@Test(expected = IllegalArgumentException.class) public void property_should_not_start_with_digit() { parse("123åäö"); }
public static PropertyPath parse(String path) { checkNotNull(path); if (path.length() == 0) { return ROOT; } return newParser(path, false).parsePath().accept(new PropertyPathBaseVisitor<PropertyPath>() { private PropertyPath parent = ROOT; @Override public PropertyPath visitIndex(PropertyPathParser.IndexContext ctx) { return parent = new Index(parent, parseLong(ctx.getText())); } @Override public PropertyPath visitKey(PropertyPathParser.KeyContext ctx) { String keyLiteral = ctx.getText(); return parent = new Key(parent, unescapeEcmaScript(keyLiteral.substring(1, keyLiteral.length() - 1))); } @Override public PropertyPath visitProperty(PropertyPathParser.PropertyContext ctx) { return parent = new Property(parent, ctx.getText()); } @Override public PropertyPath visitAnyProperty(@NotNull PropertyPathParser.AnyPropertyContext ctx) { return parent = new AnyProperty(parent); } @Override public PropertyPath visitAnyIndex(PropertyPathParser.AnyIndexContext ctx) { return parent = new AnyIndex(parent); } @Override public PropertyPath visitAnyKey(PropertyPathParser.AnyKeyContext ctx) { return parent = new AnyKey(parent); } @Override public PropertyPath visitAny(PropertyPathParser.AnyContext ctx) { return parent = new Any(parent); } @Override protected PropertyPath defaultResult() { return parent; } }); }
PropertyPath implements Comparable<PropertyPath> { public static PropertyPath parse(String path) { checkNotNull(path); if (path.length() == 0) { return ROOT; } return newParser(path, false).parsePath().accept(new PropertyPathBaseVisitor<PropertyPath>() { private PropertyPath parent = ROOT; @Override public PropertyPath visitIndex(PropertyPathParser.IndexContext ctx) { return parent = new Index(parent, parseLong(ctx.getText())); } @Override public PropertyPath visitKey(PropertyPathParser.KeyContext ctx) { String keyLiteral = ctx.getText(); return parent = new Key(parent, unescapeEcmaScript(keyLiteral.substring(1, keyLiteral.length() - 1))); } @Override public PropertyPath visitProperty(PropertyPathParser.PropertyContext ctx) { return parent = new Property(parent, ctx.getText()); } @Override public PropertyPath visitAnyProperty(@NotNull PropertyPathParser.AnyPropertyContext ctx) { return parent = new AnyProperty(parent); } @Override public PropertyPath visitAnyIndex(PropertyPathParser.AnyIndexContext ctx) { return parent = new AnyIndex(parent); } @Override public PropertyPath visitAnyKey(PropertyPathParser.AnyKeyContext ctx) { return parent = new AnyKey(parent); } @Override public PropertyPath visitAny(PropertyPathParser.AnyContext ctx) { return parent = new Any(parent); } @Override protected PropertyPath defaultResult() { return parent; } }); } }
PropertyPath implements Comparable<PropertyPath> { public static PropertyPath parse(String path) { checkNotNull(path); if (path.length() == 0) { return ROOT; } return newParser(path, false).parsePath().accept(new PropertyPathBaseVisitor<PropertyPath>() { private PropertyPath parent = ROOT; @Override public PropertyPath visitIndex(PropertyPathParser.IndexContext ctx) { return parent = new Index(parent, parseLong(ctx.getText())); } @Override public PropertyPath visitKey(PropertyPathParser.KeyContext ctx) { String keyLiteral = ctx.getText(); return parent = new Key(parent, unescapeEcmaScript(keyLiteral.substring(1, keyLiteral.length() - 1))); } @Override public PropertyPath visitProperty(PropertyPathParser.PropertyContext ctx) { return parent = new Property(parent, ctx.getText()); } @Override public PropertyPath visitAnyProperty(@NotNull PropertyPathParser.AnyPropertyContext ctx) { return parent = new AnyProperty(parent); } @Override public PropertyPath visitAnyIndex(PropertyPathParser.AnyIndexContext ctx) { return parent = new AnyIndex(parent); } @Override public PropertyPath visitAnyKey(PropertyPathParser.AnyKeyContext ctx) { return parent = new AnyKey(parent); } @Override public PropertyPath visitAny(PropertyPathParser.AnyContext ctx) { return parent = new Any(parent); } @Override protected PropertyPath defaultResult() { return parent; } }); } PropertyPath(); }
PropertyPath implements Comparable<PropertyPath> { public static PropertyPath parse(String path) { checkNotNull(path); if (path.length() == 0) { return ROOT; } return newParser(path, false).parsePath().accept(new PropertyPathBaseVisitor<PropertyPath>() { private PropertyPath parent = ROOT; @Override public PropertyPath visitIndex(PropertyPathParser.IndexContext ctx) { return parent = new Index(parent, parseLong(ctx.getText())); } @Override public PropertyPath visitKey(PropertyPathParser.KeyContext ctx) { String keyLiteral = ctx.getText(); return parent = new Key(parent, unescapeEcmaScript(keyLiteral.substring(1, keyLiteral.length() - 1))); } @Override public PropertyPath visitProperty(PropertyPathParser.PropertyContext ctx) { return parent = new Property(parent, ctx.getText()); } @Override public PropertyPath visitAnyProperty(@NotNull PropertyPathParser.AnyPropertyContext ctx) { return parent = new AnyProperty(parent); } @Override public PropertyPath visitAnyIndex(PropertyPathParser.AnyIndexContext ctx) { return parent = new AnyIndex(parent); } @Override public PropertyPath visitAnyKey(PropertyPathParser.AnyKeyContext ctx) { return parent = new AnyKey(parent); } @Override public PropertyPath visitAny(PropertyPathParser.AnyContext ctx) { return parent = new Any(parent); } @Override protected PropertyPath defaultResult() { return parent; } }); } PropertyPath(); static PropertyPath parse(String path); Property property(String name); final Index index(long index); final Key key(String index); final PropertyPath keyOrIndex(Object object); final PropertyPath node(NodeId nodeId); final AnyProperty anyProperty(); final AnyIndex anyIndex(); final AnyKey anyKey(); final Any any(); final SubPath propertyOrKey(String string); final PropertyPath path(PropertyPath path); List<SubPath> asList(); boolean isRoot(); boolean startsWith(PropertyPath other); PropertyPath toSchemaPath(); @Override int compareTo(PropertyPath other); abstract String toString(); abstract boolean equals(Object obj); abstract int hashCode(); abstract NodeId getNodeId(); }
PropertyPath implements Comparable<PropertyPath> { public static PropertyPath parse(String path) { checkNotNull(path); if (path.length() == 0) { return ROOT; } return newParser(path, false).parsePath().accept(new PropertyPathBaseVisitor<PropertyPath>() { private PropertyPath parent = ROOT; @Override public PropertyPath visitIndex(PropertyPathParser.IndexContext ctx) { return parent = new Index(parent, parseLong(ctx.getText())); } @Override public PropertyPath visitKey(PropertyPathParser.KeyContext ctx) { String keyLiteral = ctx.getText(); return parent = new Key(parent, unescapeEcmaScript(keyLiteral.substring(1, keyLiteral.length() - 1))); } @Override public PropertyPath visitProperty(PropertyPathParser.PropertyContext ctx) { return parent = new Property(parent, ctx.getText()); } @Override public PropertyPath visitAnyProperty(@NotNull PropertyPathParser.AnyPropertyContext ctx) { return parent = new AnyProperty(parent); } @Override public PropertyPath visitAnyIndex(PropertyPathParser.AnyIndexContext ctx) { return parent = new AnyIndex(parent); } @Override public PropertyPath visitAnyKey(PropertyPathParser.AnyKeyContext ctx) { return parent = new AnyKey(parent); } @Override public PropertyPath visitAny(PropertyPathParser.AnyContext ctx) { return parent = new Any(parent); } @Override protected PropertyPath defaultResult() { return parent; } }); } PropertyPath(); static PropertyPath parse(String path); Property property(String name); final Index index(long index); final Key key(String index); final PropertyPath keyOrIndex(Object object); final PropertyPath node(NodeId nodeId); final AnyProperty anyProperty(); final AnyIndex anyIndex(); final AnyKey anyKey(); final Any any(); final SubPath propertyOrKey(String string); final PropertyPath path(PropertyPath path); List<SubPath> asList(); boolean isRoot(); boolean startsWith(PropertyPath other); PropertyPath toSchemaPath(); @Override int compareTo(PropertyPath other); abstract String toString(); abstract boolean equals(Object obj); abstract int hashCode(); abstract NodeId getNodeId(); static final Root ROOT; }