prettyxml
1.2.0

dk.hippogrif.prettyxml
Class PrettyPrint

java.lang.Object
  extended bydk.hippogrif.prettyxml.PrettyPrint
All Implemented Interfaces:
PropertyNames

public class PrettyPrint
extends java.lang.Object
implements PropertyNames

Prettyprints XML based on JDOM 1.0 according to a set of properties specifying format and options. See dk.hippogrif.prettyxml.

Author:
Jesper Goertz

Field Summary
 
Fields inherited from interface dk.hippogrif.prettyxml.PropertyNames
BASIC_KEYS, ENCODING, EXPAND_EMPTY_ELEMENTS, EXTENDED_KEYS, INDENT, INDENT_ATTRIBUTES, INPUT, LINE_SEPARATOR, LINE_SEPARATORS, OMIT_DECLARATION, OMIT_ENCODING, OUTPUT, SORT_ATTRIBUTES, TEXT_MODE, TEXT_MODES, TRANSFORM, URL
 
Constructor Summary
PrettyPrint()
           
 
Method Summary
static void checkProperties(java.util.Properties prop, boolean extended)
          Checks known properties - present boolean properties are set to either "true" or "false", indent=0 is removed, string properties are trimmed and empty properties removed - however, TEXT_MODE is checked when format is initialized and ENCODING when used.
static void execute(java.util.Properties prop)
          Do the prettyprint according to properties.
static java.lang.String execute(java.util.Properties prop, java.lang.String input)
          Do the prettyprint according to properties.
static java.util.Properties getDefaultSetting()
          Get default properties setting - the first in configured settings.
static java.lang.String[] getEncodings()
          Get wellknown encodings.
static java.util.Properties getSetting(java.lang.String name)
          Get wellknown properties setting.
static java.lang.String[] getSettings()
          Get names of wellknown properties settings.
static XSLTransformer getTransformation(java.lang.String name)
          Get wellknown transformation.
static java.lang.String[] getTransformations()
          Get names of wellknown transformations.
static java.lang.String getVersion()
          Get prettyxml version.
static java.util.Properties loadProperties(java.io.File file)
          Load properties from file.
static java.util.Properties loadProperties(java.lang.String name)
          Load properties from file or as resource in classpath if file not found.
static java.util.Properties loadPropertiesResource(java.lang.String name)
          Load properties as resource in classpath.
static XSLTransformer mkTransformer(java.lang.String name)
          Construct an XSL transformer.
static void storeProperties(java.io.File file, java.util.Properties prop)
          Store properties in file with version in header.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PrettyPrint

public PrettyPrint()
Method Detail

getVersion

public static java.lang.String getVersion()
Get prettyxml version.


getEncodings

public static java.lang.String[] getEncodings()
Get wellknown encodings.


getSettings

public static java.lang.String[] getSettings()
Get names of wellknown properties settings.


getSetting

public static java.util.Properties getSetting(java.lang.String name)
Get wellknown properties setting.


getDefaultSetting

public static java.util.Properties getDefaultSetting()
Get default properties setting - the first in configured settings.


getTransformations

public static java.lang.String[] getTransformations()
Get names of wellknown transformations.


getTransformation

public static XSLTransformer getTransformation(java.lang.String name)
Get wellknown transformation.


checkProperties

public static void checkProperties(java.util.Properties prop,
                                   boolean extended)
                            throws java.lang.Exception
Checks known properties - present boolean properties are set to either "true" or "false", indent=0 is removed, string properties are trimmed and empty properties removed - however, TEXT_MODE is checked when format is initialized and ENCODING when used.

Parameters:
prop - holds the properties
extended - to include in/out properties
Throws:
java.lang.Exception - if property error

loadProperties

public static java.util.Properties loadProperties(java.lang.String name)
                                           throws java.lang.Exception
Load properties from file or as resource in classpath if file not found.

Parameters:
name - of properties file or resource
Throws:
java.io.IOException - if io error on reading file
java.lang.Exception - if resource not found

loadPropertiesResource

public static java.util.Properties loadPropertiesResource(java.lang.String name)
                                                   throws java.lang.Exception
Load properties as resource in classpath.

Parameters:
name - of resource holding properties
Throws:
java.lang.Exception - if resource not found

loadProperties

public static java.util.Properties loadProperties(java.io.File file)
                                           throws java.io.IOException
Load properties from file.

Parameters:
file - holding properties
Throws:
java.io.IOException - on io error

storeProperties

public static void storeProperties(java.io.File file,
                                   java.util.Properties prop)
                            throws java.io.IOException
Store properties in file with version in header.

Parameters:
file - to store the properties in
prop - the properties to store
Throws:
java.io.IOException - on io error

mkTransformer

public static XSLTransformer mkTransformer(java.lang.String name)
                                    throws java.lang.Exception
Construct an XSL transformer.

Parameters:
name - of stylesheet file or resource
Throws:
java.lang.Exception - if stylesheet not found

execute

public static void execute(java.util.Properties prop)
                    throws java.lang.Exception
Do the prettyprint according to properties.

Throws:
java.lang.Exception - if something goes wrong

execute

public static java.lang.String execute(java.util.Properties prop,
                                       java.lang.String input)
                                throws java.lang.Exception
Do the prettyprint according to properties.

Parameters:
input - holds xml document as text if present
Returns:
prettyprinted document as text if input param present
Throws:
java.lang.Exception - if something goes wrong

prettyxml
1.2.0

Copyright © 2005 Jesper Goertz. All Rights Reserved.