Interface PuzzleComponent
- All Known Implementing Classes:
PuzzlePiece
,PuzzlePieceSet
- Element PuzzlePiece
- Attribute PuzzlePiece
- Attribute Value PuzzlePiece
- Attribute Datatype PuzzlePiece
The second purpose of this interface is to hide the differences between one definition and a Collection of definitions. By this you will be able to use single definitions and collections of definitions as method parameters. The method getCollection() is a helper method for this.
By using this interface you declare that:
- you don't care if a PuzzleComponent is a Collection of Jigsaw pieces or one single Jigsaw piece.
- you expect one single name. If the PuzzleComponent is a Collection of definitions, all definitions have to be equally named. Calling getQName(), toString(), getLocalName() or getNamespace() on a Collection of differently named definitions will throw a RuntimeException. For example: A multiple definition of an attribute is frequently used in an XML schema.
Contract: Every object implementing hasQName should overwrite the toString() method and return the QName.
Warning: Using this interface does not imply any information about the equals() or hashCode() methods. So for using objects with qualified names in a Collection, you need information from the implementing class.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines whether this PuzzleComponent allows a text node as child.ELEMENT PuzzlePiece only: Get all attribute DefinitionsELEMENT PuzzlePiece only: Get all child element DefinitionsMethod to treat NamedDefined as a Collection of PuzzlePieceATTRIBUTE PuzzlePiece only: Get all datatype DefinitionsGet only localnameGet only namespace prefix of the qualified nameGet all parent DefinitionsgetQName()
Get the QName (i.e.getType()
Get type of PuzzlePiece [ELEMENT, ATTRIBUTE, VALUE, DATA]ATTRIBUTE PuzzlePiece only: Get all value Definitionsboolean
isMandatory
(PuzzleComponent child) ELEMENT Definition only: Determine solely by child type and name whether child is mandatory.boolean
isSingleton
(PuzzleComponent child) Determines whether the child PuzzlePiece(s) is/are singleton(s)
-
Method Details
-
getChildElements
PuzzlePieceSet getChildElements()ELEMENT PuzzlePiece only: Get all child element Definitions- Returns:
- The child Definitions of this PuzzleComponent
-
getAttributes
PuzzlePieceSet getAttributes()ELEMENT PuzzlePiece only: Get all attribute Definitions- Returns:
- The attribute Definitions of this PuzzleComponent
-
getDatatypes
PuzzlePieceSet getDatatypes()ATTRIBUTE PuzzlePiece only: Get all datatype Definitions- Returns:
- The datatype Definitions of this PuzzleComponent
-
getValues
PuzzlePieceSet getValues()ATTRIBUTE PuzzlePiece only: Get all value Definitions- Returns:
- The constant value Definitions of this PuzzleComponent
-
getParents
PuzzlePieceSet getParents()Get all parent Definitions- Returns:
- The parent Definitions of this PuzzleComponent
-
getType
MSVExpressionType getType()Get type of PuzzlePiece [ELEMENT, ATTRIBUTE, VALUE, DATA]- Returns:
- The type of this PuzzleComponent
-
canHaveText
boolean canHaveText()Determines whether this PuzzleComponent allows a text node as child.- Returns:
- True if a text node is allowed, false otherwise
-
isSingleton
Determines whether the child PuzzlePiece(s) is/are singleton(s)Convention: If child is a collection this method returns false if one child element is no singleton. If this is a collection this method returns false if child is no singleton for one element of this.
- Parameters:
child
- PuzzleComponent child- Returns:
- True if child is defined as Singleton, falso otherwise.
-
isMandatory
ELEMENT Definition only: Determine solely by child type and name whether child is mandatory.Here's why we're not using the child Definition object(s) for this: An element often has a mandatory attribute, but two (or more) different content definitions for this attribute. This is done by defining this attribute twice and creating a CHOICE between both Definitions. If you'd ask whether one of these definitions is mandatory, you'd always get false as answer as you have the choice between the two definitions. Mostly this is not the answer you're looking for.
Contract: If 'this' is a Collection, mandatory means mandatory for one member of 'this'.
- Parameters:
child
- The child Definition(s) of type ELEMENT or ATTRIBUTE- Returns:
- true if child is a defined child of this and if it's mandatory. False otherwise.
-
getCollection
Collection<PuzzlePiece> getCollection()Method to treat NamedDefined as a Collection of PuzzlePiece- Returns:
- Collection of PuzzlePiece objects
-
getQName
String getQName()Get the QName (i.e. namespace:localname ) or without namespace just the local name as fallback- Returns:
- full name
-
getNamespacePrefix
String getNamespacePrefix()Get only namespace prefix of the qualified name- Returns:
- namespacePrefix
-
getLocalName
String getLocalName()Get only localname- Returns:
- localname
-