Package org.apache.synapse.mediators.transform

Examples of org.apache.synapse.mediators.transform.PayloadFactoryMediator$Argument


                    }

                    // TODO: why do we iterate over all anonymous arguments?
                    // canProcess will always return true?
                    for (final Iterator i = anonymous.iterator(); i.hasNext();) {
                        final Argument argument = (Argument) i.next();

                        if (argument.canProcess(commandLine, arguments)) {
                            argument.process(commandLine, arguments);
                        }
                    }
                } // [END argument is NOT anonymous
            } // [END option NOT found
        } // [END process each command line token
View Full Code Here


     *
     * @return A new Argument instance using the options specified in this
     * ArgumentBuilder.
     */
    public final Argument create() {
        final Argument argument =
            new ArgumentImpl(
                name,
                description,
                minimum,
                maximum,
View Full Code Here

    private void createOption(
        final char type,
        final boolean required,
        final char opt) {
        final Argument argument;
        if (type != ' ') {
            abuilder.reset();
            abuilder.withValidator(validator(type));
            if (required) {
                abuilder.withMinimum(1);
View Full Code Here

    }
  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required){
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      create();
    return builder.
View Full Code Here

  }
 
  private Option createOption(String name, String desc,
                              String argName, int max, boolean required, Validator validator){
   
    Argument argument = argBuilder.
      withName(argName).
      withMinimum(1).
      withMaximum(max).
      withValidator(validator).
      create();
View Full Code Here

        GroupBuilder gBuilder = new GroupBuilder();

        /**
         *  OUTPUT Option
         */
        Argument outputPath = aBuilder.withName("output path").withMinimum(1).withMaximum(1).create();
        Option outputOption = oBuilder.withLongName("output")
                                      .withDescription("Path to generated output file")
                                      .withArgument(outputPath).create();

        /**
         *  GCP Option
         */
        Argument GCPPath = aBuilder.withName("path").withMinimum(1).withMaximum(1).create();
        Option inputOption = oBuilder.withLongName("input").withDescription("File with GCPs")
                                     .withArgument(GCPPath).create();

        /**
         * Set skew option
         */
        Argument skewArg = aBuilder.withName("skew").withMinimum(1).withMaximum(1).create();
        Option setSkew = oBuilder.withLongName("skew")
                                 .withDescription("Sets exlipcitly the value of skew parameter ")
                                 .withArgument(skewArg).create();

        /**
         * Set rotation option
         */
        Argument phiArg = aBuilder.withName("rotation").withMinimum(1).withMaximum(1).create();
        Option setPhi = oBuilder.withLongName("phi")
                                .withDescription("Sets exlipcitly the value of rotation parameter (in radians)")
                                .withArgument(phiArg).create();

        Option statistics = oBuilder.withLongName("s")
View Full Code Here

        if (!(m instanceof PayloadFactoryMediator)) {
            handleException("Unsupported mediator was passed in for serialization: " + m.getType());
            return null;
        }

        PayloadFactoryMediator mediator = (PayloadFactoryMediator) m;

        OMElement payloadFactoryElem = fac.createOMElement(PAYLOAD_FACTORY, synNS);
        saveTracingState(payloadFactoryElem, mediator);

        if (mediator.getFormat() != null) {

            try {
                OMElement formatElem = fac.createOMElement(FORMAT, synNS);
                formatElem.addChild(AXIOMUtil.stringToOM(mediator.getFormat()));
                payloadFactoryElem.addChild(formatElem);
            } catch (XMLStreamException e) {
                handleException("Error while serializing payloadFactory mediator", e);
            }
        } else {
            handleException("Invalid payloadFactory mediator, format is required");
        }

        List<PayloadFactoryMediator.Argument> argList = mediator.getArgumentList();

        if (argList != null && argList.size() > 0) {

            OMElement argumentsElem = fac.createOMElement(ARGS, synNS);
View Full Code Here

    private static final QName FORMAT_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "format");
    private static final QName ARGS_Q = new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "args");

    public Mediator createSpecificMediator(OMElement elem, Properties properties) {

        PayloadFactoryMediator payloadFactoryMediator = new PayloadFactoryMediator();

        OMElement formatElem = elem.getFirstChildWithName(FORMAT_Q);

        if (formatElem != null) {
            OMElement copy = formatElem.getFirstElement().cloneOMElement();
            removeIndentations(copy);
            payloadFactoryMediator.setFormat(copy.toString());
        } else {
            handleException("format element of payloadFactoryMediator is required");
        }

        OMElement argumentsElem = elem.getFirstChildWithName(ARGS_Q);

        if (argumentsElem != null) {

            Iterator itr = argumentsElem.getChildElements();

            while (itr.hasNext()) {
                OMElement argElem = (OMElement) itr.next();
                PayloadFactoryMediator.Argument arg = new PayloadFactoryMediator.Argument();
                String value;

                if ((value = argElem.getAttributeValue(ATT_VALUE)) != null) {
                    arg.setValue(value);
                } else if ((value = argElem.getAttributeValue(ATT_EXPRN)) != null) {

                    if (value.trim().length() == 0) {
                        handleException("Value of 'expression' attribute is required");
                    } else {
                        try {
                            arg.setExpression(SynapseXPathFactory.getSynapseXPath(argElem, ATT_EXPRN));
                        } catch (JaxenException e) {
                            handleException("Invalid XPath expression is provided for " +
                                    "'expression' attribute: " + value, e);
                        }
                    }

                } else {
                    handleException("Unsupported arg type. 'value' or 'expression' attribute is " +
                            "required");
                }

                payloadFactoryMediator.addArgument(arg);
            }
        }

        return payloadFactoryMediator;
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.transform.PayloadFactoryMediator$Argument

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.