@Test public void testStarsInMiddleNonGreedy() { StarPathElement star = new StarDoublePathElement( "a*b*c" ); MatchedElement lpe = star.match( "abbccbccc", null ); Assert.assertEquals( "abbccbccc", lpe.getSubKeyRef( 0 ) ); Assert.assertEquals( "b", lpe.getSubKeyRef( 1 ) ); Assert.assertEquals( "ccbcc", lpe.getSubKeyRef( 2 ) ); Assert.assertEquals( 3, lpe.getSubKeyCount() ); }
@Override public MatchedElement match(String dataKey, WalkedPath walkedPath) { if ( stringMatch( dataKey ) ) { List<String> subKeys = new ArrayList<>(2); int midStart = finMidIndex(dataKey); int midEnd = midStart + mid.length(); String firstStarPart = dataKey.substring( prefix.length(), midStart); subKeys.add( firstStarPart ); String secondStarPart = dataKey.substring( midEnd, dataKey.length() - suffix.length() ); subKeys.add( secondStarPart ); return new MatchedElement(dataKey, subKeys); } return null; }
StarDoublePathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match(String dataKey, WalkedPath walkedPath) { if ( stringMatch( dataKey ) ) { List<String> subKeys = new ArrayList<>(2); int midStart = finMidIndex(dataKey); int midEnd = midStart + mid.length(); String firstStarPart = dataKey.substring( prefix.length(), midStart); subKeys.add( firstStarPart ); String secondStarPart = dataKey.substring( midEnd, dataKey.length() - suffix.length() ); subKeys.add( secondStarPart ); return new MatchedElement(dataKey, subKeys); } return null; } }
StarDoublePathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match(String dataKey, WalkedPath walkedPath) { if ( stringMatch( dataKey ) ) { List<String> subKeys = new ArrayList<>(2); int midStart = finMidIndex(dataKey); int midEnd = midStart + mid.length(); String firstStarPart = dataKey.substring( prefix.length(), midStart); subKeys.add( firstStarPart ); String secondStarPart = dataKey.substring( midEnd, dataKey.length() - suffix.length() ); subKeys.add( secondStarPart ); return new MatchedElement(dataKey, subKeys); } return null; } StarDoublePathElement(String key); }
StarDoublePathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match(String dataKey, WalkedPath walkedPath) { if ( stringMatch( dataKey ) ) { List<String> subKeys = new ArrayList<>(2); int midStart = finMidIndex(dataKey); int midEnd = midStart + mid.length(); String firstStarPart = dataKey.substring( prefix.length(), midStart); subKeys.add( firstStarPart ); String secondStarPart = dataKey.substring( midEnd, dataKey.length() - suffix.length() ); subKeys.add( secondStarPart ); return new MatchedElement(dataKey, subKeys); } return null; } StarDoublePathElement(String key); @Override boolean stringMatch(String literal); @Override MatchedElement match(String dataKey, WalkedPath walkedPath); @Override String getCanonicalForm(); }
StarDoublePathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match(String dataKey, WalkedPath walkedPath) { if ( stringMatch( dataKey ) ) { List<String> subKeys = new ArrayList<>(2); int midStart = finMidIndex(dataKey); int midEnd = midStart + mid.length(); String firstStarPart = dataKey.substring( prefix.length(), midStart); subKeys.add( firstStarPart ); String secondStarPart = dataKey.substring( midEnd, dataKey.length() - suffix.length() ); subKeys.add( secondStarPart ); return new MatchedElement(dataKey, subKeys); } return null; } StarDoublePathElement(String key); @Override boolean stringMatch(String literal); @Override MatchedElement match(String dataKey, WalkedPath walkedPath); @Override String getCanonicalForm();  }