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

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

Introduction

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

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:jef.tools.string.StringSpliter.java

/**
 * ??Key????/*from www. j a v  a  2 s . c  om*/
 * @param chars
 * @return
 */
public boolean expandKeyRightUntil(char[] chars) {
    boolean res = false;
    if (keyword == null)
        return res;
    Substring right = getRight();
    while (right.firstCharacter() != null && !ArrayUtils.contains(chars, right.firstCharacter().charValue())) {
        right.setStart(right.getStart() + 1);
        res = true;
    }
    if (res)
        this.keyword = source.subAbsoultOffset(keyword.getStart(), right.getStart());
    return res;
}

From source file:gda.device.scannable.CoupledScannable.java

/**
 * @param newScannableName/*from   w ww  .j  a v a  2  s.co m*/
 *            The Scannable name to add.
 */
public void addScannableName(String newScannableName) {
    if (!ArrayUtils.contains(scannableNames, newScannableName)) {
        scannableNames = (String[]) ArrayUtils.add(scannableNames, newScannableName);
    }
}

From source file:jef.tools.string.RegexpUtils.java

/**
 * ??/*from   www .ja v a2s .  com*/
 * @param key
 * @param sTARQUESTION
 * @return
 */
public static String escapeRegChars(String key, char[] keeps) {
    for (char c : REGEXP_KEY_CHARS) {
        if (!ArrayUtils.contains(keeps, c)) {
            key = key.replace(String.valueOf(c), "\\" + c);
        }
    }
    return key;
}

From source file:mitm.application.djigzo.james.mailets.BlackberrySMIMEAdapter.java

private Part findAttachment(MimeMessage containerMessage)
        throws MessagingException, IOException, PartException {
    final MutableObject smimePart = new MutableObject();
    final MutableObject octetPart = new MutableObject();

    PartListener partListener = new PartScanner.PartListener() {
        @Override//ww w. j  ava  2s.  co m
        public boolean onPart(Part parent, Part part, Object context) throws PartException {
            try {
                if (ArrayUtils.contains(part.getHeader(DjigzoHeader.MARKER),
                        DjigzoHeader.ATTACHMENT_MARKER_VALUE)) {
                    smimePart.setValue(part);

                    /*
                     * we found the part with the marker so we can stop scanning
                     */
                    return false;
                }

                /*
                 * Fallback scanning for octet-stream in case the template does not contain a DjigzoHeader.MARKER
                 */
                if (part.isMimeType("application/octet-stream")) {
                    octetPart.setValue(part);
                }

                return true;
            } catch (MessagingException e) {
                throw new PartException(e);
            }
        }
    };

    PartScanner partScanner = new PartScanner(partListener, MAX_DEPTH);

    partScanner.scanPart(containerMessage);

    Part result = (Part) smimePart.getValue();

    if (result == null) {
        result = (Part) octetPart.getValue();

        if (result != null) {
            logger.debug("Marker not found. Using octet-stream instead.");
        } else {
            throw new MessagingException("Unable to find the attachment part in the template.");
        }
    }

    return result;
}

From source file:com.dc.tes.License.java

