Package org.eigenbase.xom

# Class DefWalker

java.lang.Object
org.eigenbase.xom.DefWalker

public class DefWalker extends Object
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
Constructor
Description
`DefWalker(NodeDef[] defs)`
Construct a DefWalker, attaching it to a NodeDef array and specifying a PrintWriter to display error messages for later consumption.

## Method Summary

Modifier and Type
Method
Description
`NodeDef`
`expect(Class elemType)`
Returns 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.
`Object`
`expectTypeArray(Class elemType)`
Returns a portion of the remaining nodes in the defs array as an array.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### DefWalker

public DefWalker(NodeDef[] defs)
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

public NodeDef expect(Class elemType) throws XOMException
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

public NodeDef[] expectArray(Class elemType)
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

public Object expectTypeArray(Class elemType)
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.