AnnotatedFieldNameUtil { public static String[] getNameComponents(String luceneFieldName) { String baseName, annotName, altName, bookkeepingName; int annotSepPos = luceneFieldName.indexOf(ANNOT_SEP); int altSepPos = luceneFieldName.indexOf(SENSITIVITY_SEP); int bookkeepingSepPos; bookkeepingSepPos = luceneFieldName.indexOf(BOOKKEEPING_SEP); if (annotSepPos >= 0) { baseName = luceneFieldName.substring(0, annotSepPos); int afterAnnotSepPos = annotSepPos + ANNOT_SEP_LEN; if (altSepPos >= 0) { annotName = luceneFieldName.substring(afterAnnotSepPos, altSepPos); altName = luceneFieldName.substring(altSepPos + SENSITIVITY_SEP_LEN); return new String[] { baseName, annotName, altName }; } if (bookkeepingSepPos >= 0 && bookkeepingSepPos > annotSepPos) { annotName = luceneFieldName.substring(afterAnnotSepPos, bookkeepingSepPos); bookkeepingName = luceneFieldName.substring(bookkeepingSepPos + BOOKKEEPING_SEP_LEN); return new String[] { baseName, annotName, null, bookkeepingName }; } annotName = luceneFieldName.substring(afterAnnotSepPos); return new String[] { baseName, annotName }; } if (altSepPos >= 0) { throw new IllegalArgumentException("Basename+altname is not a valid field name! (" + luceneFieldName + ")"); } if (bookkeepingSepPos >= 0) { baseName = luceneFieldName.substring(0, bookkeepingSepPos); altName = luceneFieldName.substring(bookkeepingSepPos + BOOKKEEPING_SEP_LEN); return new String[] { baseName, null, null, altName }; } return new String[] { luceneFieldName }; } private  AnnotatedFieldNameUtil(); static BookkeepFieldType whichBookkeepingSubfield(String bookkeepName); static String contentIdField(String fieldName); static String forwardIndexIdField(String annotFieldName); static String lengthTokensField(String fieldName); static String tagAnnotationField(String fieldName); static String annotationField(String fieldName, String annotName, String sensitivityName); static String annotationField(String fieldName, String annotName); static String annotationSensitivity(String fieldAnnotName, String sensitivityName); static String[] getNameComponents(String luceneFieldName); static String getBaseName(String luceneFieldName); static String getDefaultMainAnnotationName(); static MatchSensitivity sensitivity(String luceneField); static boolean isAnnotatedField(String luceneFieldName); static boolean isValidXmlElementName(String name); static String sanitizeXmlElementName(String name); static String sanitizeXmlElementName(String name, String replaceChar); static final String FORWARD_INDEX_ID_BOOKKEEP_NAME; static final String TAGS_ANNOT_NAME; static final String WORD_ANNOT_NAME; static final String PUNCTUATION_ANNOT_NAME; static final String LEMMA_ANNOT_NAME; static final String SUBANNOTATION_FIELD_PREFIX_SEPARATOR; static final String SUBANNOTATION_SEPARATOR; }
@Test public void testGetNameComponents() { testArray(new String[] { "contents", "lemma" }, AnnotatedFieldNameUtil.getNameComponents(AnnotatedFieldNameUtil.annotationField("contents", "lemma", null))); testArray(new String[] { "contents", "lemma", "s" }, AnnotatedFieldNameUtil.getNameComponents(AnnotatedFieldNameUtil.annotationField("contents", "lemma", "s"))); testArray(new String[] { "contents", null, null, "cid" }, AnnotatedFieldNameUtil.getNameComponents(AnnotatedFieldNameUtil.bookkeepingField("contents", null, "cid"))); testArray(new String[] { "contents", "lemma", null, "fiid" }, AnnotatedFieldNameUtil.getNameComponents(AnnotatedFieldNameUtil.bookkeepingField("contents", "lemma", "fiid"))); }