@Override public String getName() { return String.format(Locale.ENGLISH, "original_%d_%s_%d", file, type.toString(), sequence); }
private static OriginalImageLink getOriginalImageLink(Attributes attributes) { int file = Integer.parseInt(attributes.getValue("file")); int sequence = Integer.parseInt(attributes.getValue("sequence")); String imageStr = attributes.getValue("image"); int image = imageStr != null ? Integer.parseInt(imageStr) : 0; EImageLinkType type = EImageLinkType.valueOf(attributes.getValue("type")); return new OriginalImageLink(type, file, sequence, image); }
/** * Converts a given name to an image link. * <p> * Names can either be direct names of the png files or they can have the for "original_<file>_<type>_<sequence * * @param name * The name. * @param imageIndex * The index in the sequence. * @return The image link for that image, no matter if it exists or not. */ public static ImageLink fromName(String name, int imageIndex) { Matcher matcher = ORIGINAL_LINK.matcher(name); if (matcher.matches()) { EImageLinkType type = EImageLinkType.valueOf(matcher.group(ORIGINAL_LINK_TYPE)); int file = Integer.parseInt(matcher.group(ORIGINAL_LINK_FILE)); int sequence = Integer.parseInt(matcher.group(ORIGINAL_LINK_SEQUENCE)); return new OriginalImageLink(type, file, sequence, imageIndex); } else { return new DirectImageLink(name + "." + imageIndex); } }