Package org.eigenbase.xom
Class DefWalker
java.lang.Object
org.eigenbase.xom.DefWalker
DefWalker is a class designed to help users of plugin elements and elements
with content type ANY. It walks through an array of ElementDef, searching
for and returning portions as the correct types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the next node in the defs array, but only if it matches the provided class elemType.NodeDef[]
expectArray
(Class elemType) Returns a portion of the remaining nodes in the defs array as an array.expectTypeArray
(Class elemType) Returns a portion of the remaining nodes in the defs array as an array.
-
Constructor Details
-
DefWalker
Construct a DefWalker, attaching it to a NodeDef array and specifying a PrintWriter to display error messages for later consumption.- Parameters:
defs
- a NodeDef array to walk. All returned objects come from this array.
-
-
Method Details
-
expect
Returns the next node in the defs array, but only if it matches the provided class elemType.- Parameters:
elemType
- the Class of NodeDef to expect. This class will always be assignable from the returned object.- Throws:
XOMException
- if there are no more nodes in the defs array or if the next node is of an incorrect type.
-
expectArray
Returns a portion of the remaining nodes in the defs array as an array. All nodes in the array will be of the specified class elemType. The nodes are returned as a generic NodeDef[] array and may need to be explicitly converted to an array of the appropriate type by the caller.- Parameters:
elemType
- the Class of NodeDef to expect and return. This class will always be assignable from each returned object in the array.
-
expectTypeArray
Returns a portion of the remaining nodes in the defs array as an array. All nodes in the array will be of the specified class elemType. The nodes are in an array of the specified type, which will be returned as an object (which must be cast to the appropriate array type by the caller when needed.- Parameters:
elemType
- the Class of NodeDef to expect and return. This class will always be assignable from each returned object in the array.
-