Example usage for org.apache.commons.lang ArrayUtils toString

List of usage examples for org.apache.commons.lang ArrayUtils toString

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils toString.

Prototype

public static String toString(Object array) 

Source Link

Document

Outputs an array as a String, treating null as an empty array.

Usage

From source file:org.diffkit.util.DKSqlUtil.java

public static long executeBatchUpdate(List<String> sqlUpdateStrings_, Connection connection_) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("sqlUpdateStrings_: " + sqlUpdateStrings_.size());
        LOG.debug("connection_: " + connection_);
    }/*from   w  w  w  . ja  va 2s  .c  o m*/
    DKValidate.notNull(connection_);
    if ((sqlUpdateStrings_ == null) || (sqlUpdateStrings_.size() == 0))
        return 0;

    Statement statement = null;
    int[] rowCounts = null;
    try {
        statement = connection_.createStatement();
        for (String sqlUpdate : sqlUpdateStrings_)
            statement.addBatch(sqlUpdate);

        rowCounts = statement.executeBatch();
        if (LOG.isDebugEnabled())
            LOG.debug("effectedRowCount: " + ArrayUtils.toString(rowCounts));

    } catch (Exception e_) {
        LOG.warn(null, e_);
        if (DKObjectUtil.respondsTo(e_, "getNextException", null)) {
            try {
                Exception nextException = (Exception) DKObjectUtil.invoke(e_, "getNextException", null);
                LOG.warn(null, nextException);
            } catch (Exception f_) {
                LOG.error(null, f_);
            }
        }
        rollback(connection_);
    } finally {
        close(statement);
    }

    return DKArrayUtil.sum(rowCounts);
}

From source file:org.displaytag.exception.MissingAttributeException.java

/**
 * Constructor for MissingAttributeException.
 * @param source Class where the exception is generated
 * @param attributeNames String attribute name
 *///w  w w.j  av  a  2  s.c om
public MissingAttributeException(Class source, String[] attributeNames) {
    super(source, Messages.getString("MissingAttributeException.msg", //$NON-NLS-1$
            new Object[] { ArrayUtils.toString(attributeNames) }));

    // copy attributes to allow them to be retrieved using getAttributeNames()
    this.attributes = (String[]) ArrayUtils.clone(attributeNames);
}

From source file:org.displaytag.export.ExportViewFactory.java

/**
 * Private constructor.//  w  w w. j  a v a  2 s . c o  m
 */
private ExportViewFactory() {
    TableProperties properties = TableProperties.getInstance(null);
    String[] exportTypes = properties.getExportTypes();

    if (log.isInfoEnabled()) {
        log.info(Messages.getString("ExportViewFactory.initializing", //$NON-NLS-1$
                new Object[] { ArrayUtils.toString(exportTypes) }));
    }
    for (int j = 0; j < exportTypes.length; j++) {
        String className = properties.getExportClass(exportTypes[j]);
        registerExportView(exportTypes[j], className);
    }
}

From source file:org.docx4j.model.datastorage.RemovalHandler.java

/**
 * Removes Structured Document Tags from a document part, preserving their
 * contents.//from   w ww.  j  a v  a 2  s.  c  o m
 *
 * In case key "empty" is specified, value bindings (xpath) are removed only
 * if they have void contents (e.g. the XML points nowhere).
 *
 * @param part
 *            The document part to modify (in situ).
 * @param quantifier
 *            The quantifier regarding which kinds of parts are to be
 *            removed.
 * @param keys
 *            In case of {@link Quantifier#NAMED}, quantifier names. All
 *            strings expect "xpath", "condition", "repeat", "empty" are
 *            ignored.
 * @throws Docx4JException
 *             In case any transformation error occurs.
 */
