Here you can find the source of getNumberStyleAsInt(String style)
Parameter | Description |
---|---|
style | the string to be checked |
public static int getNumberStyleAsInt(String style)
//package com.java2s; //License from project: LGPL public class Main { private static final int STYLE_NUMBER = 0; private static final int STYLE_CURRENCY = 1; private static final int STYLE_PERCENT = 2; private static final int STYLE_INTEGER = 4; /**//w w w . j a v a 2 s .co m * Checks a string to see if it matches one of the standard * NumberFormat style patterns: * number, currency, percent, integer, or default. * if it does it will return the integer constant for that pattern. * if not, it will return -1. * * @param style the string to be checked * @return the int identifying the style pattern * @see NumberFormat */ public static int getNumberStyleAsInt(String style) { // avoid needlessly running through all the string comparisons if (style == null || style.length() < 6 || style.length() > 8) { return -1; } if (style.equalsIgnoreCase("default")) { //NOTE: java.text.NumberFormat returns "number" instances // as the default (at least in Java 1.3 and 1.4). return STYLE_NUMBER; } if (style.equalsIgnoreCase("number")) { return STYLE_NUMBER; } if (style.equalsIgnoreCase("currency")) { return STYLE_CURRENCY; } if (style.equalsIgnoreCase("percent")) { return STYLE_PERCENT; } if (style.equalsIgnoreCase("integer")) { return STYLE_INTEGER; } // ok, it's not any of the standard patterns return -1; } }