Example usage for java.util HashMap putAll

List of usage examples for java.util HashMap putAll

Introduction

In this page you can find the example usage for java.util HashMap putAll.

Prototype

public void putAll(Map<? extends K, ? extends V> m) 

Source Link

Document

Copies all of the mappings from the specified map to this map.

Usage

From source file:org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCache.java

/**
 * Saves key file to disk. This converts the LRUMap to a HashMap for deserialzation.
 *//*from   www . j a va2  s. c o  m*/
protected void saveKeys() {
    try {
        if (log.isDebugEnabled()) {
            log.debug(logCacheName + "Saving keys to: " + fileName + ", key count: " + keyHash.size());
        }

        keyFile.reset();

        HashMap keys = new HashMap();
        keys.putAll(keyHash);

        if (keys.size() > 0) {
            keyFile.writeObject(keys, 0);
        }

        if (log.isDebugEnabled()) {
            log.debug(logCacheName + "Finished saving keys.");
        }
    } catch (Exception e) {
        log.error(logCacheName + "Problem storing keys.", e);
    }
}

From source file:smilehouse.opensyncro.pipes.Pipe.java

/**
 * Sets some parameters of the pipe to same values as of the given pipe. 
 * All parameters, except those relating to last execution info are copied
 * //from  ww w .  j a  v a  2 s  .c o m
 * @param pipe The pipe to get the settings from
 */
public Pipe clone() throws ClassCastException {
    Pipe pipe = new Pipe();
    pipe.setAbortMailEnabled(this.isAbortMailEnabled());

    Iterator it = this.getConverterList().iterator();
    List newClist = new LinkedList();
    while (it.hasNext()) {
        ConverterListItem cvi = (ConverterListItem) it.next();
        ConverterListItem ci = new ConverterListItem();
        ci.setConverter(cvi.getConverter());
        HashMap cmap = new HashMap(cvi.getConverterData().getAttributes());
        ci.setConverterData(new PipeComponentData(cmap));
        ci.setConverterID(cvi.getConverterID());
        ci.setParent(this);
        newClist.add(ci);
    }
    pipe.setConverterList(newClist);

    HashMap dmap = new HashMap();
    if (this.getDestinationData() != null) {
        dmap.putAll(this.getDestinationData().getAttributes());
    }
    pipe.setDestinationData(new PipeComponentData(dmap));
    pipe.setDestinationID(this.getDestinationID());

    pipe.setHttpStartEnabled(this.isHttpStartEnabled());
    pipe.setMailHost(this.getMailHost());
    pipe.setName("Copy of " + this.getName());
    pipe.setRecipientAddress(this.getRecipientAddress());

    HashMap smap = new HashMap();
    if (this.getSourceData() != null) {
        smap.putAll(this.getSourceData().getAttributes());
    }
    pipe.setSourceData(new PipeComponentData(smap));
    pipe.setSourceID(this.getSourceID());

    pipe.setStartPassword(this.getStartPassword());
    pipe.setTransferLogNotificationLevel(this.getTransferLogNotificationLevel());
    pipe.setLoggingVerbosityLevel(this.getLoggingVerbosityLevel());
    return pipe;

}

From source file:org.tolweb.content.preparers.EolContentPreparer.java

private void addTextSectionDescription(MappedPage mpage, DaoBundle daos, HashMap<Integer, String> embeddedMedia,
        MappedTextSection mtxt, Element dataObject) {
    EmbeddedMediaHandler mediaHandler = new EmbeddedMediaHandler(mtxt.getText(),
            getPageNameUrl(mpage.getMappedNode()), daos.getImageDAO());
    Element dcDescEl = new Element("dc:description", NS_DUBLIN_CORE);
    dcDescEl.addAttribute(new Attribute("xml:lang", NS_XML, "en"));
    appendDescriptionText(mpage, mtxt, mediaHandler, dcDescEl);
    dataObject.appendChild(dcDescEl);//from   w ww  . ja  v a 2 s.  c om

    // add/put any embedded media in the map for all  
    // text sections so that it can be processed later. 
    embeddedMedia.putAll(mediaHandler.getEmbeddedMedia());
}

From source file:org.apache.sysml.parser.StatementBlock.java

public VariableSet validate(DMLProgram dmlProg, VariableSet ids, HashMap<String, ConstIdentifier> constVars,
        boolean conditional) throws LanguageException, ParseException, IOException {
    _constVarsIn.putAll(constVars);/*from   ww  w . java2  s . c  o m*/
    HashMap<String, ConstIdentifier> currConstVars = new HashMap<String, ConstIdentifier>();
    currConstVars.putAll(constVars);

    _statements = rewriteFunctionCallStatements(dmlProg, _statements);
    _dmlProg = dmlProg;

    for (Statement current : _statements) {

        if (current instanceof OutputStatement) {
            OutputStatement os = (OutputStatement) current;

            // validate variable being written by output statement exists
            DataIdentifier target = (DataIdentifier) os.getIdentifier();
            if (ids.getVariable(target.getName()) == null) {
                //undefined variables are always treated unconditionally as error in order to prevent common script-level bugs
                raiseValidateError("Undefined Variable (" + target.getName() + ") used in statement", false,
                        LanguageErrorCodes.INVALID_PARAMETERS);
            }

            if (ids.getVariable(target.getName()).getDataType() == DataType.SCALAR) {
                boolean paramsOkay = true;
                for (String key : os.getSource().getVarParams().keySet()) {
                    if (!(key.equals(DataExpression.IO_FILENAME) || key.equals(DataExpression.FORMAT_TYPE)))
                        paramsOkay = false;
                }
                if (!paramsOkay) {
                    raiseValidateError("Invalid parameters in write statement: " + os.toString(), conditional);
                }
            }

            Expression source = os.getSource();
            source.setOutput(target);
            source.validateExpression(ids.getVariables(), currConstVars, conditional);

            setStatementFormatType(os, conditional);
            target.setDimensionValueProperties(ids.getVariable(target.getName()));
        }

        else if (current instanceof AssignmentStatement) {
            AssignmentStatement as = (AssignmentStatement) current;
            DataIdentifier target = as.getTarget();
            Expression source = as.getSource();

            if (source instanceof FunctionCallIdentifier) {
                ((FunctionCallIdentifier) source).validateExpression(dmlProg, ids.getVariables(), currConstVars,
                        conditional);
            } else {
                if (MLContextProxy.isActive())
                    MLContextProxy.setAppropriateVarsForRead(source, target._name);

                source.validateExpression(ids.getVariables(), currConstVars, conditional);
            }

            if (source instanceof DataExpression
                    && ((DataExpression) source).getOpCode() == Expression.DataOp.READ)
                setStatementFormatType(as, conditional);

            // Handle const vars: (a) basic constant propagation, and (b) transitive constant propagation over assignments 
            currConstVars.remove(target.getName());
            if (source instanceof ConstIdentifier && !(target instanceof IndexedIdentifier)) { //basic
                currConstVars.put(target.getName(), (ConstIdentifier) source);
            }
            if (source instanceof DataIdentifier && !(target instanceof IndexedIdentifier)) { //transitive
                DataIdentifier diSource = (DataIdentifier) source;
                if (currConstVars.containsKey(diSource.getName())) {
                    currConstVars.put(target.getName(), currConstVars.get(diSource.getName()));
                }
            }

            if (source instanceof BuiltinFunctionExpression) {
                BuiltinFunctionExpression bife = (BuiltinFunctionExpression) source;
                if (bife.getOpCode() == Expression.BuiltinFunctionOp.NROW
                        || bife.getOpCode() == Expression.BuiltinFunctionOp.NCOL) {
                    DataIdentifier id = (DataIdentifier) bife.getFirstExpr();
                    DataIdentifier currVal = ids.getVariable(id.getName());
                    if (currVal == null) {
                        //undefined variables are always treated unconditionally as error in order to prevent common script-level bugs
                        bife.raiseValidateError("Undefined Variable (" + id.getName() + ") used in statement",
                                false, LanguageErrorCodes.INVALID_PARAMETERS);
                    }
                    IntIdentifier intid = null;
                    if (bife.getOpCode() == Expression.BuiltinFunctionOp.NROW) {
                        intid = new IntIdentifier(
                                (currVal instanceof IndexedIdentifier)
                                        ? ((IndexedIdentifier) currVal).getOrigDim1()
                                        : currVal.getDim1(),
                                bife.getFilename(), bife.getBeginLine(), bife.getBeginColumn(),
                                bife.getEndLine(), bife.getEndColumn());
                    } else {
                        intid = new IntIdentifier(
                                (currVal instanceof IndexedIdentifier)
                                        ? ((IndexedIdentifier) currVal).getOrigDim2()
                                        : currVal.getDim2(),
                                bife.getFilename(), bife.getBeginLine(), bife.getBeginColumn(),
                                bife.getEndLine(), bife.getEndColumn());
                    }

                    // handle case when nrow / ncol called on variable with size unknown (dims == -1) 
                    //   --> const prop NOT possible 
                    if (intid.getValue() != -1) {
                        currConstVars.put(target.getName(), intid);
                    }
                }
            }
            // CASE: target NOT indexed identifier
            if (!(target instanceof IndexedIdentifier)) {
                target.setProperties(source.getOutput());
                if (source.getOutput() instanceof IndexedIdentifier) {
                    target.setDimensions(source.getOutput().getDim1(), source.getOutput().getDim2());
                }

            }
            // CASE: target is indexed identifier
            else {
                // process the "target" being indexed
                DataIdentifier targetAsSeen = ids.getVariable(target.getName());
                if (targetAsSeen == null) {
                    target.raiseValidateError("cannot assign value to indexed identifier " + target.toString()
                            + " without first initializing " + target.getName(), conditional);
                }
                target.setProperties(targetAsSeen);

                // process the expressions for the indexing
                if (((IndexedIdentifier) target).getRowLowerBound() != null)
                    ((IndexedIdentifier) target).getRowLowerBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getRowUpperBound() != null)
                    ((IndexedIdentifier) target).getRowUpperBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getColLowerBound() != null)
                    ((IndexedIdentifier) target).getColLowerBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getColUpperBound() != null)
                    ((IndexedIdentifier) target).getColUpperBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);

                // validate that LHS indexed identifier is being assigned a matrix value
                //               if (source.getOutput().getDataType() != Expression.DataType.MATRIX){
                //                  LOG.error(target.printErrorLocation() + "Indexed expression " + target.toString() + " can only be assigned matrix value");
                //                  throw new LanguageException(target.printErrorLocation() + "Indexed expression " + target.toString() + " can only be assigned matrix value");
                //               }

                // validate that size of LHS index ranges is being assigned:
                //   (a) a matrix value of same size as LHS
                //   (b) singleton value (semantics: initialize enitre submatrix with this value)
                IndexPair targetSize = ((IndexedIdentifier) target)
                        .calculateIndexedDimensions(ids.getVariables(), currConstVars, conditional);

                if (targetSize._row >= 1 && source.getOutput().getDim1() > 1
                        && targetSize._row != source.getOutput().getDim1()) {
                    target.raiseValidateError("Dimension mismatch. Indexed expression " + target.toString()
                            + " can only be assigned matrix with dimensions " + targetSize._row + " rows and "
                            + targetSize._col + " cols. Attempted to assign matrix with dimensions "
                            + source.getOutput().getDim1() + " rows and " + source.getOutput().getDim2()
                            + " cols ", conditional);
                }

                if (targetSize._col >= 1 && source.getOutput().getDim2() > 1
                        && targetSize._col != source.getOutput().getDim2()) {
                    target.raiseValidateError("Dimension mismatch. Indexed expression " + target.toString()
                            + " can only be assigned matrix with dimensions " + targetSize._row + " rows and "
                            + targetSize._col + " cols. Attempted to assign matrix with dimensions "
                            + source.getOutput().getDim1() + " rows and " + source.getOutput().getDim2()
                            + " cols ", conditional);
                }

                ((IndexedIdentifier) target).setDimensions(targetSize._row, targetSize._col);
            }

            ids.addVariable(target.getName(), target);

        }

        else if (current instanceof MultiAssignmentStatement) {
            MultiAssignmentStatement mas = (MultiAssignmentStatement) current;
            ArrayList<DataIdentifier> targetList = mas.getTargetList();

            // perform validation of source expression
            Expression source = mas.getSource();
            /*
             * MultiAssignmentStatments currently supports only External, 
             * User-defined, and Multi-return Builtin function expressions
             */
            if (!(source instanceof DataIdentifier)
                    || (source instanceof DataIdentifier && !((DataIdentifier) source).multipleReturns())) {
                //if (!(source instanceof FunctionCallIdentifier) ) {
                //|| !(source instanceof BuiltinFunctionExpression && ((BuiltinFunctionExpression)source).isMultiReturnBuiltinFunction()) ){
                source.raiseValidateError("can only use user-defined functions with multi-assignment statement",
                        conditional);
            }

            if (source instanceof FunctionCallIdentifier) {
                FunctionCallIdentifier fci = (FunctionCallIdentifier) source;
                fci.validateExpression(dmlProg, ids.getVariables(), currConstVars, conditional);
            } else if ((source instanceof BuiltinFunctionExpression
                    || source instanceof ParameterizedBuiltinFunctionExpression)
                    && ((DataIdentifier) source).multipleReturns()) {
                source.validateExpression(mas, ids.getVariables(), currConstVars, conditional);
            } else
                throw new LanguageException("Unexpected error.");

            if (source instanceof FunctionCallIdentifier) {
                for (int j = 0; j < targetList.size(); j++) {

                    DataIdentifier target = targetList.get(j);
                    // set target properties (based on type info in function call statement return params)
                    FunctionCallIdentifier fci = (FunctionCallIdentifier) source;
                    FunctionStatement fstmt = (FunctionStatement) _dmlProg
                            .getFunctionStatementBlock(fci.getNamespace(), fci.getName()).getStatement(0);
                    if (fstmt == null) {
                        fci.raiseValidateError(" function " + fci.getName() + " is undefined in namespace "
                                + fci.getNamespace(), conditional);
                    }
                    if (!(target instanceof IndexedIdentifier)) {
                        target.setProperties(fstmt.getOutputParams().get(j));
                    } else {
                        DataIdentifier targetAsSeen = ids.getVariable(target.getName());
                        if (targetAsSeen == null) {
                            raiseValidateError(target.printErrorLocation()
                                    + "cannot assign value to indexed identifier " + target.toString()
                                    + " without first initializing " + target.getName(), conditional);
                        }
                        target.setProperties(targetAsSeen);
                    }
                    ids.addVariable(target.getName(), target);
                }
            } else if (source instanceof BuiltinFunctionExpression
                    || source instanceof ParameterizedBuiltinFunctionExpression) {
                Identifier[] outputs = source.getOutputs();
                for (int j = 0; j < targetList.size(); j++) {
                    ids.addVariable(targetList.get(j).getName(), (DataIdentifier) outputs[j]);
                }
            }
        }

        else if (current instanceof ForStatement || current instanceof IfStatement
                || current instanceof WhileStatement) {
            raiseValidateError(
                    "control statement (WhileStatement, IfStatement, ForStatement) should not be in generic statement block. Likely a parsing error",
                    conditional);
        }

        else if (current instanceof PrintStatement) {
            PrintStatement pstmt = (PrintStatement) current;
            List<Expression> expressions = pstmt.getExpressions();
            for (Expression expression : expressions) {
                expression.validateExpression(ids.getVariables(), currConstVars, conditional);
                if (expression.getOutput().getDataType() != Expression.DataType.SCALAR) {
                    raiseValidateError("print statement can only print scalars", conditional);
                }
            }

        }

        // no work to perform for PathStatement or ImportStatement
        else if (current instanceof PathStatement) {
        } else if (current instanceof ImportStatement) {
        }

        else {
            raiseValidateError("cannot process statement of type " + current.getClass().getSimpleName(),
                    conditional);
        }

    } // end for (Statement current : _statements){
    _constVarsOut.putAll(currConstVars);
    return ids;

}

