de.lessvoid.nifty.tools
Class ColorValidator

java.lang.Object
  extended by de.lessvoid.nifty.tools.ColorValidator

public class ColorValidator
extends Object

This checks a given String that represents a color for being valid. Supported are both short mode "#f12f" and long mode "#ff1122ff"

Author:
void, Martin Karing <nitram@illarion.org>

Constructor Summary
ColorValidator()
           
 
Method Summary
 boolean isLongMode(String toCheck)
          Check if the color text is written in the long form with alpha.
 boolean isLongModeWithoutAlpha(String toCheck)
          Check if the color text is written in the long form without alpha.
 boolean isShortMode(String toCheck)
          Check if the color text is written in the short form with alpha.
 boolean isShortModeWithoutAlpha(String toCheck)
          Check if the color text is written in the short form without alpha.
 boolean isValid(String toCheck)
          Check if a string fits any type of color definition string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorValidator

public ColorValidator()
Method Detail

isValid

public boolean isValid(String toCheck)
Check if a string fits any type of color definition string.

Parameters:
toCheck - the text to check
Returns:
true in case the text is a color definition

isShortMode

public boolean isShortMode(String toCheck)
Check if the color text is written in the short form with alpha. The text would have to look like this: #rgba

Parameters:
toCheck - the text to check
Returns:
true in case the text is a short form color definition with alpha

isShortModeWithoutAlpha

public boolean isShortModeWithoutAlpha(String toCheck)
Check if the color text is written in the short form without alpha. The text would have to look like this: #rgb

Parameters:
toCheck - the text to check
Returns:
true in case the text is a short form color definition without alpha

isLongMode

public boolean isLongMode(String toCheck)
Check if the color text is written in the long form with alpha. The text would have to look like this: #rrggbbaa

Parameters:
toCheck - the text to check
Returns:
true in case the text is a long form color definition with alpha

isLongModeWithoutAlpha

public boolean isLongModeWithoutAlpha(String toCheck)
Check if the color text is written in the long form without alpha. The text would have to look like this: #rrggbb

Parameters:
toCheck - the text to check
Returns:
true in case the text is a long form color definition without alpha


Copyright © 2012. All Rights Reserved.