/** * Compile a version format string into a compiled format. The parsing starts * at position start and ends at position end. The returned format is cached so * subsequent calls to this method using the same format string will yield the * same compiled format instance. * * @param format The format string to compile. * @param start Start position in the format string * @param end End position in the format string * @return The compiled format * @throws VersionFormatException If the format could not be compiled */ public static VersionFormat compile(String format, int start, int end) throws VersionFormatException { String fmtString = format.substring(start, end).intern(); synchronized (fmtString) { VersionFormat fmt = formatCache.get(fmtString); if (fmt == null) { VersionFormatParser parser = new VersionFormatParser(); fmt = new VersionFormat(parser.compile(format, start, end)); formatCache.put(fmtString, fmt); } return fmt; } }