From source file:com.ibm.bi.dml.parser.StatementBlock.java

/**
 * /*from w w w. ja v a  2 s .  c  o m*/
 * @param dmlProg
 * @param ids
 * @param constVars
 * @param conditional
 * @return
 * @throws LanguageException
 * @throws ParseException
 * @throws IOException
 */
public VariableSet validate(DMLProgram dmlProg, VariableSet ids, HashMap<String, ConstIdentifier> constVars,
        boolean conditional) throws LanguageException, ParseException, IOException {
    _constVarsIn.putAll(constVars);
    HashMap<String, ConstIdentifier> currConstVars = new HashMap<String, ConstIdentifier>();
    currConstVars.putAll(constVars);

    _statements = rewriteFunctionCallStatements(dmlProg, _statements);
    _dmlProg = dmlProg;

    for (Statement current : _statements) {

        if (current instanceof OutputStatement) {
            OutputStatement os = (OutputStatement) current;

            // validate variable being written by output statement exists
            DataIdentifier target = (DataIdentifier) os.getIdentifier();
            if (ids.getVariable(target.getName()) == null) {
                //undefined variables are always treated unconditionally as error in order to prevent common script-level bugs
                raiseValidateError("Undefined Variable (" + target.getName() + ") used in statement", false,
                        LanguageErrorCodes.INVALID_PARAMETERS);
            }

            if (ids.getVariable(target.getName()).getDataType() == DataType.SCALAR) {
                boolean paramsOkay = true;
                for (String key : os.getSource().getVarParams().keySet()) {
                    if (!(key.equals(DataExpression.IO_FILENAME) || key.equals(DataExpression.FORMAT_TYPE)))
                        paramsOkay = false;
                }
                if (!paramsOkay) {
                    raiseValidateError("Invalid parameters in write statement: " + os.toString(), conditional);
                }
            }

            Expression source = os.getSource();
            source.setOutput(target);
            source.validateExpression(ids.getVariables(), currConstVars, conditional);

            setStatementFormatType(os, conditional);
            target.setDimensionValueProperties(ids.getVariable(target.getName()));
        }

        else if (current instanceof AssignmentStatement) {
            AssignmentStatement as = (AssignmentStatement) current;
            DataIdentifier target = as.getTarget();
            Expression source = as.getSource();

            if (source instanceof FunctionCallIdentifier) {
                ((FunctionCallIdentifier) source).validateExpression(dmlProg, ids.getVariables(), currConstVars,
                        conditional);
            } else {
                if (MLContextProxy.isActive())
                    MLContextProxy.setAppropriateVarsForRead(source, target._name);

                source.validateExpression(ids.getVariables(), currConstVars, conditional);
            }

            if (source instanceof DataExpression
                    && ((DataExpression) source).getOpCode() == Expression.DataOp.READ)
                setStatementFormatType(as, conditional);

            // Handle const vars: (a) basic constant propagation, and (b) transitive constant propagation over assignments 
            currConstVars.remove(target.getName());
            if (source instanceof ConstIdentifier && !(target instanceof IndexedIdentifier)) { //basic
                currConstVars.put(target.getName(), (ConstIdentifier) source);
            }
            if (source instanceof DataIdentifier && !(target instanceof IndexedIdentifier)) { //transitive
                DataIdentifier diSource = (DataIdentifier) source;
                if (currConstVars.containsKey(diSource.getName())) {
                    currConstVars.put(target.getName(), currConstVars.get(diSource.getName()));
                }
            }

            if (source instanceof BuiltinFunctionExpression) {
                BuiltinFunctionExpression bife = (BuiltinFunctionExpression) source;
                if (bife.getOpCode() == Expression.BuiltinFunctionOp.NROW
                        || bife.getOpCode() == Expression.BuiltinFunctionOp.NCOL) {
                    DataIdentifier id = (DataIdentifier) bife.getFirstExpr();
                    DataIdentifier currVal = ids.getVariable(id.getName());
                    if (currVal == null) {
                        //undefined variables are always treated unconditionally as error in order to prevent common script-level bugs
                        bife.raiseValidateError("Undefined Variable (" + id.getName() + ") used in statement",
                                false, LanguageErrorCodes.INVALID_PARAMETERS);
                    }
                    IntIdentifier intid = null;
                    if (bife.getOpCode() == Expression.BuiltinFunctionOp.NROW) {
                        intid = new IntIdentifier(currVal.getDim1(), bife.getFilename(), bife.getBeginLine(),
                                bife.getBeginColumn(), bife.getEndLine(), bife.getEndColumn());
                    } else {
                        intid = new IntIdentifier(currVal.getDim2(), bife.getFilename(), bife.getBeginLine(),
                                bife.getBeginColumn(), bife.getEndLine(), bife.getEndColumn());
                    }

                    // handle case when nrow / ncol called on variable with size unknown (dims == -1) 
                    //   --> const prop NOT possible 
                    if (intid.getValue() != -1) {
                        currConstVars.put(target.getName(), intid);
                    }
                }
            }
            // CASE: target NOT indexed identifier
            if (!(target instanceof IndexedIdentifier)) {
                target.setProperties(source.getOutput());
                if (source.getOutput() instanceof IndexedIdentifier) {
                    target.setDimensions(source.getOutput().getDim1(), source.getOutput().getDim2());
                }

            }
            // CASE: target is indexed identifier
            else {
                // process the "target" being indexed
                DataIdentifier targetAsSeen = ids.getVariable(target.getName());
                if (targetAsSeen == null) {
                    target.raiseValidateError("cannot assign value to indexed identifier " + target.toString()
                            + " without first initializing " + target.getName(), conditional);
                }
                target.setProperties(targetAsSeen);

                // process the expressions for the indexing
                if (((IndexedIdentifier) target).getRowLowerBound() != null)
                    ((IndexedIdentifier) target).getRowLowerBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getRowUpperBound() != null)
                    ((IndexedIdentifier) target).getRowUpperBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getColLowerBound() != null)
                    ((IndexedIdentifier) target).getColLowerBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);
                if (((IndexedIdentifier) target).getColUpperBound() != null)
                    ((IndexedIdentifier) target).getColUpperBound().validateExpression(ids.getVariables(),
                            currConstVars, conditional);

                // validate that LHS indexed identifier is being assigned a matrix value
                //               if (source.getOutput().getDataType() != Expression.DataType.MATRIX){
                //                  LOG.error(target.printErrorLocation() + "Indexed expression " + target.toString() + " can only be assigned matrix value");
                //                  throw new LanguageException(target.printErrorLocation() + "Indexed expression " + target.toString() + " can only be assigned matrix value");
                //               }

                // validate that size of LHS index ranges is being assigned:
                //   (a) a matrix value of same size as LHS
                //   (b) singleton value (semantics: initialize enitre submatrix with this value)
                IndexPair targetSize = ((IndexedIdentifier) target)
                        .calculateIndexedDimensions(ids.getVariables(), currConstVars, conditional);

                if (targetSize._row >= 1 && source.getOutput().getDim1() > 1
                        && targetSize._row != source.getOutput().getDim1()) {
                    target.raiseValidateError("Dimension mismatch. Indexed expression " + target.toString()
                            + " can only be assigned matrix with dimensions " + targetSize._row + " rows and "
                            + targetSize._col + " cols. Attempted to assign matrix with dimensions "
                            + source.getOutput().getDim1() + " rows and " + source.getOutput().getDim2()
                            + " cols ", conditional);
                }

                if (targetSize._col >= 1 && source.getOutput().getDim2() > 1
                        && targetSize._col != source.getOutput().getDim2()) {
                    target.raiseValidateError("Dimension mismatch. Indexed expression " + target.toString()
                            + " can only be assigned matrix with dimensions " + targetSize._row + " rows and "
                            + targetSize._col + " cols. Attempted to assign matrix with dimensions "
                            + source.getOutput().getDim1() + " rows and " + source.getOutput().getDim2()
                            + " cols ", conditional);
                }

                ((IndexedIdentifier) target).setDimensions(targetSize._row, targetSize._col);
            }

            ids.addVariable(target.getName(), target);

        }

        else if (current instanceof MultiAssignmentStatement) {
            MultiAssignmentStatement mas = (MultiAssignmentStatement) current;
            ArrayList<DataIdentifier> targetList = mas.getTargetList();

            // perform validation of source expression
            Expression source = mas.getSource();
            /*
             * MultiAssignmentStatments currently supports only External, 
             * User-defined, and Multi-return Builtin function expressions
             */
            if (!(source instanceof DataIdentifier)
                    || (source instanceof DataIdentifier && !((DataIdentifier) source).multipleReturns())) {
                //if (!(source instanceof FunctionCallIdentifier) ) {
                //|| !(source instanceof BuiltinFunctionExpression && ((BuiltinFunctionExpression)source).isMultiReturnBuiltinFunction()) ){
                source.raiseValidateError("can only use user-defined functions with multi-assignment statement",
                        conditional);
            }

            if (source instanceof FunctionCallIdentifier) {
                FunctionCallIdentifier fci = (FunctionCallIdentifier) source;
                fci.validateExpression(dmlProg, ids.getVariables(), currConstVars, conditional);
            } else if (source instanceof BuiltinFunctionExpression
                    && ((DataIdentifier) source).multipleReturns()) {
                source.validateExpression(mas, ids.getVariables(), currConstVars, conditional);
            } else
                throw new LanguageException("Unexpected error.");

            if (source instanceof FunctionCallIdentifier) {
                for (int j = 0; j < targetList.size(); j++) {

                    DataIdentifier target = targetList.get(j);
                    // set target properties (based on type info in function call statement return params)
                    FunctionCallIdentifier fci = (FunctionCallIdentifier) source;
                    FunctionStatement fstmt = (FunctionStatement) _dmlProg
                            .getFunctionStatementBlock(fci.getNamespace(), fci.getName()).getStatement(0);
                    if (fstmt == null) {
                        fci.raiseValidateError(" function " + fci.getName() + " is undefined in namespace "
                                + fci.getNamespace(), conditional);
                    }
                    if (!(target instanceof IndexedIdentifier)) {
                        target.setProperties(fstmt.getOutputParams().get(j));
                    } else {
                        DataIdentifier targetAsSeen = ids.getVariable(target.getName());
                        if (targetAsSeen == null) {
                            raiseValidateError(target.printErrorLocation()
                                    + "cannot assign value to indexed identifier " + target.toString()
                                    + " without first initializing " + target.getName(), conditional);
                        }
                        target.setProperties(targetAsSeen);
                    }
                    ids.addVariable(target.getName(), target);
                }
            } else if (source instanceof BuiltinFunctionExpression) {
                Identifier[] outputs = source.getOutputs();
                for (int j = 0; j < targetList.size(); j++) {
                    ids.addVariable(targetList.get(j).getName(), (DataIdentifier) outputs[j]);
                }
            }
        }

        else if (current instanceof ForStatement || current instanceof IfStatement
                || current instanceof WhileStatement) {
            raiseValidateError(
                    "control statement (CVStatement, ELStatement, WhileStatement, IfStatement, ForStatement) should not be in genreric statement block.  Likely a parsing error",
                    conditional);
        }

        else if (current instanceof PrintStatement) {
            PrintStatement pstmt = (PrintStatement) current;
            Expression expr = pstmt.getExpression();
            expr.validateExpression(ids.getVariables(), currConstVars, conditional);

            // check that variables referenced in print statement expression are scalars
            if (expr.getOutput().getDataType() != Expression.DataType.SCALAR) {
                raiseValidateError("print statement can only print scalars", conditional);
            }
        }

        // no work to perform for PathStatement or ImportStatement
        else if (current instanceof PathStatement) {
        } else if (current instanceof ImportStatement) {
        }

        else {
            raiseValidateError("cannot process statement of type " + current.getClass().getSimpleName(),
                    conditional);
        }

    } // end for (Statement current : _statements){
    _constVarsOut.putAll(currConstVars);
    return ids;

}