public void removeSDTs(final JaxbXmlPart<? extends Object> part, final Quantifier quantifier,
        final String... keys) throws Docx4JException {

    final Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("all", quantifier == ALL);
    if (quantifier == NAMED)
        parameters.put("types", ArrayUtils.toString(keys));

    final Document partDOM = marshaltoW3CDomDocument(part.getJaxbElement());
    final JAXBResult result = prepareJAXBResult(Context.jc);

    transform(partDOM, removalTemplate, parameters, result);

    try {
        part.setJaxbElement(result);

    } catch (JAXBException e) {
        throw new Docx4JException("Error unmarshalling document part for SDT removal", e);
    }
}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>/*from   w w  w.j av  a  2 s.  c  o m*/
 * Creates a {@link CollectionLiteralExp}.
 * </p>
 * 
 * @param kind
 *          The {@link CollectionKind} of the {@link CollectionLiteralExp} .
 * @param parts
 *          The {@link CollectionLiteralPart}s of the
 *          {@link CollectionLiteralExp}.
 * @return A {@link CollectionLiteralExp} instance.
 */
public CollectionLiteralExp createCollectionLiteralExp(CollectionKind kind, Type elementType,
        CollectionLiteralPart... parts) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createCollectionLiteralExp(kind=" + kind + ", parts=" //$NON-NLS-1$ //$NON-NLS-2$
                + ArrayUtils.toString(parts) + ") - enter"); //$NON-NLS-1$
    }

    // check parameters
    if (kind == null || parts == null) {
        throw new IllegalArgumentException(
                "Parameters must not be null: kind=" + kind + ", parts=" + parts + "."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    CollectionLiteralExp collectionLiteralExp;

    collectionLiteralExp = ExpressionsFactory.INSTANCE.createCollectionLiteralExp();
    collectionLiteralExp.setKind(kind);
    collectionLiteralExp.setElementType(elementType);
    collectionLiteralExp.getPart().addAll(Arrays.asList(parts));

    // set the reference to the OCL Library
    collectionLiteralExp.setOclLibrary(oclLibrary);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createCollectionLiteralExp() - exit - return value=" //$NON-NLS-1$
                + collectionLiteralExp);
    }

    return collectionLiteralExp;
}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>/* ww w.j  av  a 2s .  c o m*/
 * Creates a new {@link Constraint}. The name is optional. but the other
 * parameters need to have valid values.
 * </p>
 * 
 * @param name
 *          An optional name for the {@link Constraint}.
 * @param kind
 *          One of the constants defined in {@link ConstraintKind}.
 * @param specification
 *          The {@link Expression} that specifies the {@link Constraint}.
 * @param constrainedElement
 *          At least one element that is the target of the {@link Constraint}.
 * 
 * @return A {@link Constraint} instance.
 */
public Constraint createConstraint(String name, ConstraintKind kind, Expression specification,
        Feature definedFeature, ConstrainableElement... constrainedElement) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createConstraint(name=" + name + ", kind=" + kind //$NON-NLS-1$ //$NON-NLS-2$
                + ", specification=" + specification + ", constrainedElement=" //$NON-NLS-1$//$NON-NLS-2$
                + ArrayUtils.toString(constrainedElement) + ") - enter"); //$NON-NLS-1$
    }

    if (kind == null || specification == null || constrainedElement == null) {
        throw new NullArgumentException("kind or specification or constrainedElement"); //$NON-NLS-1$
    }

    Constraint constraint = PivotModelFactory.eINSTANCE.createConstraint();

    constraint.setName(name);
    constraint.setKind(kind);
    constraint.setSpecification(specification);
    constraint.setDefinedFeature(definedFeature);
    constraint.getConstrainedElement().addAll(Arrays.asList(constrainedElement));

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createConstraint() - exit - return value=" + constraint); //$NON-NLS-1$
    }

    return constraint;

}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>//from ww  w  . ja  v  a  2  s .c  o m
 * Creates a new {@link ExpressionInOcl}. The body expression and the context
 * variable must not be <code>null</code>. The result and parameter variables
 * are optional since they are only required for constraints whose context is
 * an operation.
 * </p>
 * 
 * @param body
 *          The body expression as a {@link String} in OCL concrete syntax.
 * @param bodyExpression
 *          The {@link OclExpression} that is the body of the
 *          {@link ExpressionInOcl}.
 * @param context
 *          The {@link Variable} representing the contextual classifier.
 * @param result
 *          The result {@link Variable} of an operation {@link Constraint} .
 * @param parameter
 *          The parameters of an operation {@link Constraint}.
 * 
 * @return An {@link ExpressionInOcl} instance.
 */
