📄 wantpropertyelement.java
字号:
}
return _rdf_n[i];
}
/***************************************************************************
*
* ERROR HANDLING CODE
*
**************************************************************************/
// Error detection
private boolean badStateCode(int nextStateCode) {
switch (nextStateCode) {
case PARSETYPE | TYPEDLITERAL:
case PARSETYPE | TYPEDLITERAL | EMPTYWITHOBJ:
case PARSETYPE | EMPTYWITHOBJ:
case TYPEDLITERAL | EMPTYWITHOBJ:
return true;
case 0:
case PARSETYPE:
case TYPEDLITERAL:
case EMPTYWITHOBJ:
return false;
}
throw new IllegalStateException("impossible");
}
// Error classification
private int errorNumber(int nextStateCode) {
// TODO: not for 2.3. refine this error code.
return ERR_SYNTAX_ERROR;
}
/***************************************************************************
*
* ERROR MESSAGES
*
**************************************************************************/
private String descriptionOfCases(AttributeLexer ap, int nextStateCode,
String propAttrs) {
return ((propAttrs == null && ap.type == null)
|| (ap.nodeID == null && ap.resource == null && ap.type == null) || (ap.nodeID == null
&& ap.resource == null && propAttrs == null)) ? pairwiseIncompatibleErrorMessage(
nextStateCode, ap, propAttrs)
: complicatedErrorMessage(nextStateCode, ap, propAttrs);
}
private String pairwiseIncompatibleErrorMessage(int nextStateCode,
AttributeLexer ap, String propAttrs) {
ArrayList cases = new ArrayList();
if ((nextStateCode & PARSETYPE) != 0)
cases.add("rdf:parseType");
if ((nextStateCode & TYPEDLITERAL) != 0)
cases.add("rdf:datatype");
if (ap.nodeID != null)
cases.add("rdf:nodeID");
if (ap.resource != null)
cases.add("rdf:resource");
if (ap.type != null)
cases.add("rdf:type");
if (cases.size() == 1) {
if (propAttrs == null)
throw new IllegalStateException("Shouldn't happen.");
return "The attribute " + cases.get(0) + " is not permitted with "
+ propAttrs + " on a property element.";
}
String rslt = "On a property element, only one of the ";
if (propAttrs == null)
rslt += "attributes ";
for (int i = 0; i < cases.size(); i++) {
rslt += cases.get(i);
switch (cases.size() - i) {
case 1:
break;
case 2:
rslt += " or ";
break;
default:
rslt += ", ";
break;
}
}
if (propAttrs != null) {
rslt += " attributes or " + propAttrs;
}
rslt += " is permitted.";
return rslt;
}
private String complicatedErrorMessage(int nextStateCode,
AttributeLexer ap, String propAttrs) {
String subjectIs;
if (ap.nodeID == null && ap.resource == null
&& (ap.type == null || propAttrs == null))
throw new IllegalStateException("precondition failed.");
switch (nextStateCode & (TYPEDLITERAL | PARSETYPE)) {
case TYPEDLITERAL | PARSETYPE:
subjectIs = "the mutually incompatible attributes rdf:datatype and rdf:parseType are";
break;
case TYPEDLITERAL:
subjectIs = "the attribute rdf:datatype is";
break;
case PARSETYPE:
subjectIs = "the attribute rdf:parseType is";
break;
default:
throw new IllegalStateException("precondition failed");
}
String nodeIDResource = null;
if (ap.nodeID != null && ap.resource != null) {
nodeIDResource = "the mutually incompatible attributes rdf:nodeID and rdf:resource";
} else if (ap.nodeID != null) {
nodeIDResource = "the attribute rdf:nodeID";
} else if (ap.resource != null) {
nodeIDResource = "the attribute rdf:resource";
}
int otherAttCount = nodeIDResource == null ? 0 : 1;
String otherAtts;
if (ap.type != null)
otherAttCount++;
if (propAttrs != null)
otherAttCount++;
if (otherAttCount < 2)
throw new IllegalStateException("logic error");
otherAtts = otherAttCount == 2 ? "both " : "each of ";
if (ap.type != null && propAttrs != null) {
if (nodeIDResource == null)
otherAtts += "the attribute rdf:type and the " + propAttrs;
else
otherAtts += "the attribute rdf:type, the " + propAttrs;
} else if (ap.type != null) {
otherAtts += "the attribute rdf:type";
} else {
otherAtts = "the " + propAttrs;
}
if (nodeIDResource != null)
otherAtts += " and "+nodeIDResource;
return "On a property element, " + subjectIs + " incompatible with "
+ otherAtts +".";
}
private String propertyAttributeDescription(Attributes atts,
AttributeLexer ap, int cnt) {
String propAttrs = "";
int propAttrCount = atts.getLength() - cnt;
int found = 0;
if (propAttrCount == 0)
return null;
switch (propAttrCount) {
case 0:
break;
case 1:
case 2:
case 3:
for (int i = 0; i < atts.getLength(); i++)
if (!ap.done(i)) {
propAttrs += atts.getQName(i);
found++;
switch (propAttrCount - found) {
case 0:
break;
case 1:
propAttrs += " and ";
break;
default:
propAttrs += ", ";
}
}
break;
default:
if (propAttrCount < 0)
throw new IllegalStateException("Shouldn't happen.");
for (int i = 0; i < atts.getLength(); i++)
if (!ap.done(i)) {
found++;
switch (found) {
case 1:
propAttrs += atts.getQName(i) + ", ";
break;
case 2:
propAttrs += atts.getQName(i) + ", ...";
break;
default:
// ignore
}
}
}
return "property attributes (" + propAttrs + ")";
}
}
/*
* (c) Copyright 2005, 2006, 2007 Hewlett-Packard Development Company, LP All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer. 2. Redistributions in
* binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution. 3. The name of the author may not
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -