Example usage for org.apache.commons.collections OrderedMap get

List of usage examples for org.apache.commons.collections OrderedMap get

Introduction

In this page you can find the example usage for org.apache.commons.collections OrderedMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:edu.harvard.iq.dvn.core.web.StudyListing.java

public static StudyListing getStudyListingFromMap(String slIndex, Map sessionMap, Long currentVdcId) {
    OrderedMap slMap = (OrderedMap) sessionMap.get("studyListings");
    if (slMap != null) {
        StudyListing sl = (StudyListing) slMap.get(slIndex);

        if (sl != null) {

            // make sure the user is in the current vdc for this study listing
            //Long currentVdcId = getVDCRequestBean().getCurrentVDCId();
            if (currentVdcId == null) {
                if (sl.getVdcId() != null) {
                    sl = new StudyListing(StudyListing.INCORRECT_VDC);
                }//from   w w w.  j  ava 2s .  c o m
            } else {
                if (!currentVdcId.equals(sl.getVdcId())) {
                    sl = new StudyListing(StudyListing.INCORRECT_VDC);
                }
            }

            return sl;
        }
    }

    // this means that this studyListing or the session has expired
    return new StudyListing(StudyListing.EXPIRED_LIST);
}

From source file:org.diffkit.diff.custom.DKCustomTableComparison.java

/**
 * @param lhs_/*from  ww w  .  ja  va 2  s  .  co  m*/
 *           row
 * @param rhs_
 *           row
 * @return OrderedMap ordered, as best as possible, according to
 *         _displayIndexes. keys are String; values are String
 */
@SuppressWarnings("unchecked")
public OrderedMap getRowDisplayValues(Object[] lhs_, Object[] rhs_) {

    OrderedMap lhDisplayValues = this.getRowDisplayValues(lhs_, DKSide.LEFT_INDEX);
    OrderedMap rhDisplayValues = this.getRowDisplayValues(rhs_, DKSide.RIGHT_INDEX);
    if (_log.isDebugEnabled()) {
        _log.debug("lhDisplayValues->{}", lhDisplayValues);
        _log.debug("rhDisplayValues->{}", rhDisplayValues);
    }
    MapIterator lhIterator = lhDisplayValues.orderedMapIterator();
    MapIterator rhIterator = rhDisplayValues.orderedMapIterator();
    OrderedMap result = new LinkedMap();
    while (true) {
        boolean lhHasNext = lhIterator.hasNext();
        boolean rhHasNext = rhIterator.hasNext();
        if ((!lhHasNext) && (!rhHasNext))
            break;
        String lhKey = (lhHasNext ? (String) lhIterator.next() : null);
        String rhKey = (rhHasNext ? (String) rhIterator.next() : null);

        result.put(lhKey, lhDisplayValues.get(lhKey));
        result.put(rhKey, rhDisplayValues.get(rhKey));
    }
    return result;
}

From source file:org.diffkit.diff.engine.DKStandardTableComparison.java

/**
 * @param lhs_/*  w  w  w  .  j  a  va 2s  .  c o  m*/
 *           row
 * @param rhs_
 *           row
 * @return OrderedMap ordered, as best as possible, according to
 *         _displayIndexes. keys are String; values are String
 */
