本文整理汇总了Java中org.jaxen.saxpath.SAXPathException类的典型用法代码示例。如果您正苦于以下问题:Java SAXPathException类的具体用法?Java SAXPathException怎么用?Java SAXPathException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SAXPathException类属于org.jaxen.saxpath包,在下文中一共展示了SAXPathException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addXPath
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
@SuppressWarnings({"unchecked"})
private void addXPath(Expression compiledExpr) throws SAXPathException{
expressions.add(compiledExpr);
switch(compiledExpr.scope()){
case Scope.DOCUMENT:
searchDocExpressions(compiledExpr, compiledExpr);
break;
case Scope.GLOBAL:
assert compiledExpr instanceof Literal;
globalExpressions.add(compiledExpr);
break;
default:
throw new ImpossibleException("scope of "+compiledExpr.getXPath()+" can't be"+compiledExpr.scope());
}
}
示例2: startNameStep
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
@Override
public void startNameStep(int axis, String prefix, String localName) throws SAXPathException{
Constraint constraint;
boolean star = localName.equals("*");
if(star && prefix.length()==0)
constraint = Star.INSTANCE;
else{
String uri = !allowDefaultPrefixMapping && prefix.length()==0 ? "" : nsContext.getNamespaceURI(prefix);
if(uri==null)
throw new SAXPathException("undeclared prefix: " + prefix);
if(star)
constraint = namespaceURIStub.get(uri);
else{
if("*".equals(uri))
constraint = localNameStub.get(localName);
else
constraint = qnameStub.get(uri, localName);
}
}
startStep(axis, constraint);
}
示例3: endFunction
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
@Override
public void endFunction() throws SAXPathException{
ArrayDeque params = popFrame();
javax.xml.namespace.QName name = (javax.xml.namespace.QName)params.pollFirst();
if(name.getNamespaceURI().length()==0)
push(createFunction(name.getLocalPart(), params).simplify());
else{
int noOfParams = params.size();
XPathFunction function = functionResolver.resolveFunction(name, noOfParams);
if(function==null)
throw new SAXPathException("Unknown Function: "+name);
FunctionCall functionCall = new FunctionCall(new Functions.UserFunction(name.getNamespaceURI(), name.getLocalPart(), function), noOfParams);
for(int i=0; i<noOfParams; i++)
functionCall.addMember(params.pollFirst(), i);
push(functionCall);
}
}
示例4: createReader
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
/** Create an <code>XPathReader</code> using the value of
* the <code>org.saxpath.driver</code> system property.
*
* @return an instance of the <code>XPathReader</code> specified
* by the <code>org.saxpath.driver</code> property
*
* @throws SAXPathException if the property is not set, or if
* the class can not be instantiated for some reason,
* or if the class doesn't implement the <code>XPathReader</code>
* interface
*/
public static XPathReader createReader() throws SAXPathException
{
String className = null;
try
{
className = System.getProperty( DRIVER_PROPERTY );
}
catch (SecurityException e)
{
// we'll use the default
}
if ( className == null
||
className.length() == 0 )
{
className = DEFAULT_DRIVER;
}
return createReader( className );
}
示例5: parse
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
public void parse(String xpath) throws SAXPathException
{
setUpParse( xpath );
getXPathHandler().startXPath();
expr();
getXPathHandler().endXPath();
if ( LA(1) != TokenTypes.EOF )
{
XPathSyntaxException ex = createSyntaxException( "Unexpected '" + LT(1).getTokenText() + "'" );
throw ex;
}
lexer = null;
tokens = null;
}
示例6: variableReference
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void variableReference() throws SAXPathException
{
match( TokenTypes.DOLLAR );
String prefix = null;
String variableName = null;
if ( LA(2) == TokenTypes.COLON )
{
prefix = match( TokenTypes.IDENTIFIER ).getTokenText();
match( TokenTypes.COLON );
}
else
{
prefix = "";
}
variableName = match( TokenTypes.IDENTIFIER ).getTokenText();
getXPathHandler().variableReference( prefix,
variableName );
}
示例7: relativeLocationPath
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void relativeLocationPath() throws SAXPathException
{
getXPathHandler().startRelativeLocationPath();
switch ( LA(1) )
{
case TokenTypes.SLASH:
{
match( TokenTypes.SLASH );
break;
}
case TokenTypes.DOUBLE_SLASH:
{
getXPathHandler().startAllNodeStep( Axis.DESCENDANT_OR_SELF );
getXPathHandler().endAllNodeStep();
match( TokenTypes.DOUBLE_SLASH );
break;
}
}
steps();
getXPathHandler().endRelativeLocationPath();
}
示例8: abbrStep
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void abbrStep() throws SAXPathException
{
switch ( LA(1) )
{
case TokenTypes.DOT:
{
match( TokenTypes.DOT );
getXPathHandler().startAllNodeStep( Axis.SELF );
predicates();
getXPathHandler().endAllNodeStep();
break;
}
case TokenTypes.DOT_DOT:
{
match( TokenTypes.DOT_DOT );
getXPathHandler().startAllNodeStep( Axis.PARENT );
predicates();
getXPathHandler().endAllNodeStep();
break;
}
}
}
示例9: orExpr
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void orExpr() throws SAXPathException
{
getXPathHandler().startOrExpr();
andExpr();
boolean create = false;
switch ( LA(1) )
{
case TokenTypes.OR:
{
create = true;
match( TokenTypes.OR );
orExpr();
break;
}
}
getXPathHandler().endOrExpr( create );
}
示例10: andExpr
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void andExpr() throws SAXPathException
{
getXPathHandler().startAndExpr();
equalityExpr();
boolean create = false;
switch ( LA(1) )
{
case TokenTypes.AND:
{
create = true;
match( TokenTypes.AND );
andExpr();
break;
}
}
getXPathHandler().endAndExpr( create );
}
示例11: unaryExpr
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void unaryExpr() throws SAXPathException
{
switch ( LA(1) )
{
case TokenTypes.MINUS:
{
getXPathHandler().startUnaryExpr();
match( TokenTypes.MINUS );
unaryExpr();
getXPathHandler().endUnaryExpr( Operator.NEGATIVE );
break;
}
default:
{
unionExpr();
break;
}
}
}
示例12: unionExpr
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
private void unionExpr() throws SAXPathException
{
getXPathHandler().startUnionExpr();
pathExpr();
boolean create = false;
switch ( LA(1) )
{
case TokenTypes.PIPE:
{
match( TokenTypes.PIPE );
create = true;
expr();
break;
}
}
getXPathHandler().endUnionExpr( create );
}
示例13: testPriority
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
protected void testPriority(String expr, double priority, short nodeType)
throws JaxenException, SAXPathException
{
Pattern pattern = PatternParser.parse( expr );
double d = pattern.getPriority();
short nt = pattern.getMatchType();
assertEquals( "expr: " + expr,
new Double( priority ),
new Double( d ) );
assertEquals( "nodeType: " + expr,
nodeType,
nt );
}
示例14: testBogusPaths
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
public void testBogusPaths() throws SAXPathException
{
for( int i = 0; i < bogusPaths.length; ++i )
{
final String[] bogusPath = bogusPaths[i];
try
{
reader.parse( bogusPath[0] );
fail( "Should have thrown XPathSyntaxException for " + bogusPath[0]);
}
catch( XPathSyntaxException e )
{
assertEquals( bogusPath[1], e.getMessage() );
}
}
}
示例15: getPathQuery
import org.jaxen.saxpath.SAXPathException; //导入依赖的package包/类
static Query getPathQuery(String path) throws SAXPathException
{
ApplicationContext ac = ApplicationContextHelper.getApplicationContext();
XPathReader reader = new XPathReader();
LuceneXPathHandler handler = new LuceneXPathHandler();
handler.setNamespacePrefixResolver((NamespaceService) ac.getBean("namespaceService"));
handler.setDictionaryService((DictionaryService) ac.getBean("dictionaryService"));
reader.setXPathHandler(handler);
reader.parse(path);
PathQuery pathQuery = handler.getQuery();
pathQuery.setRepeats(false);
return pathQuery;
}