From source file:azkaban.webapp.servlet.ExecutorServlet.java

private void ajaxFetchExecutableFlow(HttpServletRequest req, HttpServletResponse resp,
        HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException {
    System.out.println("Fetching " + exFlow.getExecutionId());

    Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ);
    if (project == null) {
        return;//from  w  w w.ja  va  2  s. com
    }

    ret.put("submitTime", exFlow.getSubmitTime());
    ret.put("submitUser", exFlow.getSubmitUser());
    ret.put("execid", exFlow.getExecutionId());
    ret.put("projectId", exFlow.getProjectId());
    ret.put("project", project.getName());

    Map<String, Object> flowObj = getExecutableNodeInfo(exFlow);
    ret.putAll(flowObj);
}

From source file:org.ow2.proactive.scheduler.task.internal.InternalTask.java

/**
 * returns a generic replacement map, where up-to-date runtime variables were replaced
 *//*from  w w w .ja v a2s .  co  m*/
@Override
public Map<String, String> getRuntimeGenericInformation() {

    if (getTaskInfo() == null) {
        // task is not yet properly initialized
        return new HashMap<>();
    }

    HashMap<String, String> gInfo = new HashMap<>();
    Map<String, String> jobGenericInfo = internalJob.getRuntimeGenericInformation();
    if (jobGenericInfo != null) {
        gInfo.putAll(jobGenericInfo);
    }

    if (genericInformation != null) {
        Map<String, String> updatedTaskGenericInfo = applyReplacementsOnGenericInformation(genericInformation,
                getRuntimeVariables());
        gInfo.putAll(updatedTaskGenericInfo);
    }

    return gInfo;
}

