SimpleServlets v5.5.0

com.simpleservlets.htmlobjects
Class HTMLAttribute

java.lang.Object
  extended by com.simpleservlets.htmlobjects.HTMLAttribute

public final class HTMLAttribute
extends Object

Immutable objects which hold a string-based name and a string-based value. Since instances are immutable, they can be safely shared.

Author:
Paul Hyde

Field Summary
static HTMLAttribute[] ZERO_LEN_ARRAY
           
 
Constructor Summary
HTMLAttribute(String name)
          Creates an attribute defaulting the value to be the same as the name.
HTMLAttribute(String name, double value)
          Creates an attribute with the specified name and value.
HTMLAttribute(String name, int value)
          Creates an attribute with the specified name and value.
HTMLAttribute(String name, Object value)
          Creates an attribute with the specified name and value.
HTMLAttribute(String name, String value)
          Creates an attribute with the specified name and value.
HTMLAttribute(String name, Value value)
          Creates an attribute with the specified name and value.
 
Method Summary
static HTMLAttribute createUnparsed(String name, Object value)
          Creates an attribute with the specified name and value.
static HTMLAttribute createUnparsed(String name, String value)
          Creates an attribute with the specified name and value.
static HTMLAttribute createUnparsed(String name, Value value)
          Creates an attribute with the specified name and value.
 String getName()
          Returns the name of the attribute (never null and never blank).
 String getValue()
          Returns the value of the attribute (never null, might be blank).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ZERO_LEN_ARRAY

public static final HTMLAttribute[] ZERO_LEN_ARRAY
Constructor Detail

HTMLAttribute

public HTMLAttribute(String name,
                     String value)
              throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is automatically parsed for entities (see HTMLUtil.processMarkupEntities(String)).

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

HTMLAttribute

public HTMLAttribute(String name,
                     Value value)
              throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is automatically parsed for entities (see HTMLUtil.processMarkupEntities(String)). The value also has any leading and trailing whitespace trimmed.

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

HTMLAttribute

public HTMLAttribute(String name,
                     Object value)
              throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is automatically parsed for entities (see HTMLUtil.processMarkupEntities(String)).

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

HTMLAttribute

public HTMLAttribute(String name,
                     int value)
              throws IllegalArgumentException
Creates an attribute with the specified name and value.

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute
Throws:
IllegalArgumentException - if name is null, or if name is nothing but whitespace.

HTMLAttribute

public HTMLAttribute(String name,
                     double value)
              throws IllegalArgumentException
Creates an attribute with the specified name and value.

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute
Throws:
IllegalArgumentException - if name is null, or if name is nothing but whitespace.

HTMLAttribute

public HTMLAttribute(String name)
              throws IllegalArgumentException
Creates an attribute defaulting the value to be the same as the name.

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
Throws:
IllegalArgumentException - if name is null, or if name is nothing but whitespace.
Method Detail

createUnparsed

public static HTMLAttribute createUnparsed(String name,
                                           String value)
                                    throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is NOT parsed for entities (you should have a good reason for using this method—this is not typical).

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

createUnparsed

public static HTMLAttribute createUnparsed(String name,
                                           Value value)
                                    throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is NOT parsed for entities (you should have a good reason for using this method—this is not typical). The value also has any leading and trailing whitespace trimmed.

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

createUnparsed

public static HTMLAttribute createUnparsed(String name,
                                           Object value)
                                    throws IllegalArgumentException
Creates an attribute with the specified name and value. The value is NOT parsed for entities (you should have a good reason for using this method—this is not typical).

Parameters:
name - the name of the attribute and it must not be null and must not be empty.
value - the value of the attribute and it must not be null.
Throws:
IllegalArgumentException - if name or value is null, or if name is nothing but whitespace.

getName

public String getName()
Returns the name of the attribute (never null and never blank).


getValue

public String getValue()
Returns the value of the attribute (never null, might be blank).


SimpleServlets v5.5.0

Copyright © 2001-2007 Programix Incorporated. All rights reserved. SimpleServlets is free and is OSI Certified Open Source Software under the BSD license.