public String getText() { StringBuffer buf = new StringBuffer(); if (getFilterExpr() != null) { buf.append(getFilterExpr().getText()); } if (getLocationPath() != null) { if (!getLocationPath().getSteps().isEmpty()) buf.append("/"); buf.append(getLocationPath().getText()); } return buf.toString(); }
final List<Step> steps = locationPath.getSteps();
List steps = locationPath.getSteps();
private QName getName( ValueReference path ) { if ( path.getAsQName() != null ) { return path.getAsQName(); } Expr xpath = path.getAsXPath(); if ( xpath instanceof LocationPath ) { LocationPath lp = (LocationPath) xpath; if ( lp.getSteps().size() == 1 && !lp.isAbsolute() ) { Step step = (Step) lp.getSteps().get( 0 ); if ( step instanceof NameStep ) { return getQName( (NameStep) step ); } } } return null; }
private QName getChildElementStepAsQName( ValueReference ref ) { QName qName = null; Expr xpath = ref.getAsXPath(); if ( xpath instanceof LocationPath ) { LocationPath lpath = (LocationPath) xpath; if ( lpath.getSteps().size() == 1 ) { if ( lpath.getSteps().get( 0 ) instanceof NameStep ) { NameStep step = (NameStep) lpath.getSteps().get( 0 ); if ( isChildElementStepWithoutPredicateOrWithNumberPredicate( step ) ) { String prefix = step.getPrefix(); if ( prefix.isEmpty() ) { qName = new QName( step.getLocalName() ); } else { String ns = ref.getNsContext().translateNamespacePrefixToUri( prefix ); qName = new QName( ns, step.getLocalName(), prefix ); } LOG.debug( "QName: " + qName ); } } } } return qName; }
@SuppressWarnings("unchecked") public String getElementNameWithPredicates() throws JaxenException { BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator()); Expr rootExpr = baseXPath.getRootExpr(); LocationPath locationPath = (LocationPath) rootExpr; List<Step> steps = locationPath.getSteps(); Step lastStep = steps.get(steps.size() - 1); return MCRNodeBuilder.simplify(lastStep.getText()); }
public static List<QName> extractQNames( XPath xpath ) { List<QName> list = new ArrayList<QName>(); try { Expr expr = new BaseXPath( xpath.getXPath(), null ).getRootExpr(); if ( expr instanceof LocationPath ) { LocationPath lp = (LocationPath) expr; for ( Object o : lp.getSteps() ) { findQName( list, (Step) o, xpath.getNamespaceContext() ); } } } catch ( JaxenException e ) { // not a proper xpath } return list; }
private Element createRootElement(String xPath) throws JaxenException { BaseXPath baseXPath = new BaseXPath(xPath, new DocumentNavigator()); LocationPath lp = (LocationPath) (baseXPath.getRootExpr()); NameStep nameStep = (NameStep) (lp.getSteps().get(0)); String prefix = nameStep.getPrefix(); Namespace ns = prefix.isEmpty() ? Namespace.NO_NAMESPACE : MCRConstants.getStandardNamespace(prefix); return new Element(nameStep.getLocalName(), ns); }
if ( !( lhs instanceof LocationPath ) || ( (LocationPath) lhs ).getSteps().size() != 1 || !( ( (LocationPath) lhs ).getSteps().get( 0 ) instanceof NameStep ) || ( (NameStep) ( (LocationPath) lhs ).getSteps().get( 0 ) ).getAxis() != ATTRIBUTE || !( (NameStep) ( (LocationPath) lhs ).getSteps().get( 0 ) ).getLocalName().equals( "name" ) ) { String msg = "Unable to map PropertyName '" + propName.getAsText() + "'. Slot steps must specify a single name predicate (../rim:Slot[@name=...]).";
for ( Object o : ( (LocationPath) path ).getSteps() ) { if ( o instanceof NameStep ) { NameStep step = (NameStep) o;
private Pair<QName, Integer> trySimpleMultiProp( ValueReference valueReference, FeatureType ft ) throws OWSException { Expr expr = valueReference.getAsXPath(); if ( !( expr instanceof LocationPath ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } Object obj = ( (LocationPath) expr ).getSteps().get( 0 ); if ( !( obj instanceof NameStep ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } NameStep namestep = (NameStep) obj; obj = namestep.getPredicates().get( 0 ); if ( !( obj instanceof Predicate ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } Predicate pred = (Predicate) obj; expr = pred.getExpr(); if ( !( expr instanceof NumberExpr ) ) { throw new OWSException( "Cannot update property on feature type '" + ft.getName() + "'. Complex property paths are not supported.", OPERATION_NOT_SUPPORTED ); } NumberExpr ne = (NumberExpr) expr; int index = Math.round( Float.parseFloat( ne.getText() ) ); String namespaceUri = determineNamespaceUri( valueReference, ft, namestep ); return new Pair<QName, Integer>( new QName( namespaceUri, namestep.getLocalName() ), index - 1 ); }
List<Step> steps = locationPath.getSteps();
List<Step> steps = locationPath.getSteps();
List<Step> steps = locationPath.getSteps();
List<Step> steps = locationPath.getSteps();
List<Step> steps = locationPath.getSteps();
throw new UnmappableException( msg ); for ( Object step : ( (LocationPath) xpath ).getSteps() ) { if ( step instanceof AllNodeStep ) {
if (maybeListener.isPresent()) { final StepListener l = maybeListener.get(); for (Object step : path.getSteps()) { if (step instanceof AllNodeStep) { l.onAll((AllNodeStep) step);
private static void extractPrefixes( Expr expr, Set<String> prefixes ) { if ( expr instanceof BinaryExpr ) { extractPrefixes( ( (BinaryExpr) expr ).getLHS(), prefixes ); extractPrefixes( ( (BinaryExpr) expr ).getRHS(), prefixes ); } else if ( expr instanceof FilterExpr ) { extractPrefixes( ( (FilterExpr) expr ).getExpr(), prefixes ); for ( Object pred : ( (FilterExpr) expr ).getPredicates() ) { extractPrefixes( (Predicate) pred, prefixes ); } } else if ( expr instanceof FunctionCallExpr ) { extractPrefix( ( (FunctionCallExpr) expr ).getPrefix(), prefixes ); for ( Object param : ( (FunctionCallExpr) expr ).getParameters() ) { extractPrefixes( (Expr) param, prefixes ); } } else if ( expr instanceof LocationPath ) { for ( Object step : ( (LocationPath) expr ).getSteps() ) { extractPrefixes( (Step) step, prefixes ); } } else if ( expr instanceof PathExpr ) { extractPrefixes( ( (PathExpr) expr ).getFilterExpr(), prefixes ); extractPrefixes( ( (PathExpr) expr ).getLocationPath(), prefixes ); } else if ( expr instanceof UnaryExpr ) { extractPrefixes( ( (UnaryExpr) expr ).getExpr(), prefixes ); } else if ( expr instanceof VariableReferenceExpr ) { extractPrefix( ( (VariableReferenceExpr) expr ).getPrefix(), prefixes ); } }