net.sourceforge.nrl.parser.model
Class AbstractPackage

java.lang.Object
  extended by net.sourceforge.nrl.parser.model.AbstractModelElement
      extended by net.sourceforge.nrl.parser.model.AbstractPackage
All Implemented Interfaces:
IModelElement, IPackage
Direct Known Subclasses:
UML2Package, XSDPackage

public abstract class AbstractPackage
extends AbstractModelElement
implements IPackage

Abstract implementation of a package. Provides basic content management.


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.sourceforge.nrl.parser.model.IModelElement
IModelElement.ElementType
 
Constructor Summary
AbstractPackage(String name, IPackage container)
          Create a new package with a name and an optional containing package (can be null)
 
Method Summary
 void addElement(IModelElement element)
           
 List<IModelElement> getContents(boolean deep)
          Return the contents of this package, a collection of IModelElement objects.
 IModelElement getElementByName(String name, boolean deep)
          Scan a package and return the model element with a given name.
 IModelElement.ElementType getElementType()
          Return an enum indicating what type of element this is, to reduce the need to sub-cast prematurely.
 int getSize()
          Return the number of elements and packages in the package
 boolean isAmbiguous(String name)
          Returns true if a model element name occurs in multiple sub-packages, and hence a global reference to the name would be ambiguous.
 void removeElement(IModelElement element)
           
 
Methods inherited from class net.sourceforge.nrl.parser.model.AbstractModelElement
addChild, getContainingPackage, getDescendants, getName, getOriginalName, getParent, getQualifiedName, getUserData, isAssignableFrom, isSupplementary, setName, setOriginalName, setParent, setSupplementary, setUserData
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sourceforge.nrl.parser.model.IModelElement
getContainingPackage, getDescendants, getDocumentation, getName, getOriginalName, getParent, getQualifiedName, getUserData, isAssignableFrom, isSupplementary, setUserData
 

Constructor Detail

AbstractPackage

public AbstractPackage(String name,
                       IPackage container)
Create a new package with a name and an optional containing package (can be null)

Parameters:
name - the name
container - the containing package
Method Detail

addElement

public void addElement(IModelElement element)

getContents

public List<IModelElement> getContents(boolean deep)
Description copied from interface: IPackage
Return the contents of this package, a collection of IModelElement objects. Can optionally return all contents recursively, including the contents of subpackages.

Specified by:
getContents in interface IPackage
Parameters:
deep - if true, return the contents of subpackages
Returns:
the contents, a list of IModelElement objects

getElementByName

public IModelElement getElementByName(String name,
                                      boolean deep)
Description copied from interface: IPackage
Scan a package and return the model element with a given name. Optionally, also scans all subpackages.

Note: This returns the first element matching the name if a deep search is used. Use IPackage.isAmbiguous(String) to determine if multiple elements with the name exist - and if so, look them up in the right package instead.

Specified by:
getElementByName in interface IPackage
Parameters:
name - the name to look for
deep - scan subpackages if true
Returns:
the element or null if not found

getElementType

public IModelElement.ElementType getElementType()
Description copied from interface: IModelElement
Return an enum indicating what type of element this is, to reduce the need to sub-cast prematurely.

Specified by:
getElementType in interface IModelElement
Returns:
the element type

getSize

public int getSize()
Description copied from interface: IPackage
Return the number of elements and packages in the package

Specified by:
getSize in interface IPackage
Returns:
the number of elements and packages

isAmbiguous

public boolean isAmbiguous(String name)
Description copied from interface: IPackage
Returns true if a model element name occurs in multiple sub-packages, and hence a global reference to the name would be ambiguous.

Specified by:
isAmbiguous in interface IPackage
Parameters:
name - the element name
Returns:
true if multiple elements with this name exist in the package or subpackages

removeElement

public void removeElement(IModelElement element)


Copyright © 2006-2010 Christian Nentwich and others