public ExpressionInOcl createExpressionInOcl(String body, OclExpression bodyExpression, Variable context,
        Variable result, Variable... parameter) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createExpressionInOcl(bodyExpression=" + bodyExpression //$NON-NLS-1$
                + ", context=" + context + ", result=" + result + ", parameter=" //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
                + ArrayUtils.toString(parameter) + ") - enter"); //$NON-NLS-1$
    }

    if (bodyExpression == null || context == null) {
        throw new NullArgumentException("bodyExpression or context"); //$NON-NLS-1$
    }

    ExpressionInOcl expressionInOcl;

    expressionInOcl = ExpressionsFactory.INSTANCE.createExpressionInOcl();
    expressionInOcl.setBodyExpression(bodyExpression);
    expressionInOcl.setContext(context);

    if (StringUtils.isNotEmpty(body)) {
        expressionInOcl.setBody(body.replaceAll("\r\n|\r|\n", " "));
    }

    if (result != null) {
        expressionInOcl.setResult(result);
    }

    if (parameter != null) {
        expressionInOcl.getParameter().addAll(Arrays.asList(parameter));
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createExpressionInOcl() - exit - return value=" //$NON-NLS-1$
                + expressionInOcl);
    }

    return expressionInOcl;
}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>//from w w w  .ja  va  2  s  . co  m
 * Creates a new {@link IterateExp}.
 * </p>
 * 
 * @param source
 *          The source {@link OclExpression}.
 * @param name
 *          The name of the {@link IterateExp}.
 * @param body
 *          The body {@link OclExpression} of the {@link IterateExp}.
 * @param result
 *          The result {@link Variable}.
 * @param iterator
 *          The optional iterator {@link Variable}s as an array.
 * @return The {@link IterateExp} instance.
 */
public IterateExp createIterateExp(OclExpression source, OclExpression body, Variable result,
        Variable... iterator) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createIterateExp(source=" + source + ", body=" + body //$NON-NLS-1$ //$NON-NLS-2$
                + ", result=" + result + ", iterator=" //$NON-NLS-1$//$NON-NLS-2$
                + ArrayUtils.toString(iterator) + ") - enter"); //$NON-NLS-1$
    }

    if (source == null || body == null || result == null) {
        throw new NullArgumentException("source or body or result"); //$NON-NLS-1$
    }

    IterateExp iterateExp = ExpressionsFactory.INSTANCE.createIterateExp();

    iterateExp.setSource(source);
    iterateExp.setBody(body);
    iterateExp.setResult(result);

    if (iterator != null) {
        iterateExp.getIterator().addAll(Arrays.asList(iterator));
    }

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createIterateExp() - exit - return value=" + iterateExp); //$NON-NLS-1$
    }

    return iterateExp;
}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>// w ww.  j  a v a2 s .co  m
 * Creates a new {@link IteratorExp}.
 * </p>
 * 
 * @param source
 *          The source {@link OclExpression}.
 * @param name
 *          The name of the {@link IteratorExp}.
 * @param body
 *          The body {@link OclExpression}.
 * @param iterator
 *          The iterator {@link Variable}s as an array.
 * 
 * @return A {@link IteratorExp} instance.
 */