private static String Lisence(Core core, String license) {
    // ??//from   w w w.j  a va  2s . c o  m
    boolean[] adapterFlag = new boolean[C_ADAPTER_LIST_SIZE];
    // ?
    Date[] adapterDate = new Date[C_ADAPTER_LIST_SIZE];
    // 
    Date tesDate;
    // ??
    int adapterNum;

    try {
        // ?License
        //String license = RuntimeUtils.ReadResource("license.dat", RuntimeUtils.utf8);
        byte[] _enData = new BASE64Decoder().decodeBuffer(license);

        byte[] _buffer = new byte[_enData.length - 8];
        System.arraycopy(_enData, 0, _buffer, 0, _enData.length - 8);

        license = new String(decrypt(_buffer, "nuclearg".getBytes()));

        String[] segments = StringUtils.split(license, "\r");
        for (int i = 0; i < C_ADAPTER_LIST_SIZE; i++)
            adapterFlag[i] = segments[0].charAt(i) == '1';

        String[] _adapterDate = segments[1].split("\\|");
        for (int i = 0; i < C_ADAPTER_LIST_SIZE; i++)
            if (adapterFlag[i])
                adapterDate[i] = _adapterDate[i + 1].equals("00000000") ? null
                        : new SimpleDateFormat("yyyyMMdd").parse(_adapterDate[i + 1]);

        tesDate = segments[2].equals("00000000") ? null : new SimpleDateFormat("yyyyMMdd").parse(segments[2]);

        adapterNum = Integer.parseInt(segments[3]);
    } catch (Exception ex) {
        throw new LicenseException("?License", ex);
    }

    if (tesDate != null && new Date().after(tesDate))
        throw new LicenseException("");

    int count = 0;
    StringBuffer buffer = new StringBuffer();

    List<String> disabledChannelNames = new ArrayList<String>();
    for (String name : core.channels.getChannelNames())
        if (core.channels.getChannel(name) instanceof IAdapterChannel) {
            count++;
            Class<? extends IChannel> cls = core.channels.getChannel(name).getClass();

            String pName = core.channels.getChannel(name).getClass().getPackage().getName();
            pName = pName.substring(pName.lastIndexOf('.') + 1);
            int id = pName.hashCode() & 0x7fffffff % 64;
            if (ArrayUtils.contains(cls.getInterfaces(), IListenerChannel.class))
                id += 64;

            if (!adapterFlag[id] || (adapterDate[id] != null && new Date().after(adapterDate[id])))
                disabledChannelNames.add(name);
        }

    if (adapterNum > 0 && count > adapterNum)
        throw new LicenseException("??license?");

    for (String disabledChannel : disabledChannelNames) {
        buffer.append("License?" + disabledChannel + "??")
                .append(SystemUtils.LINE_SEPARATOR);
        core.channels.getChannelNames().remove(disabledChannel);
    }

    return buffer.toString();
}

From source file:com.atolcd.pentaho.di.trans.steps.gisrelate.GisRelateMeta.java

public void getFields(RowMetaInterface r, String origin, RowMetaInterface[] info, StepMeta nextStep,
        VariableSpace space) {//from  w  w  w .  j a v a2s  . com

    if (ArrayUtils.contains(numericResultOperators, operator)) {
        ValueMetaInterface valueMeta = new ValueMeta(outputFieldName, ValueMeta.TYPE_NUMBER);
        valueMeta.setOrigin(origin);
        r.addValueMeta(valueMeta);
    }

    if (ArrayUtils.contains(boolResultOperators, operator)) {

        if (returnType.equalsIgnoreCase("ALL")) {
            ValueMetaInterface valueMeta = new ValueMeta(outputFieldName, ValueMeta.TYPE_BOOLEAN);
            valueMeta.setOrigin(origin);
            r.addValueMeta(valueMeta);
        }
    }

}

From source file:jp.primecloud.auto.process.nifty.NiftyProcessClient.java

public RunningInstancesItemType waitInstance(String instanceId) {
    // ???//ww w .ja v  a  2  s.  c om
    String[] stableStatus = new String[] { "running", "stopped" };
    // TODO: API??? warning ?API??????
    String[] unstableStatus = new String[] { "pending", "warning" };// 

    RunningInstancesItemType instance;
    while (true) {
        instance = describeInstance(instanceId);
        String status = instance.getInstanceState().getName();

        if (ArrayUtils.contains(stableStatus, status)) {
            break;
        }

        if (!ArrayUtils.contains(unstableStatus, status)) {
            // ???
            AutoException exception = new AutoException("EPROCESS-000604", instanceId, status);
            exception.addDetailInfo("result=" + ReflectionToStringBuilder.toString(instance));
            throw exception;
        }
    }

    return instance;
}

From source file:br.gov.frameworkdemoiselle.tools.nimble.eclipse.NimbleRunner.java

@Override
/**// w ww.  j  a  v a  2 s.com
 * This method is here to refresh the fresh project in the workspace as soon as maven has finished creating it.
 *
 * @param events An array of debug events. We are looking for a <code>DebugEvent#TERMINATE</code> event.
 */
