View Javadoc
1   /*
2    * Copyright 2007 Werner Guttmann
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11   * or implied. See the License for the specific language governing permissions and limitations under
12   * the License.
13   */
14  package org.exolab.castor.builder.conflict.strategy;
15  
16  import org.exolab.castor.xml.schema.Annotated;
17  import org.exolab.javasource.JClass;
18  
19  /**
20   * Class name conflict resolver.
21   * 
22   * @author <a href="mailto:werner DOT guttmann AT gmx DOT net">Werner Guttmann</a>
23   */
24  public class XPATHClassNameConflictResolver extends BaseClassNameConflictResolver
25      implements ClassNameConflictResolver {
26  
27    /**
28     * Changes the JClass' internal class name, as a result of an XPATH expression uniquely
29     * identifying an XML artefact within an XML schema.
30     * 
31     * @param jClass The {@link JClass} instance whose local name should be changed.
32     * @param xpath XPATH expression used to defer the new local class name
33     * @param typedXPath typed XPATH expression used to defer the new local class name
34     * @param annotated {@link Annotated} instance
35     */
36    public void changeClassInfoAsResultOfConflict(final JClass jClass, final String xpath,
37        final String typedXPath, final Annotated annotated) {
38      // set new classname
39      String newClassName = calculateXPathPrefix(xpath) + jClass.getLocalName();
40      jClass.changeLocalName(newClassName);
41    }
42  
43  
44  }