BEA Systems, Inc.

com.beasys.commerce.util.dom
Class EntityFixer

java.lang.Object
  |
  +--com.beasys.commerce.util.dom.EntityFixer

public class EntityFixer
extends java.lang.Object

A utility class for replacing standard XML entities with their character values.


Field Summary
protected static java.lang.String[][] defReplaceEntities
          Default XML/HTML entities that represent special character sequences.
protected  java.util.Hashtable entities
          Our character to entity mapping.
protected static EntityFixer instance
          The singleton EntityFixer.
 
Constructor Summary
EntityFixer()
          Constructor.
 
Method Summary
 java.lang.String addEntityMapping(java.lang.String chars, java.lang.String value)
          Add a characters to value mapping (i.e.
 java.lang.String fixEntities(java.lang.String in)
           
 java.lang.String getEntityMapping(java.lang.String chars)
          Retrive the a current entity mapping.
static EntityFixer getInstance()
          Get the singleton instance.
 java.lang.String removeEntityMapping(java.lang.String chars)
          Remove an entity mapping.
static java.lang.String replace(java.lang.String inStr, java.lang.String find, java.lang.String replace)
          String search and replace method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instance

protected static EntityFixer instance
The singleton EntityFixer.

defReplaceEntities

protected static final java.lang.String[][] defReplaceEntities
Default XML/HTML entities that represent special character sequences.

entities

protected java.util.Hashtable entities
Our character to entity mapping.
Constructor Detail

EntityFixer

public EntityFixer()
Constructor.

This will initialize the entity mapping with the default values.

Method Detail

addEntityMapping

public java.lang.String addEntityMapping(java.lang.String chars,
                                         java.lang.String value)
Add a characters to value mapping (i.e. "%" -> "&pect;")
Parameters:
chars - the characters ("%").
value - the string to replace chars with ("&pect;").
Returns:
the previous value, or null if none.
Throws:
java.lang.IllegalArgumentException - thrown if chars is "&".

removeEntityMapping

public java.lang.String removeEntityMapping(java.lang.String chars)
Remove an entity mapping.

getEntityMapping

public java.lang.String getEntityMapping(java.lang.String chars)
Retrive the a current entity mapping.

fixEntities

public java.lang.String fixEntities(java.lang.String in)

replace

public static java.lang.String replace(java.lang.String inStr,
                                       java.lang.String find,
                                       java.lang.String replace)
String search and replace method.

getInstance

public static EntityFixer getInstance()
Get the singleton instance.

BEA Systems, Inc.

Copyright © 2000 BEA Systems, Inc. All Rights Reserved