@Test public void asRegex() { { FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd}-%i.txt", context); String regex = fnp.toRegex(); assertEquals("foo-\\d{4}\\.\\d{2}\\.\\d{2}-\\d+.txt", regex); } { FileNamePattern fnp = new FileNamePattern("foo-%d{yyyy.MM.dd'T'}-%i.txt", context); String regex = fnp.toRegex(); assertEquals("foo-\\d{4}\\.\\d{2}\\.\\d{2}T-\\d+.txt", regex); } }
public String toRegex() { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("\\d+"); } else if (p instanceof DateTokenConverter) { DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p; buf.append(dtc.toRegex()); } p = p.getNext(); } return buf.toString(); }
FileNamePattern extends ContextAwareBase { public String toRegex() { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("\\d+"); } else if (p instanceof DateTokenConverter) { DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p; buf.append(dtc.toRegex()); } p = p.getNext(); } return buf.toString(); } }
FileNamePattern extends ContextAwareBase { public String toRegex() { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("\\d+"); } else if (p instanceof DateTokenConverter) { DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p; buf.append(dtc.toRegex()); } p = p.getNext(); } return buf.toString(); } FileNamePattern(String patternArg, Context contextArg); }
FileNamePattern extends ContextAwareBase { public String toRegex() { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("\\d+"); } else if (p instanceof DateTokenConverter) { DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p; buf.append(dtc.toRegex()); } p = p.getNext(); } return buf.toString(); } FileNamePattern(String patternArg, Context contextArg); String toString(); @Override int hashCode(); @Override boolean equals(Object obj); DateTokenConverter<Object> getPrimaryDateTokenConverter(); IntegerTokenConverter getIntegerTokenConverter(); boolean hasIntegerTokenCOnverter(); String convertMultipleArguments(Object... objectList); String convert(Object o); String convertInt(int i); void setPattern(String pattern); String getPattern(); String toRegexForFixedDate(Date date); String toRegex(); }
FileNamePattern extends ContextAwareBase { public String toRegex() { StringBuilder buf = new StringBuilder(); Converter<Object> p = headTokenConverter; while (p != null) { if (p instanceof LiteralConverter) { buf.append(p.convert(null)); } else if (p instanceof IntegerTokenConverter) { buf.append("\\d+"); } else if (p instanceof DateTokenConverter) { DateTokenConverter<Object> dtc = (DateTokenConverter<Object>) p; buf.append(dtc.toRegex()); } p = p.getNext(); } return buf.toString(); } FileNamePattern(String patternArg, Context contextArg); String toString(); @Override int hashCode(); @Override boolean equals(Object obj); DateTokenConverter<Object> getPrimaryDateTokenConverter(); IntegerTokenConverter getIntegerTokenConverter(); boolean hasIntegerTokenCOnverter(); String convertMultipleArguments(Object... objectList); String convert(Object o); String convertInt(int i); void setPattern(String pattern); String getPattern(); String toRegexForFixedDate(Date date); String toRegex();  }