com.japisoft.xmlpad.action.xml
Class FormatAction

java.lang.Object
  extended byjavax.swing.AbstractAction
      extended bycom.japisoft.xmlpad.action.XMLAction
          extended bycom.japisoft.xmlpad.action.xml.FormatAction
All Implemented Interfaces:
javax.swing.Action, java.awt.event.ActionListener, java.lang.Cloneable, java.util.EventListener, Features, Properties, java.io.Serializable

public class FormatAction
extends XMLAction

Action for formatting the XML content. If you don't want to have sorted attributes, you must override the sortAttributes method.

By default indentSize is equals to 4, but you can override it by calling ActionModel.setProperty( Properties.INDENT_SIZE_PROPERTY, new Integer( 2 ) The same thing for the indent char calling ActionModel.setProperty( Properties.INDENT_CHAR_PROPERTY, '\'' )

Version:
1.2
Author:
(c) 2002 - 2003 JAPISOFT
See Also:
XMLAction, Serialized Form

Nested Class Summary
 
Nested classes inherited from class com.japisoft.xmlpad.action.XMLAction
XMLAction.EmptyIcon
 
Field Summary
static boolean CANONICAL
           
static boolean DIALOG_ERROR
          Mode for having a popup dialog when the formatting is impossible
static java.lang.String ID
           
protected  java.io.PrintWriter out
           
static java.lang.String PREF_APOSENTITY
          Particular property inside the XMLContainer
static boolean PRESERVE_EMPTY_ATTRIBUTE_VALUE
          Preserve whitespaces string for attribute value
 
Fields inherited from class com.japisoft.xmlpad.action.XMLAction
AUTO_UI, container, editor, groupName, IMAGE_EXT, IMAGE_SIZE, INVALID_ACTION, param, RESOURCE_BUNDLE, VALID_ACTION
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface com.japisoft.xmlpad.action.Features
VALIDATING_FEATURE
 
Fields inherited from interface com.japisoft.xmlpad.action.Properties
FILE_ENCODING, INDENT_CHAR_PROPERTY, INDENT_SIZE_PROPERTY
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
FormatAction()
           
 
Method Summary
 java.lang.String getMessageForError(XMLContainer container)
           
 java.lang.Object getProperty(java.lang.String propertyName, java.lang.Object defaultValue)
           
static java.lang.String getWriterEncoding()
           
 boolean isReplaceAmp()
           
 boolean isReplaceAPos()
           
 boolean isReplaceGt()
           
 boolean isReplaceLt()
           
 boolean isReplaceQuote()
           
protected  java.lang.String normalize(java.lang.String s, boolean keepWhiteSpace)
          Normalizes the given string.
 boolean notifyAction()
          Notify action must be done.
 void print(int indent, org.w3c.dom.Node node)
          Prints the specified node, recursively.
 void print(org.w3c.dom.Node node)
           
 void setProperty(java.lang.String propertyName, java.lang.Object value)
          Support for INDENT_CHAR_PROPERTY, INDENT_SIZE_PROPERTY properties
 void setReplaceAmp(boolean replaceAmp)
          Resolve the amp character as entity.
 void setReplaceAPos(boolean replaceAPos)
          Resolve the ' character as entity.
 void setReplaceGt(boolean replaceGt)
          Resolved the gt character is resolved as entity.
 void setReplaceLt(boolean replaceLt)
          Resolved the lt character as entity.
 void setReplaceQuote(boolean replaceQuote)
          Resolved the " character as entity.
protected  org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs)
          Returns a sorted list of attributes.
 
Methods inherited from class com.japisoft.xmlpad.action.XMLAction
actionPerformed, autoRequestFocus, dispose, getDefaultAccelerator, getDefaultIcon, getDefaultLabel, getDefaultMnemonic, getDefaultTooltip, getLabel, getName, getParam, getPopupGroup, getXMLContainer, getXMLEditor, hasFeature, installUIContent, isPopable, isToolbarable, notifyXMLContainer, notifyXMLEditor, setActionDelegate, setActionReferenceGroup, setActionReferenceIcon, setFeature, setParam, setPopable, setToolbarable, setXMLContainer, setXMLEditor
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PREF_APOSENTITY

public static final java.lang.String PREF_APOSENTITY
Particular property inside the XMLContainer

See Also:
Constant Field Values

ID

public static final java.lang.String ID

CANONICAL

public static boolean CANONICAL

DIALOG_ERROR

public static boolean DIALOG_ERROR
Mode for having a popup dialog when the formatting is impossible


PRESERVE_EMPTY_ATTRIBUTE_VALUE

public static boolean PRESERVE_EMPTY_ATTRIBUTE_VALUE
Preserve whitespaces string for attribute value


out

protected java.io.PrintWriter out
Constructor Detail

FormatAction

public FormatAction()
Method Detail

setProperty

public void setProperty(java.lang.String propertyName,
                        java.lang.Object value)
Support for INDENT_CHAR_PROPERTY, INDENT_SIZE_PROPERTY properties

Overrides:
setProperty in class XMLAction
Parameters:
propertyName - Property name
value - Property value

getProperty

public java.lang.Object getProperty(java.lang.String propertyName,
                                    java.lang.Object defaultValue)
Overrides:
getProperty in class XMLAction
Returns:
a property value for this action. If the current XMLAction has not overrided it a null value will be returned

notifyAction

public boolean notifyAction()
Description copied from class: XMLAction
Notify action must be done. It returns INVALID_ACTION if the action is not accessible and VALID_ACTION if this is correct.

Specified by:
notifyAction in class XMLAction
Returns:
VALID_ACTION if the action is possible and else INVALID_ACTION

getMessageForError

public java.lang.String getMessageForError(XMLContainer container)

getWriterEncoding

public static java.lang.String getWriterEncoding()

print

public void print(org.w3c.dom.Node node)

print

public void print(int indent,
                  org.w3c.dom.Node node)
Prints the specified node, recursively.


isReplaceAmp

public boolean isReplaceAmp()
Returns:
true if the amp character is resolved as entity

setReplaceAmp

public void setReplaceAmp(boolean replaceAmp)
Resolve the amp character as entity. By default true


isReplaceAPos

public boolean isReplaceAPos()
Returns:
true if the ' character is resolved as entity

setReplaceAPos

public void setReplaceAPos(boolean replaceAPos)
Resolve the ' character as entity. By default true


isReplaceGt

public boolean isReplaceGt()
Returns:
true if the gt character is resolved as entity

setReplaceGt

public void setReplaceGt(boolean replaceGt)
Resolved the gt character is resolved as entity. By default true


isReplaceLt

public boolean isReplaceLt()
Returns:
true if the lt character is resolved as entity

setReplaceLt

public void setReplaceLt(boolean replaceLt)
Resolved the lt character as entity. By default true


isReplaceQuote

public boolean isReplaceQuote()
Returns:
true if the " character is resolved as entity

setReplaceQuote

public void setReplaceQuote(boolean replaceQuote)
Resolved the " character as entity. By default true


normalize

protected java.lang.String normalize(java.lang.String s,
                                     boolean keepWhiteSpace)
Normalizes the given string.


sortAttributes

protected org.w3c.dom.Attr[] sortAttributes(org.w3c.dom.NamedNodeMap attrs)
Returns a sorted list of attributes.



Copyright © 2006 JAPISoft. All Rights Reserved.