@SuppressWarnings("unchecked")
public OrderedMap getRowDisplayValues(Object[] lhs_, Object[] rhs_) {

    OrderedMap lhDisplayValues = this.getRowDisplayValues(lhs_, DKSide.LEFT_INDEX);
    OrderedMap rhDisplayValues = this.getRowDisplayValues(rhs_, DKSide.RIGHT_INDEX);
    if (_log.isDebugEnabled()) {
        _log.debug("lhDisplayValues->{}", lhDisplayValues);
        _log.debug("rhDisplayValues->{}", rhDisplayValues);
    }
    MapIterator lhIterator = lhDisplayValues.orderedMapIterator();
    MapIterator rhIterator = rhDisplayValues.orderedMapIterator();
    OrderedMap result = new LinkedMap();
    while (true) {
        boolean lhHasNext = lhIterator.hasNext();
        boolean rhHasNext = rhIterator.hasNext();
        if ((!lhHasNext) && (!rhHasNext))
            break;
        String lhKey = (lhHasNext ? (String) lhIterator.next() : null);
        String rhKey = (rhHasNext ? (String) rhIterator.next() : null);
        if (lhKey == null) {
            result.put(rhKey, ":" + rhDisplayValues.get(rhKey));
        } else if (rhKey == null) {
            result.put(lhKey, lhDisplayValues.get(lhKey) + ":");
        } else if (lhKey.equals(rhKey)) {
            String lhValue = (String) lhDisplayValues.get(lhKey);
            String rhValue = (String) rhDisplayValues.get(rhKey);
            String displayValue = (lhValue.equals(rhValue) ? lhValue : (lhValue + ":" + rhValue));
            result.put(lhKey, displayValue);
        } else {
            if (!result.containsKey(lhKey))
                result.put(lhKey, (String) lhDisplayValues.get(lhKey) + ":");
            else {
                String rhValue = (String) result.get(lhKey);
                result.put(lhKey, (String) lhDisplayValues.get(lhKey) + rhValue);
            }
            if (!result.containsKey(rhKey))
                result.put(rhKey, ":" + (String) rhDisplayValues.get(rhKey));
            else {
                String lhValue = (String) result.get(rhKey);
                result.put(rhKey, lhValue + (String) rhDisplayValues.get(rhKey));
            }
        }
    }
    return result;
}

From source file:org.geotools.xml.impl.SchemaIndexImpl.java

public XSDElementDeclaration getChildElement(XSDElementDeclaration parent, QName childName) {
    OrderedMap children = (OrderedMap) children(parent);
    XSDParticle particle = (XSDParticle) children.get(childName);

    if (particle != null) {
        XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent();

        if (child.isElementDeclarationReference()) {
            child = child.getResolvedElementDeclaration();
        }/*from   w ww. jav a2s  .  c  o m*/

        return child;
    }

    if ("*".equals(childName.getNamespaceURI())) {
        //do a check just on local name
        ArrayList matches = new ArrayList();

        for (Iterator e = children.entrySet().iterator(); e.hasNext();) {
            Map.Entry entry = (Map.Entry) e.next();
            QName name = (QName) entry.getKey();

            if (name.getLocalPart().equals(childName.getLocalPart())) {
                matches.add(entry.getValue());
            }
        }

        if (matches.size() == 1) {
            particle = (XSDParticle) matches.get(0);

            XSDElementDeclaration child = (XSDElementDeclaration) particle.getContent();

            if (child.isElementDeclarationReference()) {
                child = child.getResolvedElementDeclaration();
            }

            return child;
        }
    }

    return null;
}

From source file:org.pentaho.platform.plugin.services.connections.xquery.XQResultSet.java

public Object[] next() {
    if (peekRow != null) {
        Object[] row = peekRow;//from   ww  w  . j a v  a  2 s. c  o  m
        peekRow = null;
        return row;
    }

    // Create a map of the headers and assign empty string to them
    OrderedMap resultList = new ListOrderedMap();
    for (int i = 0; i < metaData.getColumnCount(); i++) {
        resultList.put(metaData.getColumnHeaders()[0][i], XQResultSet.EMPTY_STR);
    }
    // Get the next row of data
    if (iter.hasNext()) {
        Object o = iter.next();
        decodeNode(o, resultList);
    }
    // get the values
    Object[] currentRow = new Object[resultList.size()];
    Iterator keyIter = resultList.keySet().iterator();
    int i = 0;
    while (keyIter.hasNext()) {
        currentRow[i] = resultList.get(keyIter.next());
        i++;
    }
    // if all the values are the empty string then we're done.
    boolean done = true;
    for (Object element : currentRow) {
        if (!("".equals(element))) { //$NON-NLS-1$
            done = false;
        }
    }
    if (done) {
        return null;
    }
    return currentRow;
}