jcurzez
Class Attribute

java.lang.Object
  |
  +--jcurzez.Attribute

public final class Attribute
extends java.lang.Object

A Jcurzez attribute (bold, underline, and so on). There are several predefined attributes :

Attributes can be combined (using and() or andNot()). Thus, if we want to use a bold and underline attribute, we create this compound attribute as shown below:

 Attribute boldAndUnderline = Attribute.BOLD.and(Attribute.UNDERLINE);
 

Version:
0.0.3
Author:
Thomas Girard

Field Summary
static Attribute BLINK
          BLINK attribute.
static Attribute BOLD
          BOLD attribute.
static Attribute DIM
          DIM attribute.
static Attribute NORMAL
          NORMAL attribute.
static Attribute REVERSE
          REVERSE attribute.
static Attribute STANDOUT
          STANDOUT attribute.
static Attribute UNDERLINE
          UNDERLINE attribute.
private  byte value
          The value of the attribute.
 
Constructor Summary
private Attribute(byte value)
          Creates a new attribute, having name name.
 
Method Summary
 Attribute and(Attribute a)
          Creates a new Attribute that combines a and this.
 Attribute andNot(Attribute a)
          Create a new attribute that has attribute a off.
 boolean equals(java.lang.Object o)
          Tests equality of this with o.
 byte getValue()
          Returns the value describing this.
 boolean hasAttribute(Attribute a)
          Checks whether this has attribute a.
 int hashCode()
          Returns the hashcode of this attribute.
 java.lang.String toString()
          Returns a string representation of this, in the form [ bold underline ].
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

value

private final byte value
The value of the attribute.


NORMAL

public static final Attribute NORMAL
NORMAL attribute.


BLINK

public static final Attribute BLINK
BLINK attribute.


BOLD

public static final Attribute BOLD
BOLD attribute.


DIM

public static final Attribute DIM
DIM attribute.


REVERSE

public static final Attribute REVERSE
REVERSE attribute.


STANDOUT

public static final Attribute STANDOUT
STANDOUT attribute.


UNDERLINE

public static final Attribute UNDERLINE
UNDERLINE attribute.

Constructor Detail

Attribute

private Attribute(byte value)
Creates a new attribute, having name name.

Parameters:
value - the value of the attribute.
Method Detail

hasAttribute

public boolean hasAttribute(Attribute a)
Checks whether this has attribute a.

Parameters:
a - the attribute we want to check this against.
Returns:
true if this has attribute a on.

and

public Attribute and(Attribute a)
Creates a new Attribute that combines a and this.

Parameters:
a - the attribute to combine with this.
Returns:
the newly created attribute, or this if a attribute was already set for this.

andNot

public Attribute andNot(Attribute a)
Create a new attribute that has attribute a off.

Parameters:
a - the attribute to unset from this.
Returns:
the newly created attribute, or this if a was not set in it.

equals

public boolean equals(java.lang.Object o)
Tests equality of this with o.

Overrides:
equals in class java.lang.Object
Parameters:
o - the object we want to test.
Returns:
true if this and o are equal.

hashCode

public int hashCode()
Returns the hashcode of this attribute. Since having same value means attributes are equal, this is the the hashcode.

Overrides:
hashCode in class java.lang.Object
Returns:
value.

toString

public java.lang.String toString()
Returns a string representation of this, in the form [ bold underline ].

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this.

getValue

public byte getValue()
Returns the value describing this.

Returns:
value.


Send me an email