22 package com.realtime.crossfire.jxclient.skin.io;
31 import java.awt.Color;
32 import java.io.IOException;
33 import java.io.LineNumberReader;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
55 public static int parseStat(@NotNull
final String name)
throws IOException {
58 }
catch (
final IllegalArgumentException ignored) {
62 throw new IOException(
"invalid stat name: "+name);
75 }
catch (
final IllegalArgumentException ignored) {
79 throw new IOException(
"invalid orientation: "+name);
89 public static Color
parseColor(@NotNull
final String name)
throws IOException {
94 throw new IOException(
"unknown color name "+name);
104 final int pos = name.lastIndexOf(
'/');
112 }
catch (
final IOException ignored) {
115 if (alpha < 0 || alpha > 255) {
119 final String colorName = name.substring(0, pos);
128 return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
138 if (name.equals(
"BLACK")) {
141 if (name.equals(
"BLUE")) {
144 if (name.equals(
"DARK_GRAY")) {
145 return Color.DARK_GRAY;
147 if (name.equals(
"GRAY")) {
150 if (name.equals(
"WHITE")) {
153 if (name.length() == 7 && name.charAt(0) ==
'#' && name.charAt(1) !=
'-') {
155 return new Color(Integer.parseInt(name.substring(1), 16));
156 }
catch (
final NumberFormatException ignored) {
173 public static String
parseText(@NotNull
final Args args, @NotNull
final LineNumberReader lnr)
throws IOException {
174 final StringBuilder text =
new StringBuilder();
175 if (args.hasMore()) {
176 text.append(args.get());
177 while (args.hasMore()) {
179 text.append(args.get());
182 if (text.toString().equals(
"<<EOF")) {
185 final String line = lnr.readLine();
187 throw new IOException(
"EOF");
189 if (line.equals(
"EOF")) {
192 if (line.startsWith(
"#")) {
199 if (text.length() > 0) {
200 text.setLength(text.length()-1);
204 return text.toString().replaceFirst(
"_$",
" ");
217 return optionManager.getCheckBoxOption(name);
219 throw new IOException(ex.getMessage(), ex);
static Color parseColor(@NotNull final String name)
Parses a color name.
static Orientation parseOrientation(@NotNull final String name)
Parses an orientation value.
Interface for orientation images.
Maintains a set of named options.
Utility class to parse stat names.
Utility class for parsing string parameters into values.
static float parseFloat(@NotNull final String str)
Parses a float constant.
static int parseStat(@NotNull final String name)
Parses a stat value.
Utility class to parse orientation names.
Indicates about an incorrect option.
static Color parseColorNull(@NotNull final String name)
Parses a color name, optionally followed by "/<alpha>".
static Color parseColorName(@NotNull final String name)
Parses a color name.
Utility class for parsing strings into numbers.
static Orientation parseOrientation(@NotNull final String name)
Converts an orientation name into an Orientation instance.
ParseUtils()
Private constructor to prevent instantiation.
static CheckBoxOption parseCheckBoxOption(@NotNull final String name, @NotNull final OptionManager optionManager)
Parses a check box option name.
The base class for all check box options.
static String parseText(@NotNull final Args args, @NotNull final LineNumberReader lnr)
Concatenates trailing arguments into a string.
static int parseStat(@NotNull final String name)
Converts a stat name into a stat index.