public void doCompare(
      Object value1,
      Object value2,
      List<Object> messages,
      Locale locale,
      ClassLoader loader,
      boolean value2InlineConstant) {
    Boolean success =
        BaseCompare.doRealCompare(
            value1,
            value2,
            this.operator,
            this.type,
            this.format,
            messages,
            locale,
            loader,
            value2InlineConstant);

    if (success != null && success.booleanValue() == false) {
      addMessage(messages, loader, locale);
    }
  }
 /**
  * Gets the XRI authority isContact flag. If the flag was never set, this method returns the
  * default value (false).
  */
 public boolean getIsContact() {
   if (isContact == null) return false;
   return isContact.booleanValue();
 }
示例#3
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()));
    }
  }
 /**
  * Gets the XRI authority isEscrow flag. If the flag was never set, this method would return the
  * default (false) value.
  */
 public boolean getIsEscrow() {
   if (isEscrow == null) return false;
   return isEscrow.booleanValue();
 }