From source file:azkaban.webapp.servlet.ExecutorServlet.java

private void ajaxFetchExecutableFlowUpdate(HttpServletRequest req, HttpServletResponse resp,
        HashMap<String, Object> ret, User user, ExecutableFlow exFlow) throws ServletException {
    Long lastUpdateTime = Long.parseLong(getParam(req, "lastUpdateTime"));
    System.out.println("Fetching " + exFlow.getExecutionId());

    Project project = getProjectAjaxByPermission(ret, exFlow.getProjectId(), user, Type.READ);
    if (project == null) {
        return;/*  w w w  .  j a  v  a  2s.  c o m*/
    }

    Map<String, Object> map = getExecutableFlowUpdateInfo(exFlow, lastUpdateTime);
    map.put("status", exFlow.getStatus());
    map.put("startTime", exFlow.getStartTime());
    map.put("endTime", exFlow.getEndTime());
    map.put("updateTime", exFlow.getUpdateTime());
    ret.putAll(map);
}

From source file:org.lansir.beautifulgirls.proxy.ProxyInvocationHandler.java

/**
 * AkApiParams to hashmap, filter out of null-value
 *
 * @param annosArr Method's params' annotation array[][]
 * @param args Method's params' values//w w  w .ja v a2 s .co m
 * @param filesToSend
 * @return HashMap all (paramName -> paramValue)
 */