public IteratorExp createIteratorExp(OclExpression source, String name, OclExpression body,
        Variable... iterator) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createIteratorExp(source=" + source + ", name=" + name //$NON-NLS-1$ //$NON-NLS-2$
                + ", body=" + body + ", iterator=" + ArrayUtils.toString(iterator) //$NON-NLS-1$//$NON-NLS-2$
                + ") - enter"); //$NON-NLS-1$
    }

    if (source == null || StringUtils.isEmpty(name) || body == null) {
        throw new IllegalArgumentException("Parameters must not be null or empty: source=" + source //$NON-NLS-1$
                + ", name=" + name + ", body=" + body + "."); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
    }

    IteratorExp iteratorExp = ExpressionsFactory.INSTANCE.createIteratorExp();

    iteratorExp.setSource(source);
    iteratorExp.setName(name);
    iteratorExp.setBody(body);

    if (iterator != null) {
        iteratorExp.getIterator().addAll(Arrays.asList(iterator));
    }

    // set the reference to the OCL library
    iteratorExp.setOclLibrary(oclLibrary);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createIteratorExp() - exit - return value=" + iteratorExp); //$NON-NLS-1$
    }

    return iteratorExp;
}

From source file:org.dresdenocl.essentialocl.expressions.factory.EssentialOclFactory.java

/**
 * <p>/*from   w  w w. j a v a2s. c  o  m*/
 * Creates a new {@link OperationCallExp}.
 * </p>
 * 
 * @param source
 *          The source {@link OclExpression} of the {@link OperationCallExp}.
 * @param referredOperationName
 *          The fully qualified name of the operation (i.e., including the
 *          fully qualified name of its owning {@link Type}).
 * @param argument
 *          An optional list of arguments as {@link OclExpression}s.
 * 
 * @return The created {@link OperationCallExp}.
 */
public OperationCallExp createOperationCallExp(OclExpression source, String referredOperationName,
        OclExpression... argument) {

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createOperationCallExp(source=" + source //$NON-NLS-1$
                + ", referredOperationName=" + referredOperationName + ", argument=" //$NON-NLS-1$ //$NON-NLS-2$
                + ArrayUtils.toString(argument) + ") - enter"); //$NON-NLS-1$
    }

    if (source == null || StringUtils.isEmpty(referredOperationName)) {
        throw new IllegalArgumentException("Parameters must not be null or empty: source=" + source //$NON-NLS-1$
                + ", referredOperationName=" + referredOperationName + ","); //$NON-NLS-1$ //$NON-NLS-2$
    }

    // collect the parameter types
    List<Type> paramTypes = new ArrayList<Type>();

    if (argument != null) {
        for (int i = 0; i < argument.length; i++) {
            paramTypes.add(argument[i].getType());
        }
    }

    // lookup the operation
    Type sourceType = source.getType();
    Operation operation = sourceType.lookupOperation(referredOperationName, paramTypes);

    if (operation == null) {
        StringBuilder paramTypeNames = new StringBuilder();
        if (paramTypes.size() == 0)
            paramTypeNames.append(" with no argument");
        if (paramTypes.size() == 1)
            paramTypeNames.append(" with argument type ");
        if (paramTypes.size() > 1)
            paramTypeNames.append(" with argument types ");
        for (int i = 0; i < paramTypes.size(); i++) {
            Type paramType = paramTypes.get(i);
            if (i > 0)
                paramTypeNames.append(", ");
            paramTypeNames.append("'");
            paramTypeNames.append(paramType.getName());
            paramTypeNames.append("'");
        }
        throw new IllegalArgumentException("Unable to find operation '" + referredOperationName //$NON-NLS-1$
                + "'" + paramTypeNames + " in type '" //$NON-NLS-1$ //$NON-NLS-2$
                + source.getType().getQualifiedName() + "'."); //$NON-NLS-1$
    }

    OperationCallExp operationCallExp = ExpressionsFactory.INSTANCE.createOperationCallExp();
    operationCallExp.setSource(source);
    operationCallExp.setReferredOperation(operation);

    if (argument != null) {
        operationCallExp.getArgument().addAll(Arrays.asList(argument));
    }

    // a property call expression needs access to the OCL library
    operationCallExp.setOclLibrary(oclLibrary);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("createOperationCallExp() - exit - return value=" + operationCallExp); //$NON-NLS-1$
    }

    return operationCallExp;
}