@Test( expected = ValueFormatException.class ) public void shouldThrowValueFormatExceptionOnMalformedName() { factory.splitPath("/jcr:foo/{foobar"); }
String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } }
PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } } }
PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } } PathValueFactory( TextDecoder decoder,
                             ValueFactories factories ); }
PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } } PathValueFactory( TextDecoder decoder,
                             ValueFactories factories ); @Override PathFactory with( ValueFactories valueFactories ); @Override Path createRootPath(); @Override Path create( String value ); @Override Path create( final String value,
                        TextDecoder decoder ); @Override Path create( int value ); @Override Path create( long value ); @Override Path create( boolean value ); @Override Path create( float value ); @Override Path create( double value ); @Override Path create( BigDecimal value ); @Override Path create( Calendar value ); @Override Path create( Date value ); @Override Path create( DateTime value ); @Override Path create( Name value ); @Override Path create( Path value ); @Override Path create( Path.Segment value ); @Override Path createAbsolutePath( Name... segmentNames ); @Override Path createAbsolutePath( Segment... segments ); @Override Path createAbsolutePath( Iterable<Segment> segments ); @Override Path createRelativePath(); @Override Path createRelativePath( Name... segmentNames ); @Override Path createRelativePath( Segment... segments ); @Override Path createRelativePath( Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        Path childPath ); @Override Path create( Path parentPath,
                        Name segmentName,
                        int index ); @Override Path create( Path parentPath,
                        String segmentName,
                        int index ); @Override Path create( Path parentPath,
                        Name... segmentNames ); @Override Path create( Path parentPath,
                        Segment... segments ); @Override Path create( Path parentPath,
                        Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        String subpath ); @Override Segment createSegment( Name segmentName ); @Override Segment createSegment( Name segmentName,
                                  int index ); @Override Segment createSegment( String segmentName ); @Override Segment createSegment( String segmentName,
                                  TextDecoder decoder ); @Override Segment createSegment( String segmentName,
                                  int index ); @Override Path create( Reference value ); @Override Path create( URI value ); @Override Path create( UUID value ); @Override Path create( NodeKey value ); @Override Path create( byte[] value ); @Override Path create( BinaryValue value ); @Override Path create( InputStream stream ); @Override Path[] createEmptyArray( int length ); }
PathValueFactory extends AbstractValueFactory<Path> implements PathFactory { String[] splitPath( String rawPath ) { List<String> segments = new LinkedList<String>(); int curr = 0; int nextBrace = rawPath.indexOf('{'); int nextSlash = rawPath.indexOf('/'); while (true) { if ((nextSlash == -1 && nextBrace > -1) || (nextBrace > -1 && nextBrace < nextSlash)) { int nextClosingBrace = rawPath.indexOf('}', nextBrace); if (nextClosingBrace == -1) { throw new ValueFormatException(rawPath, getPropertyType(), GraphI18n.missingClosingBrace.text(rawPath)); } nextSlash = rawPath.indexOf('/', nextClosingBrace + 1); nextBrace = rawPath.indexOf('{', nextClosingBrace + 1); } else if ((nextBrace == -1 && nextSlash > -1) || (nextSlash > -1 && nextSlash < nextBrace)) { if (nextSlash > 0) { segments.add(rawPath.substring(curr, nextSlash)); } curr = nextSlash + 1; nextSlash = rawPath.indexOf('/', curr); } else { segments.add(rawPath.substring(curr)); return segments.toArray(new String[segments.size()]); } } } PathValueFactory( TextDecoder decoder,
                             ValueFactories factories ); @Override PathFactory with( ValueFactories valueFactories ); @Override Path createRootPath(); @Override Path create( String value ); @Override Path create( final String value,
                        TextDecoder decoder ); @Override Path create( int value ); @Override Path create( long value ); @Override Path create( boolean value ); @Override Path create( float value ); @Override Path create( double value ); @Override Path create( BigDecimal value ); @Override Path create( Calendar value ); @Override Path create( Date value ); @Override Path create( DateTime value ); @Override Path create( Name value ); @Override Path create( Path value ); @Override Path create( Path.Segment value ); @Override Path createAbsolutePath( Name... segmentNames ); @Override Path createAbsolutePath( Segment... segments ); @Override Path createAbsolutePath( Iterable<Segment> segments ); @Override Path createRelativePath(); @Override Path createRelativePath( Name... segmentNames ); @Override Path createRelativePath( Segment... segments ); @Override Path createRelativePath( Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        Path childPath ); @Override Path create( Path parentPath,
                        Name segmentName,
                        int index ); @Override Path create( Path parentPath,
                        String segmentName,
                        int index ); @Override Path create( Path parentPath,
                        Name... segmentNames ); @Override Path create( Path parentPath,
                        Segment... segments ); @Override Path create( Path parentPath,
                        Iterable<Segment> segments ); @Override Path create( Path parentPath,
                        String subpath ); @Override Segment createSegment( Name segmentName ); @Override Segment createSegment( Name segmentName,
                                  int index ); @Override Segment createSegment( String segmentName ); @Override Segment createSegment( String segmentName,
                                  TextDecoder decoder ); @Override Segment createSegment( String segmentName,
                                  int index ); @Override Path create( Reference value ); @Override Path create( URI value ); @Override Path create( UUID value ); @Override Path create( NodeKey value ); @Override Path create( byte[] value ); @Override Path create( BinaryValue value ); @Override Path create( InputStream stream ); @Override Path[] createEmptyArray( int length );  }