Pattern makeGroup(Pattern p1, Pattern p2) { if (p1 == empty) return p2; if (p2 == empty) return p1; if (p1 == notAllowed || p2 == notAllowed) return notAllowed; if (false && p1 instanceof GroupPattern) { GroupPattern sp = (GroupPattern)p1; return makeGroup(sp.p1, makeGroup(sp.p2, p2)); } Pattern p = new GroupPattern(p1, p2); return interner.intern(p); }
GroupPattern(Pattern p1, Pattern p2) { super(p1.isNullable() && p2.isNullable(), combineHashCode(GROUP_HASH_CODE, p1.hashCode(), p2.hashCode()), p1, p2); }
@Override void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha) throws RestrictionViolationException { switch (context) { case START_CONTEXT: throw new RestrictionViolationException("start_contains_group"); case DATA_EXCEPT_CONTEXT: throw new RestrictionViolationException("data_except_contains_group"); } super.checkRestrictions(context == ELEMENT_REPEAT_CONTEXT ? ELEMENT_REPEAT_GROUP_CONTEXT : context, dad, alpha); if (context != LIST_CONTEXT && !contentTypeGroupable(p1.getContentType(), p2.getContentType())) throw new RestrictionViolationException("group_string"); }
void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha) throws RestrictionViolationException { switch (context) { case START_CONTEXT: throw new RestrictionViolationException("start_contains_group"); case DATA_EXCEPT_CONTEXT: throw new RestrictionViolationException("data_except_contains_group"); } super.checkRestrictions(context == ELEMENT_REPEAT_CONTEXT ? ELEMENT_REPEAT_GROUP_CONTEXT : context, dad, alpha); if (context != LIST_CONTEXT && !contentTypeGroupable(p1.getContentType(), p2.getContentType())) throw new RestrictionViolationException("group_string"); }
GroupPattern(Pattern p1, Pattern p2) { super(p1.isNullable() && p2.isNullable(), combineHashCode(GROUP_HASH_CODE, p1.hashCode(), p2.hashCode()), p1, p2); }
Pattern makeGroup(Pattern p1, Pattern p2) { if (p1 == empty) return p2; if (p2 == empty) return p1; if (p1 == notAllowed || p2 == notAllowed) return notAllowed; if (false && p1 instanceof GroupPattern) { GroupPattern sp = (GroupPattern)p1; return makeGroup(sp.p1, makeGroup(sp.p2, p2)); } Pattern p = new GroupPattern(p1, p2); return interner.intern(p); }