kirk.io.sdl
Class SDLElement

java.lang.Object
  extended bykirk.io.sdl.SDLElement
Direct Known Subclasses:
SDLDataElement, SDLNormalElement

public abstract class SDLElement
extends Object

This class represents an SDL element. It has a name, and a value. What this value actually is, is decided by the subclasses. SDL has 2 types of elements, the normal element, and the data element. These are represented by 2 subclasses.

Version:
1
Author:
Berend "Kirk" Wouda

Field Summary
protected  String name
          The name of this element.
 
Constructor Summary
SDLElement(String name)
          Constructs a new SDLElement with the given name.
 
Method Summary
 SDLDataElement getAsDataElement()
          Convenience method for casting this element to the data type.
 SDLNormalElement getAsNormalElement()
          Convenience method for casting this element to the normal type.
 String getName()
          Returns the name of this element.
 void setName(String name)
          Sets the name of this element to name.
abstract  String toString(String indent)
          Returns a string representation of this SDLElement with the given indentation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
The name of this element.

Constructor Detail

SDLElement

public SDLElement(String name)
Constructs a new SDLElement with the given name.

Parameters:
name - The name of the element.
Method Detail

getName

public String getName()
Returns the name of this element.

Returns:
The name of this element.

setName

public void setName(String name)
Sets the name of this element to name.

Parameters:
name - The name this element should have.

getAsNormalElement

public SDLNormalElement getAsNormalElement()
Convenience method for casting this element to the normal type. This method is aimed at reducing clutter in code that needs a cast. It also allows easier chained statements. Casting is something that happens a lot when retrieving data from the SDL structure, since you need to know/have the subtype of the element.


getAsDataElement

public SDLDataElement getAsDataElement()
Convenience method for casting this element to the data type. This method is aimed at reducing clutter in code that needs a cast. It also allows easier chained statements. Casting is something that happens a lot when retrieving data from the SDL structure, since you need to know/have the subtype of the element.


toString

public abstract String toString(String indent)
Returns a string representation of this SDLElement with the given indentation.

Parameters:
indent - The indentation to be used.
Returns:
A string representation of this SDLElement.