Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
    * JBoss, Home of Professional Open Source
    * Copyright 2005, JBoss Inc., and individual contributors as indicated
    * by the @authors tag. See the copyright.txt in the distribution for a
    * full listing of individual contributors.
    *
    * This is free software; you can redistribute it and/or modify it
    * under the terms of the GNU Lesser General Public License as
    * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
   * This software is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
   * License along with this software; if not, write to the Free
   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
   */
 package org.jboss.xb.binding.sunday.unmarshalling;
 
 import java.util.Map;
 import java.util.Set;
 
 
A SchemaBinding is a collection of binding objects (TypeBinding, ChoiceBinding, ElementBinding, ModelGroupBinding, SequenceBinding, WildcardBinding) for a single namespace keyed by the QNames of the schema components.

Author(s):
Alexey Loubyansky
Version:
$Revision: 2667 $
 
 public class SchemaBinding
 {
    private static final ValueAdapter DATE_ADAPTER = new ValueAdapter()
    {
       public Object cast(Object oClass c)
       {
          if (o != null && java.util.Date.class.isAssignableFrom(c))
          {
             o = ((java.util.Calendaro).getTime();
          }
          return o;
       }
    };
   
   
The namespaces Set<String>
 
    private Set namespaces = .;
   
namespace to prefix map, used in xb builder during binding
 
    private Map<StringStringnsByPrefix = Collections.emptyMap();
   
Map<QName, TypeBinding> for simple/complex types
 
    private Map<QNameTypeBindingtypes = new HashMap<QNameTypeBinding>();
   
Map<QName, ParticleBinding> for
 
    private Map<QNameParticleBindingelements = new HashMap<QNameParticleBinding>();
   
Map<QName, ModelGroupBinding> for
 
    private Map<QNameModelGroupBindinggroups = new HashMap<QNameModelGroupBinding>();
   
The default package information
 
    private PackageMetaData packageMetaData;
   
Schema resolver to use for foreign namespaces
 
    private SchemaBindingResolver schemaResolver;
   
Must all content have a valid binding
 
    private boolean strictSchema = true;
   
Should child elements be ignored if they don't map to a parent field
 
    private boolean ignoreUnresolvedFieldOrClass = true;
   
Should '_' be considered as a word separator or part of Java identifier
 
    private boolean ignoreLowLine = true;
   
Should ${x} references be replaced with x system property
 
    private boolean replacePropertyRefs = true;
   
Should list xml types be unmarshalled as arrays
 
    private boolean unmarshalListsToArrays;
   
Should the default no-arg ctor be used to create the java instance
 
    private boolean useNoArgCtorIfFound;
   
The default property name to use for simple content bindings
 
    private String simpleContentProperty = "value";
   
   
if all the characters in the mixed content are whitespaces should they be considered indentation and ignored? the default is true for the backwards compatibility
 
    private boolean ignoreWhitespacesInMixedContent = true;

   
default XOP unmarshaller
 
    private XOPUnmarshaller xopUnmarshaller;
   
default XOP marshaller
 
    private XOPMarshaller xopMarshaller;
   public SchemaBinding()
   {
   }
   
   public void addPrefixMapping(String prefixString ns)
   {
      if( == .)
      {
          = Collections.singletonMap(prefixns);
      }
      else
      {
         if(.size() == 1)
         {
             = new HashMap<StringString>();
         }
         .put(prefixns);
      }
   }
   
   public String getNamespace(String prefix)
   {
      return .get(prefix);
   }
   
   
Get the namespaces.

Returns:
the namespaces.
   public Set getNamespaces()
   {
      return ;
   }

   
Set the namespaces.

Parameters:
namespaces the namespaces.
Throws:
java.lang.IllegalArgumentException for null spaces
   public void setNamespaces(Set namespaces)
   {
      if (namespaces == null)
         throw new IllegalArgumentException("Null namespaces");
      this. = namespaces;
   }
   public TypeBinding getType(QName qName)
   {
      return .get(qName);
   }
   public void addType(TypeBinding type)
   {
      QName qName = type.getQName();
      if(qName == null)
      {
         throw new JBossXBRuntimeException("Global type must have a name.");
      }
      .put(qNametype);
   }
   public ElementBinding getElement(QName name)
   {
      ParticleBinding particle = .get(name);
      ElementBinding element = (ElementBinding)(particle == null ? null : particle.getTerm());
      return element;
   }
   {
      return .get(name);
   }
   public void addElement(ElementBinding element)
   {
      ParticleBinding particle = new ParticleBinding(element);
      .put(element.getQName(), particle);
   }
   public ElementBinding addElement(QName nameTypeBinding type)
   {
      ElementBinding element = new ElementBinding(thisnametype);
      addElement(element);
      return element;
   }
   public Iterator getElements()
   {
      return new Iterator()
      {
         private Iterator<ParticleBindingparticleIterator = .values().iterator();
         public boolean hasNext()
         {
            return .hasNext();
         }
         public Object next()
         {
            ParticleBinding particle = .next();
            return particle.getTerm();
         }
         public void remove()
         {
            throw new UnsupportedOperationException("remove is not implemented.");
         }
      };
   }
   {
      return .values().iterator();
   }
   public Iterator<TypeBindinggetTypes()
   {
      return Collections.unmodifiableCollection(.values()).iterator();
   }
   public ModelGroupBinding getGroup(QName name)
   {
      return .get(name);
   }
   public void addGroup(QName nameModelGroupBinding group)
   {
      .put(namegroup);
   }
   {
      return .values().iterator();
   }
   {
      return ;
   }
   public void setPackageMetaData(PackageMetaData packageMetaData)
   {
      this. = packageMetaData;
   }
   {
      return ;
   }
   public void setSchemaResolver(SchemaBindingResolver schemaResolver)
   {
      this. = schemaResolver;
   }
   public boolean isStrictSchema()
   {
      return ;
   }

   
If strict-schema is true then all the elements and attributes in XML content being parsed must be bound in this instance of SchemaBinding (except attributes from xmlns and xsi namespaces), otherwise a runtime exception is thrown. The default value for this property is true.
   public void setStrictSchema(boolean strictSchema)
   {
      this. = strictSchema;
   }
   public boolean isIgnoreUnresolvedFieldOrClass()
   {
      return ;
   }

   
If a field is not found in the parent class to set child value on or a class an element is bound to an exception will be thrown if this property is false. Otherwise, the process will just go on (the default for now).
   public void setIgnoreUnresolvedFieldOrClass(boolean ignoreUnresolvedFieldOrClass)
   {
      this. = ignoreUnresolvedFieldOrClass;
   }
   public boolean isReplacePropertyRefs()
   {
      return ;
   }
   

Parameters:
flag
   public void setReplacePropertyRefs(boolean flag)
   {
      this. = flag;
   }
   public boolean isIgnoreLowLine()
   {
      return ;
   }

   
Where '_' should be considered as a word separator or a part of the Java identifier when mapping XML names to Java identifiers.
   public void setIgnoreLowLine(boolean ignoreLowLine)
   {
      this. = ignoreLowLine;
   }
   public boolean isUnmarshalListsToArrays()
   {
      return ;
   }

   
Should list xml types be unmarshalled as arrays

Parameters:
unmarshalListsToArrays
   public void setUnmarshalListsToArrays(boolean unmarshalListsToArrays)
   {
      this. = unmarshalListsToArrays;
   }
   public boolean isUseNoArgCtorIfFound()
   {
      return ;
   }

   
Should the default no-arg ctor be used to create the java instance

Parameters:
useNoArgCtorIfFound
   public void setUseNoArgCtorIfFound(boolean useNoArgCtorIfFound)
   {
      this. = useNoArgCtorIfFound;
   }
   {
      return ;
   }

   
Set the default property name to use for simple content bindings

Parameters:
simpleContentProperty
   public void setSimpleContentProperty(String simpleContentProperty)
   {
      this. = simpleContentProperty;
   }

   

Returns:
schema default XOP unmarshaller
   {
      return ;
   }

   

Parameters:
xopUnmarshaller schema default XOP unmarshaller
   public void setXopUnmarshaller(XOPUnmarshaller xopUnmarshaller)
   {
      this. = xopUnmarshaller;
   }

   

Returns:
schema default XOP marshaller
   {
      return ;
   }

   

Parameters:
xopMarshaller schema default XOP marshaller
   public void setXopMarshaller(XOPMarshaller xopMarshaller)
   {
      this. = xopMarshaller;
   }
   public void setUnresolvedContentBoundToDOM(boolean toDom)
   {
      if(type == null)
      {
         // ignore, there is no use of the anyType in the schema
         return;
         //throw new JBossXBRuntimeException("anyType is not bound.");
      }
      WildcardBinding wildcard = type.getWildcard();
      if(toDom)
      {
      }
      else
      {
         wildcard.setUnresolvedCharactersHandler(null);
         wildcard.setUnresolvedElementHandler(null);
         wildcard.setUnresolvedMarshaller(null);
      }
   }
   
   public boolean isUnresolvedContentBoundToDOM()
   {
      if(type == null)
      {
         // there is no use of the anyType in the schema
         return false;
         //throw new JBossXBRuntimeException("anyType is not bound.");
      }
      WildcardBinding wildcard = type.getWildcard();
      return wildcard.getUnresolvedCharactersHandler() instanceof DomCharactersHandler
      && wildcard.getUnresolvedElementHandler() instanceof DomParticleHandler
      && wildcard.getUnresolvedMarshaller() instanceof DomLocalMarshaller;
   }
   
   public boolean isIgnoreWhitespacesInMixedContent()
   {
   }
   
   public void setIgnoreWhitespacesInMixedContent(boolean value)
   {
      this. = value;
   }
   
   void addElementParticle(ParticleBinding particle)
   {
      ElementBinding element = (ElementBinding)particle.getTerm();
      .put(element.getQName(), particle);
   }
New to GrepCode? Check out our FAQ X