/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* A representation of a content model. A content model is
* basically a restricted BNF expression. It is restricted in
* the sense that it must be deterministic. This means that you
* don't have to represent it as a finite state automata.<p>
* See Annex H on page 556 of the SGML handbook for more information.
*
* @author Arthur van Hoff
*
*/
/**
* Type. Either '*', '?', '+', ',', '|', '&'.
*/
public int type;
/**
* The content. Either an Element or a ContentModel.
*/
/**
* The next content model (in a ',', '|' or '&' expression).
*/
public ContentModel() {
}
/**
* Create a content model for an element.
*/
}
/**
* Create a content model of a particular type.
*/
}
/**
* Create a content model of a particular type.
*/
}
/**
* Return true if the content model could
* match an empty input stream.
*/
public boolean empty() {
switch (type) {
case '*':
case '?':
return true;
case '+':
case '|':
if (m.empty()) {
return true;
}
}
return false;
case ',':
case '&':
if (!m.empty()) {
return false;
}
}
return true;
default:
return false;
}
}
/**
* Update elemVec with the list of elements that are
* part of the this contentModel.
*/
switch (type) {
case '*':
case '?':
case '+':
break;
case ',':
case '|':
case '&':
m.getElements(elemVec);
}
break;
default:
}
}
private boolean valSet[];
private boolean val[];
// A cache used by first(). This cache was found to speed parsing
// by about 10% (based on measurements of the 4-12 code base after
// buffering was fixed).
/**
* Return true if the token could potentially be the
* first token in the input stream.
*/
switch (type) {
case '*':
case '?':
case '+':
case ',':
return true;
}
if (!m.empty()) {
return false;
}
}
return false;
case '|':
case '&': {
// All Element instances are created before this ever executes
}
}
break;
}
}
}
default:
// PENDING: refer to comment in ContentModelState
/*
if (content == token) {
return true;
}
Element e = (Element)content;
if (e.omitStart() && e.content != null) {
return e.content.first(token);
}
return false;
*/
}
}
/**
* Return the element that must be next.
*/
switch (type) {
case '&':
case '|':
case '*':
case '?':
return null;
case '+':
case ',':
default:
}
}
/**
* Convert to a string.
*/
switch (type) {
case '*':
return content + "*";
case '?':
return content + "?";
case '+':
return content + "+";
case ',':
case '|':
case '&':
}
}
default:
}
}
}