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

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

Introduction

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

Prototype

public static boolean isNotEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is not empty or not null.

Usage

From source file:org.efaps.esjp.accounting.transaction.Create_Base.java

/**
 * Creates the transaction doc for contact.
 *
 * @param _parameter Parameter as passed by the eFaps API
 * @param _map the map//  ww  w.  j  a v  a 2 s  .c  om
 * @param _suffix the suffix
 * @throws EFapsException on error
 */
protected void createTransactionDoc4Contact(final Parameter _parameter, final Map<String, String> _map,
        final String _suffix) throws EFapsException {
    final String[] docLinkOids = _parameter.getParameterValues("docLink_" + _suffix);
    if (ArrayUtils.isNotEmpty(docLinkOids)) {
        for (int i = 0; i < docLinkOids.length; i++) {
            final Instance inst = Instance.get(docLinkOids[i]);
            if (InstanceUtils.isKindOf(inst, CIContacts.ContactAbstract)) {
                if (!_map.containsKey(inst.getOid())) {
                    final Instance docinst = new TransactionDocument().createDoc4Contact(_parameter, inst);
                    _map.put(inst.getOid(), docinst.getOid());
                }
                docLinkOids[i] = _map.get(inst.getOid());
            }
        }
    }
}

From source file:org.executequery.components.TextAreaLogAppender.java

public synchronized void append(final LoggingEvent event) {

    ThreadUtils.invokeLater(new Runnable() {

        @Override//from w w  w . j av  a 2 s.c  o  m
        public void run() {

            String text = null;
            Object message = event.getMessage();
            if (message instanceof String) {

                text = (String) message;
                if (text.length() == 1 && Character.isWhitespace(text.charAt(0))) {

                    return;
                }

            }

            text = layout.format(event);
            newLineMatcher.reset(text);
            text = newLineMatcher.replaceAll(SPACE).trim();

            textArea.append(text);
            textArea.append(Layout.LINE_SEP);

            String[] s = event.getThrowableStrRep();
            if (ArrayUtils.isNotEmpty(s)) {

                for (int i = 0; i < s.length; i++) {

                    textArea.append(s[i]);
                    textArea.append(Layout.LINE_SEP);
                }
            }

            textArea.setCaretPosition(textArea.getText().length());

        }
    });

}

From source file:org.executequery.gui.erd.ErdTable.java

protected void drawTable(Graphics2D g, int offsetX, int offsetY) {

    if (parent == null) {

        return;//from   w  ww . ja va2s .  c  o m
    }

    Font tableNameFont = parent.getTableNameFont();
    Font columnNameFont = parent.getColumnNameFont();

    // set the table value background
    g.setColor(TITLE_BAR_BG_COLOR);
    g.fillRect(offsetX, offsetY, FINAL_WIDTH - 1, TITLE_BAR_HEIGHT);

    // set the table value
    FontMetrics fm = g.getFontMetrics(tableNameFont);
    int lineHeight = fm.getHeight();
    int titleXPosn = (FINAL_WIDTH / 2) - (fm.stringWidth(tableName) / 2) + offsetX;

    g.setColor(Color.BLACK);
    g.setFont(tableNameFont);
    g.drawString(tableName, titleXPosn, lineHeight + offsetY);

    // draw the line separator
    lineHeight = TITLE_BAR_HEIGHT + offsetY - 1;
    g.drawLine(offsetX, lineHeight, offsetX + FINAL_WIDTH - 1, lineHeight);

    // fill the white background
    g.setColor(tableBackground);
    g.fillRect(offsetX, TITLE_BAR_HEIGHT + offsetY, FINAL_WIDTH - 1, FINAL_HEIGHT - TITLE_BAR_HEIGHT - 1);

    // add the column names
    fm = g.getFontMetrics(columnNameFont);
    int heightPlusSep = 1 + TITLE_BAR_HEIGHT + offsetY;
    int leftMargin = 5 + offsetX;

    lineHeight = fm.getHeight();
    g.setColor(Color.BLACK);
    g.setFont(columnNameFont);

    int drawCount = 0;
    String value = null;
    if (ArrayUtils.isNotEmpty(columns)) {

        for (int i = 0; i < columns.length; i++) {
            ColumnData column = columns[i];
            if (displayReferencedKeysOnly && !column.isKey()) {
                continue;
            }

            int y = (((drawCount++) + 1) * lineHeight) + heightPlusSep;
            int x = leftMargin;

            // draw the column value string
            value = column.getColumnName();
            g.drawString(value, x, y);

            // draw the data type and size string
            x = leftMargin + dataTypeOffset;
            value = column.getFormattedDataType();
            g.drawString(value, x, y);

            // draw the key label
            if (column.isKey()) {

                if (column.isPrimaryKey() && column.isForeignKey()) {

                    value = PRIMARY + FOREIGN;

                } else if (column.isPrimaryKey()) {

                    value = PRIMARY;

                } else if (column.isForeignKey()) {

                    value = FOREIGN;
                }

                x = leftMargin + dataTypeOffset + keyLabelOffset;
                g.drawString(value, x, y);
            }

        }

    }

    // draw the rectangle border
    double scale = g.getTransform().getScaleX();

    if (selected && scale != ErdPrintable.PRINT_SCALE) {
        g.setStroke(focusBorderStroke);
        g.setColor(Color.BLUE);
    } else {
        g.setColor(Color.BLACK);
    }

    g.drawRect(offsetX, offsetY, FINAL_WIDTH - 1, FINAL_HEIGHT - 1);
    //    g.setColor(Color.DARK_GRAY);
    //    g.draw3DRect(offsetX, offsetY, FINAL_WIDTH - 2, FINAL_HEIGHT - 2, true);
}

