Package org.apache.cocoon.precept

Examples of org.apache.cocoon.precept.Constraint


          if (constraintAliases.containsKey(constraintType)) {
            List aliasConstraints = (List) constraintAliases.get(constraintType);
            int i = 1;
            for (Iterator it = aliasConstraints.iterator(); it.hasNext(); i++) {
              Constraint constraint = (Constraint) it.next();
              getLogger().debug("new alias constraint " + (constraints.size() + i) + ". " + String.valueOf(constraint.getType()) + "[" + String.valueOf(constraint) + "]");
            }
            constraints.addAll(aliasConstraints);
          }
          else {
            Constraint constraint = constraintFactory.createConstraintInstance(constraintType, constraintName, constraintContext, configurationHandler.getConfiguration());

            if (constraint instanceof Loggable) {
              ((Loggable)constraint).setLogger(getLogger());
            }

            if (constraint instanceof Configurable) {
              try {
                ((Configurable)constraint).configure(configurationHandler.getConfiguration());
              }
              catch(Throwable t) {
                getLogger().error("",t);
              }
            }

            if (constraint != null) {
              getLogger().debug("new simple constraint " + (constraints.size() + 1) + ". " + String.valueOf(constraint.getType()) + "[" + String.valueOf(constraint) + "]");
              constraints.add(constraint);
            }
            else {
              throw new SAXException("could not create constraint " + String.valueOf(constraintType));
            }
View Full Code Here


    if (withConstraints) {
      Collection constraints = e.getConstraints();
      if (constraints != null) {
        for (Iterator it = constraints.iterator(); it.hasNext();) {
          Constraint constraint = (Constraint) it.next();

          handler.startElement("", "constraint", "constraint", NOATTR);
          String s = String.valueOf(constraint.getId()) +
                  " of type " + String.valueOf(constraint.getType()) +
                  " is " + constraint.isSatisfiedBy(e.getValue(), null);
          handler.characters(s.toString().toCharArray(), 0, s.length());
          handler.endElement("", "constraint", "constraint");
        }
      }
    }
View Full Code Here

  public void toStringBuffer( StringBuffer sb, int depth) {
    sb.append(" ").append(name).append("=");

    if (constraints != null) {
      for (Iterator it = constraints.iterator(); it.hasNext();) {
        Constraint constraint = (Constraint) it.next();
        sb.append("{").append(constraint.getType()).append("}");
      }
    }

    sb.append("[").append( (required)?"required":"optional"  ).append("]");
  }
View Full Code Here

        if (withConstraints) {
            Collection constraints = e.getConstraints();
            if (constraints != null) {
                for (Iterator it = constraints.iterator(); it.hasNext();) {
                    Constraint constraint = (Constraint) it.next();

                    handler.startElement("", "constraint", "constraint", NOATTR);
                    String s = String.valueOf(constraint.getId()) +
                            " of type " + String.valueOf(constraint.getType()) +
                            " is " + constraint.isSatisfiedBy(e.getValue(), null);
                    handler.characters(s.toString().toCharArray(), 0, s.length());
                    handler.endElement("", "constraint", "constraint");
                }
            }
        }
View Full Code Here

                    if (constraintAliases.containsKey(constraintType)) {
                        List aliasConstraints = (List) constraintAliases.get(constraintType);
                        int i = 1;
                        for (Iterator it = aliasConstraints.iterator(); it.hasNext(); i++) {
                            Constraint constraint = (Constraint) it.next();
                            getLogger().debug("new alias constraint " + (constraints.size() + i) + ". " + String.valueOf(constraint.getType()) + "[" + String.valueOf(constraint) + "]");
                        }
                        constraints.addAll(aliasConstraints);
                    }
                    else {
                        Constraint constraint = constraintFactory.createConstraintInstance(constraintType, constraintName, constraintContext, configurationHandler.getConfiguration());

                        if (constraint instanceof LogEnabled) {
                            ((LogEnabled) constraint).enableLogging(getLogger());
                        }

                        if (constraint instanceof Configurable) {
                            try {
                                ((Configurable) constraint).configure(configurationHandler.getConfiguration());
                            }
                            catch (Throwable t) {

                                getLogger().error("", t);

                            }
                        }

                        if (constraint != null) {
                            getLogger().debug("new simple constraint " + (constraints.size() + 1) + ". " + String.valueOf(constraint.getType()) + "[" + String.valueOf(constraint) + "]");
                            constraints.add(constraint);
                        }
                        else {
                            throw new SAXException("could not create constraint " + String.valueOf(constraintType));
                        }
View Full Code Here

   public void toStringBuffer(StringBuffer sb, int depth) {
        sb.append(" ").append(name).append("=");

       if (constraints != null) {
            for (Iterator it = constraints.iterator(); it.hasNext();) {
                Constraint constraint = (Constraint) it.next();
                sb.append("{").append(constraint.getType()).append("}");
            }
        }

       sb.append("[").append((required) ? "required" : "optional").append("]");
    }
View Full Code Here

        sb.append(">");

        if (e.getConstraints() != null) {
            for (Iterator it = e.getConstraints().iterator(); it.hasNext();) {
                Constraint constraint = (Constraint) it.next();
                sb.append("{").append(constraint.getType()).append("}");
            }
        }
        else {
            sb.append("{*}");
        }
View Full Code Here

TOP

Related Classes of org.apache.cocoon.precept.Constraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.