001: /*
002: Copyright (c) 2006, Dennis M. Sosnoski
003: All rights reserved.
004:
005: Redistribution and use in source and binary forms, with or without modification,
006: are permitted provided that the following conditions are met:
007:
008: * Redistributions of source code must retain the above copyright notice, this
009: list of conditions and the following disclaimer.
010: * Redistributions in binary form must reproduce the above copyright notice,
011: this list of conditions and the following disclaimer in the documentation
012: and/or other materials provided with the distribution.
013: * Neither the name of JiBX nor the names of its contributors may be used
014: to endorse or promote products derived from this software without specific
015: prior written permission.
016:
017: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
018: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
019: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
021: ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: */
028:
029: package org.jibx.typeinfo;
030:
031: import java.util.ArrayList;
032:
033: /**
034: * Holder for package information.
035: *
036: * @author Dennis M. Sosnoski
037: */
038: public class PackageDescription {
039: /** Containing package information. */
040: private final PackageDescription m_containingPackage;
041:
042: /** External form package prefix (including trailing '.', if needed). */
043: private final String m_externalPrefix;
044:
045: /** Internal form package prefix (including trailing '/', if needed). */
046: private final String m_internalPrefix;
047:
048: /** Classes from this package. */
049: private final ArrayList m_classes;
050:
051: /** Child packages of this package. */
052: private final ArrayList m_childPackages;
053:
054: /**
055: * Constructor.
056: *
057: * @param name package simple name (without containing packages)
058: * @param pack containing package (<code>null</code> if this is the default
059: * package)
060: */
061: public PackageDescription(String name, PackageDescription pack) {
062: m_containingPackage = pack;
063: if (pack == null) {
064: m_externalPrefix = m_internalPrefix = "";
065: } else {
066: m_externalPrefix = pack.m_externalPrefix + name + '.';
067: m_internalPrefix = pack.m_internalPrefix + name + '/';
068: }
069: m_classes = new ArrayList();
070: m_childPackages = new ArrayList();
071: }
072:
073: //
074: // Access methods
075:
076: /**
077: * Get containing package.
078: *
079: * @return containing package (<code>null</code> if this is the default
080: * package)
081: */
082: public PackageDescription getContainingPackage() {
083: return m_containingPackage;
084: }
085:
086: /**
087: * Get package name in internal form.
088: *
089: * @return internal name
090: */
091: public String getInternalPrefix() {
092: return m_internalPrefix;
093: }
094:
095: /**
096: * Get package name in external form.
097: *
098: * @return name
099: */
100: public String getExternalPrefix() {
101: return m_externalPrefix;
102: }
103:
104: /**
105: * Get (modifiable) class list.
106: *
107: * @return class list
108: */
109: public ArrayList getClasses() {
110: return m_classes;
111: }
112:
113: /**
114: * Get (modifiable) child package list.
115: *
116: * @return child list
117: */
118: public ArrayList getChildPackages() {
119: return m_childPackages;
120: }
121: }
|