public void handleDebugEvents(DebugEvent[] events) {
    for (int i = 0; i < events.length; i++) {
        DebugEvent event = events[i];
        if (ArrayUtils.contains(getProcesses(), event.getSource())) {
            if (event.getKind() == DebugEvent.TERMINATE) {
                System.out.println("Closing Demoiselle Nimble " + new Date());
                DebugPlugin.getDefault().removeDebugEventListener(this);
                try {
                    verifyWorkspace();
                    EclipseUtil.refreshWorkspace();
                } catch (CoreException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}

From source file:com.athena.chameleon.engine.threadpool.task.FileEncodingConvertTask.java

@Override
protected void taskRun() {
    OutputStreamWriter output = null;
    InputStream input = null;//from w w  w .jav  a2s  . co  m

    try {
        input = new FileInputStream(file);
        byte[] data = IOUtils.toByteArray(input, file.length());
        IOUtils.closeQuietly(input);

        /*
         * CharsetDector ? ? ?? ?.
         * 
         * UTF-8, UTF-16BE, UTF-16LE, UTF-32BE, UTF-32LE, Shift_JIS, ISO-2022-JP, 
         * ISO-2022-CN, ISO-2022-KR, GB18030, EUC-JP, EUC-KR, Big5, ISO-8859-1, 
         * ISO-8859-2, ISO-8859-5, ISO-8859-6, ISO-8859-7, ISO-8859-8, windows-1251, 
         * windows-1256, KOI8-R, ISO-8859-9, IBM424_rtl, IBM424_ltr, IBM420_rtl, IBM420_ltr
         */
        // ? ? defaultEncoding    ? 
        // new CharsetDetector().getString(data, defaultEncoding);  ?? ? ? ? 
        // ?? null  ?? ?.
        //String fileContents = new CharsetDetector().getString(data, defaultEncoding);

        String fileContents = null;
        com.ibm.icu.text.CharsetMatch cm = null;

        try {
            CharsetDetector detector = new CharsetDetector();
            detector.setDeclaredEncoding(defaultEncoding);
            detector.setText(data);
            cm = detector.detect();

            fileContents = cm.getString();

            //logger.debug("Encoding => {}" + cm.getName());
            //logger.debug("Contents => {}" + cm.getString());
        } catch (Exception e) {
            // Ignore...
        }

        if (fileContents != null) {
            // html, jsp, xml ?? ? Character Set  ?? ???  UTF-8 
            // charset=EUC-KR, encoding="EUC-KR"    EUC-KR, ISO-8859-1  
            //    SEARCH_CHAR_SET? 
            if (ArrayUtils.contains(TARGET_SUFFIX, extension)) {
                fileContents = replace(fileContents);
            }

            output = new OutputStreamWriter(new FileOutputStream(file), defaultEncoding);
            output.write(fileContents);
            IOUtils.closeQuietly(output);
        }
    } catch (UnsupportedEncodingException e) {
        logger.error("UnsupportedEncodingException has occurred : ", e);
    } catch (FileNotFoundException e) {
        logger.error("FileNotFoundException has occurred : ", e);
    } catch (IOException e) {
        logger.error("IOException has occurred : ", e);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.manydesigns.elements.fields.TextField.java

protected void valueToXhtmlView(XhtmlBuffer xb) {
    xb.openElement("div");
    String cssClass = "value";
    if (ArrayUtils.contains(red, stringValue)) {
        cssClass += " status_red";
    } else if (ArrayUtils.contains(amber, stringValue)) {
        cssClass += " status_amber";
    } else if (ArrayUtils.contains(green, stringValue)) {
        cssClass += " status_green";
    }// w  w w  .j  a  v  a 2s.c o m
    xb.addAttribute("class", cssClass);
    xb.addAttribute("id", id);
    String escapedText = getDisplayValue();
    if (href != null) {
        xb.openElement("a");
        xb.addAttribute("href", href);
        xb.addAttribute("alt", title);
    }
    xb.writeNoHtmlEscape(escapedText);
    if (href != null) {
        xb.closeElement("a");
    }
    xb.closeElement("div");
}