001 package com.thaiopensource.relaxng.impl;
002
003 import org.xml.sax.SAXException;
004
005 abstract class BinaryPattern extends Pattern {
006 final Pattern p1;
007 final Pattern p2;
008
009 BinaryPattern(boolean nullable, int hc, Pattern p1, Pattern p2) {
010 super(nullable, Math.max(p1.getContentType(), p2.getContentType()), hc);
011 this.p1 = p1;
012 this.p2 = p2;
013 }
014
015 void checkRecursion(int depth) throws SAXException {
016 p1.checkRecursion(depth);
017 p2.checkRecursion(depth);
018 }
019
020 void checkRestrictions(int context, DuplicateAttributeDetector dad, Alphabet alpha)
021 throws RestrictionViolationException {
022 p1.checkRestrictions(context, dad, alpha);
023 p2.checkRestrictions(context, dad, alpha);
024 }
025
026 boolean samePattern(Pattern other) {
027 if (getClass() != other.getClass())
028 return false;
029 BinaryPattern b = (BinaryPattern)other;
030 return p1 == b.p1 && p2 == b.p2;
031 }
032
033 Pattern getOperand1() {
034 return p1;
035 }
036
037 Pattern getOperand2() {
038 return p2;
039 }
040 }