From source file:org.executequery.gui.erd.ErdTable.java

/** <p>Resets all of this component's joins. */
public void resetAllJoins() {

    if (ArrayUtils.isNotEmpty(verticalLeftJoins)) {

        for (int i = 0; i < verticalLeftJoins.length; i++) {
            verticalLeftJoins[i].reset();
            verticalRightJoins[i].reset();
        }//from  w w  w. j  a  v a  2s. co m

    }

    if (ArrayUtils.isNotEmpty(horizontalBottomJoins)) {

        for (int i = 0; i < horizontalBottomJoins.length; i++) {
            horizontalBottomJoins[i].reset();
            horizontalTopJoins[i].reset();
        }

    }

}

From source file:org.geoserver.security.iride.entity.IrideIdentity.java

/**
 * Constructor.<p>/* ww  w  .jav a 2  s  .c  o m*/
 * Builds an <code>IRIDE</code> <code>Digital Identity</code> entity
 * out of the given <code>IRIDE</code> <code>Digital Identity</code> string representation tokens,
 * which are validated with {@link IrideIdentityValidator#validate(String[])}.
 *
 * @see IrideIdentityValidator#validate(String[])
 *
 * @param tokens <code>IRIDE</code> <code>Digital Identity</code> string representation tokens
 * @throws IllegalArgumentException if given tokens array length is not equal to the expected length,
 *         which should be {@link IrideIdentityToken#values()} length
 *         (i.e.: the number of tokens defined in {@link IrideIdentityToken} enum).<br />
 *         {@code null} tokens array is considered of length 0.
 * @throws IrideIdentityTokenizationException if any error occurs during tokenization or validation processes
 */
public IrideIdentity(String... tokens) throws IrideIdentityTokenizationException {
    final IrideIdentityInvalidTokenValue[] invalidTokens = VALIDATOR.validate(tokens);
    if (ArrayUtils.isNotEmpty(invalidTokens)) {
        throw new IrideIdentityInvalidTokensException(invalidTokens);
    }

    this.codFiscale = tokens[IrideIdentityToken.CODICE_FISCALE.getPosition()];
    this.nome = tokens[IrideIdentityToken.NOME.getPosition()];
    this.cognome = tokens[IrideIdentityToken.COGNOME.getPosition()];
    this.idProvider = tokens[IrideIdentityToken.ID_PROVIDER.getPosition()];
    this.timestamp = tokens[IrideIdentityToken.TIMESTAMP.getPosition()];
    this.livelloAutenticazione = Integer
            .valueOf(tokens[IrideIdentityToken.LIVELLO_AUTENTICAZIONE.getPosition()]);
    this.mac = tokens[IrideIdentityToken.MAC.getPosition()];

    this.internalRepresentation = null;
}

From source file:org.geoserver.security.iride.identity.IrideIdentity.java

/**
 * Constructor.<p>/*from  w  w  w.j  av  a  2s .  c o m*/
 * Builds an <code>IRIDE</code> Digital Identity entity
 * out of the given <code>IRIDE</code> Digital Identity string representation tokens,
 * which are validated with {@link IrideIdentityValidator#validate(String[])}.
 *
 * @see IrideIdentityValidator#validate(String[])
 *
 * @param tokens <code>IRIDE</code> Digital Identity string representation tokens
 * @throws IllegalArgumentException if given tokens array length is not equal to the expected length,
 *         which should be {@link IrideIdentityToken#values()} length
 *         (i.e.: the number of tokens defined in {@link IrideIdentityToken} enum).<br />
 *         {@code null} tokens array is considered of length 0.
 * @throws IrideIdentityTokenizationException if any error occurs during tokenization or validation processes
 */
public IrideIdentity(String... tokens) throws IrideIdentityTokenizationException {
    final IrideIdentityInvalidTokenValue[] invalidTokens = VALIDATOR.validate(tokens);
    if (ArrayUtils.isNotEmpty(invalidTokens)) {
        throw new IrideIdentityInvalidTokensException(invalidTokens);
    }

    this.codFiscale = tokens[IrideIdentityToken.CODICE_FISCALE.getPosition()];
    this.nome = tokens[IrideIdentityToken.NOME.getPosition()];
    this.cognome = tokens[IrideIdentityToken.COGNOME.getPosition()];
    this.idProvider = tokens[IrideIdentityToken.ID_PROVIDER.getPosition()];
    this.timestamp = tokens[IrideIdentityToken.TIMESTAMP.getPosition()];
    this.livelloAutenticazione = Integer
            .valueOf(tokens[IrideIdentityToken.LIVELLO_AUTENTICAZIONE.getPosition()]);
    this.mac = tokens[IrideIdentityToken.MAC.getPosition()];

    this.internalRepresentation = null;

    this.formatter = new IrideIdentityFormatter();
}

From source file:org.hippoecm.frontend.util.RequestUtils.java

/**
 * Returns the remote client address or null if remote client address information is unavailable.
 * @param request wicket request// w  ww.  j  a  v  a 2 s. co  m
 * @return the remote client address or null if remote client address information is unavailable
 */
public static String getFarthestRemoteAddr(final Request request) {
    String[] remoteAddrs = getRemoteAddrs(request);

    if (ArrayUtils.isNotEmpty(remoteAddrs)) {
        return remoteAddrs[0];
    }

    return null;
}

From source file:org.ikasan.component.converter.xml.XmlByteArrayToObjectConverter.java

@Override
public void setConfiguration(XmlToObjectConverterConfiguration configuration) {
    this.configuration = configuration;
    marshaller = new Jaxb2Marshaller();
    if (StringUtils.isNotEmpty(configuration.getContextPath())) {
        marshaller.setContextPath(configuration.getContextPath());
    } else if (ArrayUtils.isNotEmpty(configuration.getContextPaths())) {
        marshaller.setContextPaths(configuration.getContextPaths());
    } else if (ArrayUtils.isNotEmpty(configuration.getClassesToBeBound())) {
        marshaller.setClassesToBeBound(configuration.getClassesToBeBound());
    }/*from w ww  .  j a va2  s.  c o m*/
    marshaller.setUnmarshallerProperties(configuration.getUnmarshallerProperties());
    marshaller.setMarshallerProperties(configuration.getMarshallerProperties());
    if (configuration.getValidationEventHandler() != null) {
        marshaller.setValidationEventHandler(configuration.getValidationEventHandler());
    }
    try {
        marshaller.afterPropertiesSet();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
}

From source file:org.ikasan.component.converter.xml.XmlStringToObjectConverter.java

@Override
public void setConfiguration(XmlStringToObjectConfiguration configuration) {
    this.configuration = configuration;
    marshaller = new Jaxb2Marshaller();
    if (StringUtils.isNotEmpty(configuration.getContextPath())) {
        marshaller.setContextPath(configuration.getContextPath());
    } else if (ArrayUtils.isNotEmpty(configuration.getContextPaths())) {
        marshaller.setContextPaths(configuration.getContextPaths());
    } else if (ArrayUtils.isNotEmpty(configuration.getClassesToBeBound())) {
        marshaller.setClassesToBeBound(configuration.getClassesToBeBound());
    }/* w  w  w . j ava2s . c  om*/
    marshaller.setUnmarshallerProperties(configuration.getUnmarshallerProperties());
    marshaller.setMarshallerProperties(configuration.getMarshallerProperties());
    if (configuration.getValidationEventHandler() != null) {
        marshaller.setValidationEventHandler(configuration.getValidationEventHandler());
    }

    try {
        marshaller.afterPropertiesSet();
    } catch (Exception e) {
        throw new ConfigurationException(e.getMessage());
    }
}

From source file:org.kuali.kra.lookup.KraDocSearchCriteriaDTOLookupableHelperServiceImpl.java

/**
 * Modifies the principal names to multicampus format if multicampus mode is on.
 *///from  w w  w  .j a  v  a 2 s.com
protected void addMultiCampusPrincipalName() {
    boolean multiCampusEnabled = getParameterService().getIndicatorParameter(
            Constants.KC_GENERIC_PARAMETER_NAMESPACE, Constants.KC_ALL_PARAMETER_DETAIL_TYPE_CODE,
            Constants.PARAMETER_MULTI_CAMPUS_ENABLED);

    if (multiCampusEnabled) {
        Map<Object, Object> searchParameters = new HashMap<Object, Object>(getParameters());
        String[] principalNameParameter = (String[]) searchParameters.get(PRINCIPAL_NAME_FIELD);
        if (ArrayUtils.isNotEmpty(principalNameParameter)) {
            if (StringUtils.isNotBlank(principalNameParameter[0])) {
                String principalName = principalNameParameter[0];
                String campusCode = (String) GlobalVariables.getUserSession()
                        .retrieveObject(Constants.USER_CAMPUS_CODE_KEY);
                String multiCampusPrincipalName = getMultiCampusIdentityService()
                        .getMultiCampusPrincipalName(principalName, campusCode);
                searchParameters.put(PRINCIPAL_NAME_FIELD, new String[] { multiCampusPrincipalName });
            }
        }
        setParameters(Collections.unmodifiableMap(searchParameters));
    }
}