コード例 #1
0
ファイル: XercesParser.java プロジェクト: veinrein/usemon
  /**
   * Configure schema validation as recommended by the JAXP 1.2 spec. The <code>properties</code>
   * object may contains information about the schema local and language.
   *
   * @param properties parser optional info
   */
  private static void configureOldXerces(SAXParser parser, Properties properties)
      throws ParserConfigurationException, SAXNotSupportedException {

    String schemaLocation = (String) properties.get("schemaLocation");
    String schemaLanguage = (String) properties.get("schemaLanguage");

    try {
      if (schemaLocation != null) {
        parser.setProperty(JAXP_SCHEMA_LANGUAGE, schemaLanguage);
        parser.setProperty(JAXP_SCHEMA_SOURCE, schemaLocation);
      }
    } catch (SAXNotRecognizedException e) {
      log.info(parser.getClass().getName() + ": " + e.getMessage() + " not supported.");
    }
  }
コード例 #2
0
  /**
   * Convert the specified locale-sensitive input object into an output object of the specified
   * type.
   *
   * @param value The input object to be converted
   * @param pattern The pattern is used for the convertion
   * @exception ConversionException if conversion cannot be performed successfully
   */
  protected Object parse(Object value, String pattern) throws ParseException {
    // DecimalFormat is not thread safe so best to construct one each time
    DecimalFormat formatter = (DecimalFormat) DecimalFormat.getInstance(locale);
    // if some constructors default pattern to null, it makes only sense to handle null pattern
    // gracefully
    if (pattern != null) {
      if (locPattern) {
        formatter.applyLocalizedPattern(pattern);
      } else {
        formatter.applyPattern(pattern);
      }
    } else {
      log.warn("No pattern provided, using default.");
    }

    return formatter.parse((String) value);
  }