VID implements Serializable { public static VID parse(String aVid) { Matcher m = PATTERN_EXT.matcher(aVid); if (m.matches()) { String extId = null; String extPayload = null; int annotationId = Integer.valueOf(m.group(ID)); if (m.group(EXTENSION) != null) { extId = m.group(EXTENSION); } if (m.group(EXT_PAYLOAD) != null) { extPayload = m.group(EXT_PAYLOAD); } return new VID(annotationId, extId, extPayload); } m = PATTERN_VID.matcher(aVid); if (m.matches()) { int annotationId = Integer.valueOf(m.group(ID)); int subAnnotationId = NONE; int feature = NONE; int slot = NONE; int layerId = NONE; if (m.group(SUB) != null) { subAnnotationId = Integer.valueOf(m.group(SUB)); } if (m.group(ATTR) != null) { feature = Integer.valueOf(m.group(ATTR)); } if (m.group(SLOT) != null) { slot = Integer.valueOf(m.group(SLOT)); } if (m.group(LAYER) != null) { layerId = Integer.valueOf(m.group(LAYER)); } return new VID(null, layerId, annotationId, subAnnotationId, feature, slot); } else { throw new IllegalArgumentException("Cannot parse visual identifier [" + aVid + "]"); } } VID(FeatureStructure aFS);  VID(int aAnnotationID);  VID(int aAnnotationID, String aExtensionId, String aPayload);  VID(AnnotationFS aFS, int aAttribute);  VID(int aAnnotationID, int aAttribute);  VID(AnnotationFS aFS, int aAttribute, int aSlot);  VID(int aAnnotationID, int aAttribute, int aSlot);  VID(AnnotationFS aFS, int aSubAnnotationId, int aAttribute, int aSlot);  VID(String aExtensionId, int aAnnotationID);  VID(int aAnnotationID, int aSubAnnotationId, int aAttribute,
            int aSlot);  VID(long aLayerId, int aAnnotationID, int aSubAnnotationId);  VID(long aLayerId, int aAnnotationID, int aSubAnnotationId,
            int aAttribute, int aSlot);  VID(String aExtensionId, long aLayerId, int aAnnotationID, int aSubAnnotationId,
            int aAttribute, int aSlot);  VID(String aExtensionId, long aLayerId, int aAnnotationID, int aSubAnnotationId,
            String aExtensionPayload);  VID(String aExtensionId, long aLayerId, int aAnnotationID, int aSubAnnotationId,
            int aAttribute, int aSlot, String aExtensionPayload); static VID copyVID(VID aVID); boolean isSet(); boolean isNotSet(); long getLayerId(); int getId(); int getSubId(); int getAttribute(); int getSlot(); boolean isSlotSet(); boolean isSynthetic(); String getExtensionId(); String getExtensionPayload(); static VID parseOptional(String aVid); static VID parse(String aVid); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); static final Pattern PATTERN_EXT; static final Pattern PATTERN_VID; static final int NONE; static final VID NONE_ID; }
@Test public void testParse() { assertParseVid(null, -1, 10, -1, -1, -1, "10", null); assertParseVid(null, -1, 10, -1, 1, -1, "10.1", null); assertParseVid(null, -1, 10, -1, 1, 2, "10.1.2", null); assertParseVid(null, -1, 10, 1, 2, 3, "10-1.2.3", null); assertParseVid("ext", -1, 10, -1, -1, -1, "ext:10-user", "user"); assertParseVid("ext", -1, 10, -1, -1, -1, "ext:10-1.2.3", "1.2.3"); assertParseVid("ext", -1, 10, -1, -1, -1, "ext:10-1.2.3@1", "1.2.3@1"); }