1 /*
   2  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.rngom.parse.host;
  27 
  28 import com.sun.xml.internal.rngom.ast.builder.Annotations;
  29 import com.sun.xml.internal.rngom.ast.builder.BuildException;
  30 import com.sun.xml.internal.rngom.ast.builder.DataPatternBuilder;
  31 import com.sun.xml.internal.rngom.ast.om.Location;
  32 import com.sun.xml.internal.rngom.ast.om.ParsedElementAnnotation;
  33 import com.sun.xml.internal.rngom.ast.om.ParsedPattern;
  34 import com.sun.xml.internal.rngom.parse.Context;
  35 
  36 /**
  37  *
  38  * @author
  39  *      Kohsuke Kawaguchi (kk@kohsuke.org)
  40  */
  41 final class DataPatternBuilderHost extends Base implements DataPatternBuilder {
  42     final DataPatternBuilder lhs;
  43     final DataPatternBuilder rhs;
  44 
  45     DataPatternBuilderHost( DataPatternBuilder lhs, DataPatternBuilder rhs ) {
  46         this.lhs = lhs;
  47         this.rhs = rhs;
  48     }
  49 
  50     public void addParam(String name, String value, Context context, String ns, Location _loc, Annotations _anno) throws BuildException {
  51         LocationHost loc = cast(_loc);
  52         AnnotationsHost anno = cast(_anno);
  53 
  54         lhs.addParam( name, value, context, ns, loc.lhs, anno.lhs );
  55         rhs.addParam( name, value, context, ns, loc.rhs, anno.rhs );
  56     }
  57 
  58     public void annotation(ParsedElementAnnotation _ea) {
  59         ParsedElementAnnotationHost ea = (ParsedElementAnnotationHost) _ea;
  60 
  61         lhs.annotation(ea.lhs);
  62         rhs.annotation(ea.rhs);
  63     }
  64 
  65     public ParsedPattern makePattern(Location _loc, Annotations _anno) throws BuildException {
  66         LocationHost loc = cast(_loc);
  67         AnnotationsHost anno = cast(_anno);
  68 
  69         return new ParsedPatternHost(
  70             lhs.makePattern( loc.lhs, anno.lhs ),
  71             rhs.makePattern( loc.rhs, anno.rhs ));
  72     }
  73 
  74     public ParsedPattern makePattern(ParsedPattern _except, Location _loc, Annotations _anno) throws BuildException {
  75         ParsedPatternHost except = (ParsedPatternHost) _except;
  76         LocationHost loc = cast(_loc);
  77         AnnotationsHost anno = cast(_anno);
  78 
  79         return new ParsedPatternHost(
  80             lhs.makePattern(except.lhs, loc.lhs, anno.lhs),
  81             rhs.makePattern(except.rhs, loc.rhs, anno.rhs));
  82     }
  83 }