示例#1
0
 public Boolean getBooleanBody(Boolean def) {
   if (body == null) {
     return def;
   } else {
     return Boolean.valueOf(body);
   }
 }
示例#2
0
 public Boolean getBooleanAttribute(String name, Boolean def) {
   String value = attributes.getProperty(name);
   if (value == null) {
     return def;
   } else {
     return Boolean.valueOf(value);
   }
 }
示例#3
0
  static Object getValue(String pname, String pvalue, State state) {
    TYPE_NAME tname = state._hmPVariables.get(new PVAR_NAME(pname))._sRange;

    // TYPE_NAMES are interned so that equality can be tested directly
    // (also helps enforce better type safety)
    if (TYPE_NAME.INT_TYPE.equals(tname)) {
      return Integer.valueOf(pvalue);
    }

    if (TYPE_NAME.BOOL_TYPE.equals(tname)) {
      return Boolean.valueOf(pvalue);
    }

    if (TYPE_NAME.REAL_TYPE.equals(tname)) {
      return Double.valueOf(pvalue);
    }

    if (state._hmObject2Consts.containsKey(tname)) {
      return new OBJECT_VAL(pvalue);
      // for( LCONST lc : state._hmObject2Consts.get(tname)) {
      //	if ( lc.toString().equals(pvalue)) {
      //		return lc;
      //	}
      // }
    }

    if (state._hmTypes.containsKey(tname)) {
      return new ENUM_VAL(pvalue);
      // if ( state._hmTypes.get(tname) instanceof ENUM_TYPE_DEF ) {
      //	ENUM_TYPE_DEF etype = (ENUM_TYPE_DEF)state._hmTypes.get(tname);
      //	for ( ENUM_VAL ev : etype._alPossibleValues) {
      //		if ( ev.toString().equals(pvalue)) {
      //			return ev;
      //		}
      //	}
      // }
    }

    return null;
  }
示例#4
0
  protected static XmlConfigurator parse(InputStream stream, Boolean validate)
      throws java.io.IOException {
    /**
     * CAUTION: crappy code ahead ! I (bela) am not an XML expert, so the code below is pretty
     * amateurish... But it seems to work, and it is executed only on startup, so no perf loss on
     * the critical path. If somebody wants to improve this, please be my guest.
     */
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      boolean validation = false;
      String tmp = Util.getProperty(new String[] {Global.XML_VALIDATION}, null, null, false, null);
      if (tmp != null) {
        validation = Boolean.valueOf(tmp).booleanValue();
      } else if (validate != null) {
        validation = validate.booleanValue();
      }
      factory.setValidating(validation);
      factory.setNamespaceAware(validation);
      if (validation) {
        factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
      }

      DocumentBuilder builder = factory.newDocumentBuilder();
      builder.setEntityResolver(
          new EntityResolver() {

            public InputSource resolveEntity(String publicId, String systemId) throws IOException {
              if (systemId != null
                  && systemId.startsWith("http://www.jgroups.org/schema/JGroups-")) {
                String schemaName = systemId.substring("http://www.jgroups.org/".length());
                InputStream schemaIs = getAsInputStreamFromClassLoader(schemaName);
                if (schemaIs == null) {
                  throw new IOException("Schema not found from classloader: " + schemaName);
                }
                InputSource source = new InputSource(schemaIs);
                source.setPublicId(publicId);
                source.setSystemId(systemId);
                return source;
              }
              return null;
            }
          });
      // Use AtomicReference to allow make variable final, not for atomicity
      // We store only last exception
      final AtomicReference<SAXParseException> exceptionRef =
          new AtomicReference<SAXParseException>();
      builder.setErrorHandler(
          new ErrorHandler() {

            public void warning(SAXParseException exception) throws SAXException {
              log.warn("Warning during parse", exception);
            }

            public void fatalError(SAXParseException exception) throws SAXException {
              exceptionRef.set(exception);
            }

            public void error(SAXParseException exception) throws SAXException {
              exceptionRef.set(exception);
            }
          });
      Document document = builder.parse(stream);
      if (exceptionRef.get() != null) {
        throw exceptionRef.get();
      }

      // The root element of the document should be the "config" element,
      // but the parser(Element) method checks this so a check is not
      // needed here.
      Element configElement = document.getDocumentElement();
      return parse(configElement);
    } catch (Exception x) {
      throw new IOException(Util.getMessage("ParseError", x.getLocalizedMessage()));
    }
  }
 /** Sets the XRI authority isContact flag */
 public void setIsContact(boolean isContact) {
   this.isContact = Boolean.valueOf(isContact);
 }
 /** Sets the XRI authority isEscrow flag */
 public void setIsEscrow(boolean isEscrow) {
   this.isEscrow = Boolean.valueOf(isEscrow);
 }