/** * Returns true if the segment is the container Id. */ static boolean isId(Object o) { return ItemPathSegmentUtil.isId(o); }
/** * Returns true if the segment is the Identifier one ("#"). */ static boolean isIdentifier(Object segment) { return ItemPathSegmentUtil.isIdentifier(segment); }
/** * Returns true if the segment is a name segment. * * Note that special segments (parent, reference, identifier, variable) are NOT considered to be name segments, * even if they can be represented using QName. */ static boolean isName(Object segment) { return ItemPathSegmentUtil.isName(segment); }
public static QName getSpecialSymbol(Object o) { if (o instanceof QName) { return (QName) o; } else if (o instanceof IdentifierPathSegment) { return IdentifierPathSegment.QNAME; } else if (o instanceof ParentPathSegment) { return ParentPathSegment.QNAME; } else if (o instanceof ObjectReferencePathSegment) { return ObjectReferencePathSegment.QNAME; } else { throw new IllegalArgumentException("Not a special item path segment: " + getStringInformation(o)); } }
public static boolean isName(Object segment) { return segment instanceof NameItemPathSegment || segment instanceof QName && !isSpecialName(segment); // todo remove }
/** * Returns true if the segment is the container Id with value of NULL. */ static boolean isNullId(Object o) { return ItemPathSegmentUtil.isNullId(o); }
/** * Returns true if the segment is a special one: parent, reference, identifier, variable. */ static boolean isSpecial(Object segment) { return ItemPathSegmentUtil.isSpecial(segment); }
/** * Returns true if the segment is the Object Reference one ("@"). */ static boolean isObjectReference(Object segment) { return ItemPathSegmentUtil.isObjectReference(segment); }
/** * Returns true if the segment is the Parent one (".."). */ static boolean isParent(Object segment) { return ItemPathSegmentUtil.isParent(segment); }
static boolean segmentsEquivalent(Object o1, Object o2) { if (ItemPath.isName(o1)) { return ItemPath.isName(o2) && QNameUtil.match(ItemPath.toName(o1), ItemPath.toName(o2)); } else if (ItemPath.isVariable(o1)) { return ItemPath.isVariable(o2) && QNameUtil.match(ItemPath.toVariableName(o1), ItemPath.toVariableName(o2)); } else if (ItemPath.isSpecial(o1)) { return ItemPath.isSpecial(o2) && QNameUtil.match(ItemPathSegmentUtil.getSpecialSymbol(o1), ItemPathSegmentUtil.getSpecialSymbol(o2)); } else if (ItemPath.isId(o1)) { return ItemPath.isId(o2) && Objects.equals(ItemPath.toId(o1), ItemPath.toId(o2)); } else { return false; } }
public static QName toVariableName(Object segment) { if (segment instanceof VariableItemPathSegment) { return ((VariableItemPathSegment) segment).getName(); } else { throw new IllegalArgumentException("Not a variable: " + getStringInformation(segment)); } }
static boolean isSpecial(Object o) { return o instanceof IdentifierPathSegment || o instanceof ReferencePathSegment || isSpecialName(o); // todo remove }
static ItemName toName(Object segment, boolean failOnError) { if (segment instanceof NameItemPathSegment) { return ((NameItemPathSegment) segment).getName(); } else if (segment instanceof ItemName) { return (ItemName) segment; } else if (segment instanceof QName) { return ItemName.fromQName((QName) segment); } else { if (failOnError) { throw new IllegalArgumentException("Not a name: " + getStringInformation(segment)); } else { return null; } } }