75 /** 76 * Return the content model that is relevant to the current state. 77 */ 78 public ContentModel getModel() { 79 ContentModel m = model; 80 for (int i = 0; i < value; i++) { 81 if (m.next != null) { 82 m = m.next; 83 } else { 84 return null; 85 } 86 } 87 return m; 88 } 89 90 /** 91 * Check if the state can be terminated. That is there are no more 92 * tokens required in the input stream. 93 * @return true if the model can terminate without further input 94 */ 95 public boolean terminate() { 96 switch (model.type) { 97 case '+': 98 if ((value == 0) && !(model).empty()) { 99 return false; 100 } 101 case '*': 102 case '?': 103 return (next == null) || next.terminate(); 104 105 case '|': 106 for (ContentModel m = (ContentModel)model.content ; m != null ; m = m.next) { 107 if (m.empty()) { 108 return (next == null) || next.terminate(); 109 } 110 } 111 return false; 112 113 case '&': { 114 ContentModel m = (ContentModel)model.content; 115 116 for (int i = 0 ; m != null ; i++, m = m.next) { 117 if ((value & (1L << i)) == 0) { 118 if (!m.empty()) { 119 return false; 120 } | 75 /** 76 * Return the content model that is relevant to the current state. 77 */ 78 public ContentModel getModel() { 79 ContentModel m = model; 80 for (int i = 0; i < value; i++) { 81 if (m.next != null) { 82 m = m.next; 83 } else { 84 return null; 85 } 86 } 87 return m; 88 } 89 90 /** 91 * Check if the state can be terminated. That is there are no more 92 * tokens required in the input stream. 93 * @return true if the model can terminate without further input 94 */ 95 @SuppressWarnings("fallthrough") 96 public boolean terminate() { 97 switch (model.type) { 98 case '+': 99 if ((value == 0) && !(model).empty()) { 100 return false; 101 } 102 // Fall through okay? 103 case '*': 104 case '?': 105 return (next == null) || next.terminate(); 106 107 case '|': 108 for (ContentModel m = (ContentModel)model.content ; m != null ; m = m.next) { 109 if (m.empty()) { 110 return (next == null) || next.terminate(); 111 } 112 } 113 return false; 114 115 case '&': { 116 ContentModel m = (ContentModel)model.content; 117 118 for (int i = 0 ; m != null ; i++, m = m.next) { 119 if ((value & (1L << i)) == 0) { 120 if (!m.empty()) { 121 return false; 122 } |