Package org.jibx.util
Class HolderBase
java.lang.Object
org.jibx.util.HolderBase
- Direct Known Subclasses:
SchemaHolder
Base class for external data used in constructing a namespaced file which may reference other files of the same type.
This class tracks both the referenced files and the corresponding namespace references, assigning prefixes for the
latter as appropriate. The namespace associated with this file is always given the prefix 'tns', while those used for
other files get prefixes of the form 'ns1', 'ns2', etc.
- Author:
- Dennis M. Sosnoski
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionHolderBase(String uri) Constructor for a file being generated.HolderBase(String uri, String name) Constructor for an existing file. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddNamespaceDecl(String prefix, String uri) Subclass hook method to handle adding a namespace declaration.voidaddReference(HolderBase ref) Record a reference from this file to another file of the same type.voidfinish()Implementation method for subclasses to complete the construction of the file.Get the file name to be used for this file.Get namespace URI associated with this file.Get the prefix for a namespace URI.Get the set of references from this file to other files of the same type.booleanCheck if file already exists.booleanCheck if file is modifiable.voidsetFileName(String name) Set the file name to be used for this file.
-
Field Details
-
m_namespace
-
m_nsPrefixMap
-
m_finished
private boolean m_finished -
m_existingFile
private boolean m_existingFile -
m_fileName
-
m_referenceSet
-
-
Constructor Details
-
HolderBase
Constructor for a file being generated.- Parameters:
uri- (nullif no-namespace binding)
-
HolderBase
Constructor for an existing file.- Parameters:
uri- (nullif no-namespace binding)name- file name
-
-
Method Details
-
isExistingFile
public boolean isExistingFile()Check if file already exists.- Returns:
trueif existing file,falseif not
-
isModifiable
public boolean isModifiable()Check if file is modifiable. This will always befalsefor an existing file, and will be setfalsefor new files whenfinish()is called.- Returns:
trueif file is modifiable,falseif not
-
getPrefix
Get the prefix for a namespace URI. The first time this is called for a particular namespace URI a prefix is assigned and returned. This assumes that the default namespace is always the no-namespace.- Parameters:
uri-- Returns:
- prefix
-
addNamespaceDecl
Subclass hook method to handle adding a namespace declaration. The implementation of this method needs to set up the namespace declaration for output in the generated XML.- Parameters:
prefix-uri-
-
getNamespace
Get namespace URI associated with this file.- Returns:
- namespace (
nullif no-namespace)
-
getFileName
Get the file name to be used for this file.- Returns:
- name (
nullif not set)
-
setFileName
Set the file name to be used for this file.- Parameters:
name-
-
addReference
Record a reference from this file to another file of the same type. This adds the reference to the set of references. Self-references are ignored.- Parameters:
ref-
-
getReferences
Get the set of references from this file to other files of the same type.- Returns:
- references
-
finish
public void finish()Implementation method for subclasses to complete the construction of the file. This includes processing references to other files, as well as any other components of the file which need to be finalized. This method must be called after all references have been added, allowing the subclass to add any necessary structures to the file representation. Subclasses must call the base class implementation when their processing is completed.
-