net.percederberg.grammatica.code
Class CodeElementContainer

java.lang.Object
  |
  +--net.percederberg.grammatica.code.CodeElement
        |
        +--net.percederberg.grammatica.code.CodeElementContainer
All Implemented Interfaces:
java.lang.Comparable
Direct Known Subclasses:
CSharpFile, CSharpNamespace, net.percederberg.grammatica.code.csharp.CSharpType, JavaFile, net.percederberg.grammatica.code.java.JavaType

public abstract class CodeElementContainer
extends CodeElement

The abstract base class for all code element containers. The code element containers contains other code elements.

Version:
1.0
Author:
Per Cederberg,

Constructor Summary
CodeElementContainer()
           
 
Method Summary
protected  void addElement(CodeElement elem)
          Adds a code element to this container.
protected  void printContents(java.io.PrintWriter out, CodeStyle style, int indent)
          Prints all the contained code elements to the specified output stream.
protected  void printSeparator(java.io.PrintWriter out, CodeStyle style, CodeElement prev, CodeElement next)
          Prints the lines separating two elements.
 
Methods inherited from class net.percederberg.grammatica.code.CodeElement
category, compareTo, print
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeElementContainer

public CodeElementContainer()
Method Detail

addElement

protected void addElement(CodeElement elem)
Adds a code element to this container.

Parameters:
elem - the code element to add

printContents

protected void printContents(java.io.PrintWriter out,
                             CodeStyle style,
                             int indent)
Prints all the contained code elements to the specified output stream. The code elements will be sorted by their category number before printing.

Parameters:
out - the output stream
style - the code style to use
indent - the indentation level

printSeparator

protected void printSeparator(java.io.PrintWriter out,
                              CodeStyle style,
                              CodeElement prev,
                              CodeElement next)
Prints the lines separating two elements. By default this method prints a newline before the first element, and between elements with different category numbers.

Parameters:
out - the output stream
style - the code style to use
prev - the previous element, or null if first
next - the next element, or null if last