public <T extends CDOMObject> PrimitiveCollection<T> getChoiceSet( SelectionCreator<T> sc, String value) { try { return ChoiceSetLoadUtilities.getChoiceSet(this, sc, value); } catch (ParsingSeparator.GroupingMismatchException e) { Logging.errorPrint("Group Mismatch in getting ChoiceSet: " + e.getMessage()); return null; } }
public <T extends CDOMObject> PrimitiveCollection<T> getPrimitiveChoiceFilter( SelectionCreator<T> sc, String key) { return ChoiceSetLoadUtilities.getPrimitive(this, sc, key); }
@Override protected ParseResult parseTokenWithSeparator(LoadContext context, CDOMObject obj, String value) { if (value.indexOf('[') != -1 || value.indexOf(']') != -1) { return new ParseResult.Fail( getParentToken() + ":" + getTokenName() + " may not contain brackets: " + value, context); } int pipeLoc = value.lastIndexOf('|'); String activeValue; String title; if (pipeLoc == -1) { activeValue = value; title = getDefaultTitle(); } else { String titleString = value.substring(pipeLoc + 1); if (titleString.startsWith("TITLE=")) { title = titleString.substring(6); if (title.startsWith("\"")) { title = title.substring(1, title.length() - 1); } activeValue = value.substring(0, pipeLoc); if (title == null || title.length() == 0) { return new ParseResult.Fail( getParentToken() + ":" + getTokenName() + " had TITLE= but no title: " + value, context); } } else { activeValue = value; title = getDefaultTitle(); } } CDOMGroupRef<T> allReference = context.ref.getCDOMAllReference(getChooseClass()); PrimitiveCollection<T> prim; if (Constants.LST_ALL.equals(activeValue)) { prim = allReference; } else { if (hasIllegalSeparator('|', activeValue)) { return ParseResult.INTERNAL_ERROR; } Set<PrimitiveCollection<T>> set = new HashSet<PrimitiveCollection<T>>(); StringTokenizer st = new StringTokenizer(activeValue, "|"); while (st.hasMoreTokens()) { String tok = st.nextToken(); PrimitiveCollection<T> ref = ChoiceSetLoadUtilities.getSimplePrimitive(context, getManufacturer(context), tok); if (ref == null) { return new ParseResult.Fail( "Error: Count not get Reference for " + tok + " in " + getTokenName(), context); } if (!set.add(ref)) { return new ParseResult.Fail( "Error, Found item: " + ref + " twice while parsing " + getTokenName(), context); } } if (set.isEmpty()) { return new ParseResult.Fail("No items in set.", context); } prim = new CompoundOrPrimitive<T>(set); } if (!prim.getGroupingState().isValid()) { ComplexParseResult cpr = new ComplexParseResult(); cpr.addErrorMessage("Invalid combination of objects was used in: " + activeValue); cpr.addErrorMessage(" Check that ALL is not combined with another item"); return cpr; } PrimitiveChoiceSet<T> pcs = new CollectionToChoiceSet<T>(prim); BasicChooseInformation<T> tc = new BasicChooseInformation<T>(getTokenName(), pcs); tc.setTitle(title); tc.setChoiceActor(this); context.obj.put(obj, ObjectKey.CHOOSE_INFO, tc); return ParseResult.SUCCESS; }