C# Class SimpleFramework.Xml.Stream.Indenter

The Indenter is used create indent strings using the stack paradigm. This allows XML documents to be generated by pushing and popping indents onto the stack. This indenter caches all indent strings created so that when the same position on the stack is encountered the indent can be acquired quickly.

The indents created by this are all prefixed with the line feed character, which allows XML tags to span exclusive lines. If the indent size specified is zero or less then no spaces, or line feed will be added to the generated indent string.

Mostrar archivo Open project: ngallagher/simplexml Class Usage Examples

Public Methods

Method Description
Create ( ) : String

This is used to create an indent which can later be pushed on to the stack. If the number of spaces to be added is zero then this will return a single character string with a line feed.

Indent ( int index ) : String

This is used to acquire the indent at the specified index. If the indent does not exist at the specified index then on is created using the current value of the indent. The very first indent taken from this will be an empty string value.

Indenter ( Format format ) : System

Constructor for the Indenter object. This will create an indent that uses the specified number of spaces to create each entry pushed on to the stack. This uses a cache size of sixteen, which should be sufficient for most files.

Pop ( ) : String

This is used to pop an indent from the cache. This reduces the length of the current indent and is typically used when an end tag is added to an XML document. If the number of pop requests exceeds the number of push requests then an empty string is returned from this method.

Push ( ) : String

This is used to push an indent on to the cache. The first indent created by this is an empty string, this is because an indent is not required for the start of an XML file. If there are multiple roots written to the same writer then the start and end tags of a root element will exist on the same line.

Top ( ) : String

This returns the current indent for this indenter. This should be used to write elements or comments that should be at the same indentation level as the XML element that will follow.

Private Methods

Method Description
Indenter ( Format format, int size ) : System

Constructor for the Indenter object. This will create an indent that uses the specified number of spaces to create each entry pushed on to the stack. This uses a cache of the specified size, which is used to optimize the object.

Method Details

Create() public method

This is used to create an indent which can later be pushed on to the stack. If the number of spaces to be added is zero then this will return a single character string with a line feed.
public Create ( ) : String
return String

Indent() public method

This is used to acquire the indent at the specified index. If the indent does not exist at the specified index then on is created using the current value of the indent. The very first indent taken from this will be an empty string value.
public Indent ( int index ) : String
index int /// this is the index to acquire the indent from ///
return String

Indenter() public method

Constructor for the Indenter object. This will create an indent that uses the specified number of spaces to create each entry pushed on to the stack. This uses a cache size of sixteen, which should be sufficient for most files.
public Indenter ( Format format ) : System
format Format /// determines the number of spaces per indent ///
return System

Pop() public method

This is used to pop an indent from the cache. This reduces the length of the current indent and is typically used when an end tag is added to an XML document. If the number of pop requests exceeds the number of push requests then an empty string is returned from this method.
public Pop ( ) : String
return String

Push() public method

This is used to push an indent on to the cache. The first indent created by this is an empty string, this is because an indent is not required for the start of an XML file. If there are multiple roots written to the same writer then the start and end tags of a root element will exist on the same line.
public Push ( ) : String
return String

Top() public method

This returns the current indent for this indenter. This should be used to write elements or comments that should be at the same indentation level as the XML element that will follow.
public Top ( ) : String
return String