Josh
Native console access wrapper for Java

com.yifanlu.Josh
Class ConsoleAttribute

java.lang.Object
  extended by com.yifanlu.Josh.ConsoleAttribute
Direct Known Subclasses:
ConsoleCharInfo, ConsoleColor, ConsoleScreenBufferInfo

public class ConsoleAttribute
extends java.lang.Object

Stores the attribute of a character. The attribute is composed of the text color (foreground color), the highlighting (background color), and it's byte changes. If you are just going to modify color attributes, we suggest using the superclass ConsoleColor.

Since:
1.0
Version:
1.3, 05/29/10
Author:
Yifan Lu
See Also:
JoshOutBuffer

Field Summary
protected  int attributes
           
static int COMMON_LVB_GRID_HORIZONTAL
          Character byte change.
static int COMMON_LVB_GRID_LVERTICAL
          Character byte change.
static int COMMON_LVB_GRID_RVERTICAL
          Character byte change.
static int COMMON_LVB_LEADING_BYTE
          Character byte change.
static int COMMON_LVB_REVERSE_VIDEO
          Character byte change.
static int COMMON_LVB_TRAILING_BYTE
          Character byte change.
static int COMMON_LVB_UNDERSCORE
          Character byte change.
 
Constructor Summary
ConsoleAttribute()
          Create a new object with no attributes.
ConsoleAttribute(int attributes)
          Create a new attribute object with an int.
 
Method Summary
 void addAttributes(int attribute)
          Mixes another attribute Use the constants like COMMON_LVB_LEADING_BYTE for the attribute and this will use the OR operator to add the attribute to the object.
 boolean equals(java.lang.Object anObject)
          Compares two Objects, if both are ConsoleAttribute and have the same attributes, they are equal.
 int getAttributes()
          Gets the attributes stored in the object.
 int hashCode()
          Returns a hash code.
 void setAttributes(int attributes)
          Sets the attributes
 java.lang.String toString()
          A String representation of this object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

attributes

protected int attributes

COMMON_LVB_LEADING_BYTE

public static final int COMMON_LVB_LEADING_BYTE
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_TRAILING_BYTE

public static final int COMMON_LVB_TRAILING_BYTE
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_GRID_HORIZONTAL

public static final int COMMON_LVB_GRID_HORIZONTAL
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_GRID_LVERTICAL

public static final int COMMON_LVB_GRID_LVERTICAL
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_GRID_RVERTICAL

public static final int COMMON_LVB_GRID_RVERTICAL
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_REVERSE_VIDEO

public static final int COMMON_LVB_REVERSE_VIDEO
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values

COMMON_LVB_UNDERSCORE

public static final int COMMON_LVB_UNDERSCORE
Character byte change.

See Also:
Windows console attributes constants, Constant Field Values
Constructor Detail

ConsoleAttribute

public ConsoleAttribute()
Create a new object with no attributes.


ConsoleAttribute

public ConsoleAttribute(int attributes)
Create a new attribute object with an int. An attribute is an hex int value. You can mix and match different attributes with the OR ( | ) operator. For example the attribute ConsoleAttribute.COMMON_LVB_LEADING_BYTE | ConsoleAttribute.COMMON_LVB_TRAILING_BYTE | ConsoleAttribute.COMMON_LVB_GRID_LVERTICAL is valid for the int attribute parameter.

Parameters:
attributes - The attribute(s) of the character which can be mixed with the OR operator.
Method Detail

addAttributes

public void addAttributes(int attribute)
Mixes another attribute Use the constants like COMMON_LVB_LEADING_BYTE for the attribute and this will use the OR operator to add the attribute to the object. This is equivalent to setAttributes(getAttributes() | attribute) .

Parameters:
attribute - The attribute to mix.

getAttributes

public int getAttributes()
Gets the attributes stored in the object.

Returns:
The attributes stored.

setAttributes

public void setAttributes(int attributes)
Sets the attributes

Parameters:
attributes - The attribute(s) of the character which can be mixed with the OR operator.

equals

public boolean equals(java.lang.Object anObject)
Compares two Objects, if both are ConsoleAttribute and have the same attributes, they are equal.

Overrides:
equals in class java.lang.Object
Parameters:
anObject - Another ConsoleAttribute object.
Returns:
true if both attributes are equal.

hashCode

public int hashCode()
Returns a hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for this object.

toString

public java.lang.String toString()
A String representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The attributes as a number.

Copyright © 2010 Yifan Lu