private HashMap<String, String> getRawApiParams2HashMap(Annotation[][] annosArr, Object[] args,
        HashMap<String, File> filesToSend, HashMap<String, String> paramsMapOri) {
    HashMap<String, String> paramsMap = new HashMap<String, String>();
    for (int idx = 0; idx < args.length; idx++) {
        String paramName = null;
        String encode = "none";
        for (Annotation a : annosArr[idx]) {
            if (AkParam.class.equals(a.annotationType())) {
                AkParam ap = (AkParam) a;
                paramName = ap.value();
                encode = ap.encode();
            }
        }
        if (paramName != null) {
            Object arg = args[idx];
            if (arg != null) { // filter out of null-value param
                if (encode != null && !"none".equals(encode)) {
                    try {
                        paramsMap.put(paramName, URLEncoder.encode(arg.toString(), encode));
                    } catch (UnsupportedEncodingException e) {
                        Log.w(TAG, "UnsupportedEncodingException:" + encode);
                        paramsMap.put(paramName, arg.toString());
                    }
                    paramsMapOri.put(paramName, arg.toString());
                } else if ("$paramMap".equals(paramName)) {
                    Map<String, String> paramMap = (Map<String, String>) arg;
                    paramsMap.putAll(paramMap);
                    paramsMapOri.putAll(paramMap);
                } else if ("$filesToSend".equals(paramName)) {
                    if (arg instanceof Map) {
                        Map<String, File> files = (Map<String, File>) arg;
                        filesToSend.putAll(files);
                    }
                } else {
                    paramsMap.put(paramName, arg.toString());
                    paramsMapOri.put(paramName, arg.toString());
                }
            }
        }
    }
    return paramsMap;
}

From source file:org.hermes.android.NotificationsController.java

public void showWearNotifications(boolean notifyAboutLast) {
    if (Build.VERSION.SDK_INT < 19) {
        return;//w  w w .  j a v  a2s . com
    }
    ArrayList<Long> sortedDialogs = new ArrayList<>();
    HashMap<Long, ArrayList<MessageObject>> messagesByDialogs = new HashMap<>();
    for (MessageObject messageObject : pushMessages) {
        long dialog_id = messageObject.getDialogId();
        if ((int) dialog_id == 0) {
            continue;
        }

        ArrayList<MessageObject> arrayList = messagesByDialogs.get(dialog_id);
        if (arrayList == null) {
            arrayList = new ArrayList<>();
            messagesByDialogs.put(dialog_id, arrayList);
            sortedDialogs.add(0, dialog_id);
        }
        arrayList.add(messageObject);
    }

    HashMap<Long, Integer> oldIds = new HashMap<>();
    oldIds.putAll(wearNoticationsIds);
    wearNoticationsIds.clear();

    for (long dialog_id : sortedDialogs) {
        ArrayList<MessageObject> messageObjects = messagesByDialogs.get(dialog_id);
        int max_id = messageObjects.get(0).getId();
        TLRPC.Chat chat = null;
        TLRPC.User user = null;
        String name = null;
        if (dialog_id > 0) {
            user = MessagesController.getInstance().getUser((int) dialog_id);
            if (user == null) {
                continue;
            }
        } else {
            chat = MessagesController.getInstance().getChat(-(int) dialog_id);
            if (chat == null) {
                continue;
            }
        }
        if (chat != null) {
            name = chat.title;
        } else {
            name = ContactsController.formatName(user.first_name, user.last_name);
        }

        Integer notificationId = oldIds.get(dialog_id);
        if (notificationId == null) {
            notificationId = wearNotificationId++;
        } else {
            oldIds.remove(dialog_id);
        }

        Intent replyIntent = new Intent(ApplicationLoader.applicationContext, WearReplyReceiver.class);
        replyIntent.putExtra("dialog_id", dialog_id);
        replyIntent.putExtra("max_id", max_id);
        PendingIntent replyPendingIntent = PendingIntent.getBroadcast(ApplicationLoader.applicationContext,
                notificationId, replyIntent, PendingIntent.FLAG_UPDATE_CURRENT);
        RemoteInput remoteInput = new RemoteInput.Builder(EXTRA_VOICE_REPLY)
                .setLabel(LocaleController.getString("Reply", R.string.Reply)).build();
        String replyToString;
        if (chat != null) {
            replyToString = LocaleController.formatString("ReplyToGroup", R.string.ReplyToGroup, name);
        } else {
            replyToString = LocaleController.formatString("ReplyToUser", R.string.ReplyToUser, name);
        }
        NotificationCompat.Action action = new NotificationCompat.Action.Builder(R.drawable.ic_reply_icon,
                replyToString, replyPendingIntent).addRemoteInput(remoteInput).build();

        String text = "";
        for (MessageObject messageObject : messageObjects) {
            String message = getStringForMessage(messageObject, false);
            if (message == null) {
                continue;
            }
            if (chat != null) {
                message = message.replace(" @ " + name, "");
            } else {
                message = message.replace(name + ": ", "").replace(name + " ", "");
            }
            if (text.length() > 0) {
                text += "\n\n";
            }
            text += message;
        }

        Intent intent = new Intent(ApplicationLoader.applicationContext, LaunchActivity.class);
        intent.setAction("com.tmessages.openchat" + Math.random() + Integer.MAX_VALUE);
        intent.setFlags(32768);
        if (chat != null) {
            intent.putExtra("chatId", chat.id);
        } else if (user != null) {
            intent.putExtra("userId", user.id);
        }
        PendingIntent contentIntent = PendingIntent.getActivity(ApplicationLoader.applicationContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(
                ApplicationLoader.applicationContext).setContentTitle(name)
                        .setSmallIcon(R.drawable.notification).setGroup("messages").setContentText(text)
                        .setGroupSummary(false).setContentIntent(contentIntent)
                        .extend(new NotificationCompat.WearableExtender().addAction(action))
                        .setCategory(NotificationCompat.CATEGORY_MESSAGE);

        if (chat == null && user != null && user.phone != null && user.phone.length() > 0) {
            builder.addPerson("tel:+" + user.phone);
        }

        notificationManager.notify(notificationId, builder.build());
        wearNoticationsIds.put(dialog_id, notificationId);
    }

    for (HashMap.Entry<Long, Integer> entry : oldIds.entrySet()) {
        notificationManager.cancel(entry.getValue());
    }
}