Example usage for java.util LinkedHashMap LinkedHashMap

List of usage examples for java.util LinkedHashMap LinkedHashMap

Introduction

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

Prototype

public LinkedHashMap() 

Source Link

Document

Constructs an empty insertion-ordered LinkedHashMap instance with the default initial capacity (16) and load factor (0.75).

Usage

From source file:com.dianping.phoenix.dev.core.tools.generator.stable.ServiceMetaGenerator.java

@Override
protected Object getArgs(ServiceMetaContext context) throws Exception {
    Map<String, Integer> servicePortMapping = new LinkedHashMap<String, Integer>();

    Class.forName(context.getDriverClass());

    Connection conn = null;/*from   ww w  .j  av a2 s .  c  o m*/
    Statement stmt = null;
    try {
        if (StringUtils.isNotBlank(context.getUser())) {
            conn = DriverManager.getConnection(context.getUrl(), context.getUser(), context.getPwd());
        } else {
            conn = DriverManager.getConnection(context.getUrl());
        }
        stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(
                "SELECT s.serviceName AS serviceName, h.port1 AS port FROM jrobin_host h, service s WHERE s.projectId = h.projectId AND h.port1 IS NOT NULL ORDER BY PORT ASC;");
        while (rs.next()) {
            String serviceName = rs.getString("serviceName");
            int port = rs.getInt("port");
            if (StringUtils.isNotBlank(serviceName)) {
                servicePortMapping.put(serviceName, port);
            }
        }
    } finally {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (Exception e) {

            }
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception e) {

            }
        }
    }

    return servicePortMapping;

}

From source file:com.replaymod.replaystudio.pathing.serialize.LegacyTimelineConverter.java

public static Map<String, Timeline> convert(PathingRegistry registry, ReplayFile replayFile)
        throws IOException {
    KeyframeSet[] keyframeSets = readAndParse(replayFile);
    if (keyframeSets == null) {
        return Collections.emptyMap();
    }/*from   w  w  w.ja v a  2 s .c o  m*/

    Map<String, Timeline> timelines = new LinkedHashMap<>();
    for (KeyframeSet keyframeSet : keyframeSets) {
        timelines.put(keyframeSet.name, convert(registry, keyframeSet));
    }
    return timelines;
}

From source file:de.roderick.weberknecht.WebSocketHandshake.java

public byte[] getHandshake() {
    String path = url.getPath();/*from   www . j a  v  a 2 s. co m*/
    String host = url.getHost();

    if (url.getPort() != -1) {
        host += ":" + url.getPort();
    }

    LinkedHashMap<String, String> header = new LinkedHashMap<String, String>();

    if (this.extraHeaders != null) {
        for (String fieldName : this.extraHeaders.keySet()) {
            // Only checks for Field names with the exact same text,
            // but according to RFC 2616 (HTTP) field names are case-insensitive.
            if (!header.containsKey(fieldName)) {
                header.put(fieldName, this.extraHeaders.get(fieldName));
            }
        }
    }

    header.put("Host", host);
    header.put("Upgrade", "websocket");
    header.put("Connection", "Upgrade");
    header.put("Sec-WebSocket-Version", String.valueOf(WebSocket.getVersion()));
    header.put("Sec-WebSocket-Key", this.nonce);

    if (this.protocol != null) {
        header.put("Sec-WebSocket-Protocol", this.protocol);
    }

    String handshake = "GET " + path + " HTTP/1.1\r\n";
    handshake += this.generateHeader(header);
    handshake += "\r\n";

    byte[] handshakeBytes = new byte[handshake.getBytes().length];
    System.arraycopy(handshake.getBytes(), 0, handshakeBytes, 0, handshake.getBytes().length);

    return handshakeBytes;
}

From source file:edu.uci.ics.jung.graph.DirectedOrderedSparseMultigraph.java

/**
 * Creates a new instance./*  w w w.j  ava 2  s  . com*/
 */
public DirectedOrderedSparseMultigraph() {
    vertices = new LinkedHashMap<V, Pair<Set<E>>>();
    edges = new LinkedHashMap<E, Pair<V>>();
}

From source file:com.hp.mqm.clt.TestResultCollectionTool.java

public void collectAndPushTestResults() {
    Map<File, String> publicApiXMLs = new LinkedHashMap<File, String>();
    if (settings.isInternal()) {
        for (String fileName : settings.getInputXmlFileNames()) {
            publicApiXMLs.put(new File(fileName), fileName);
        }// w ww.j av a2s . co m
    } else if (settings.getOutputFile() != null) {
        processJunitReport(new File(settings.getInputXmlFileNames().get(0)),
                new File(settings.getOutputFile()));
        System.out.println("JUnit report was saved to the output file");
        System.exit(ReturnCode.SUCCESS.getReturnCode());
    } else {
        for (String fileName : settings.getInputXmlFileNames()) {
            File publicApiTempXML = null;
            try {
                publicApiTempXML = File.createTempFile("testResult.xml", null);
                publicApiTempXML.deleteOnExit();
            } catch (IOException e) {
                System.out.println("Can not create temp file for test result");
                System.exit(ReturnCode.FAILURE.getReturnCode());
            }
            processJunitReport(new File(fileName), publicApiTempXML);
            publicApiXMLs.put(publicApiTempXML, fileName);
        }
    }

    client = new RestClient(settings);
    try {
        for (Map.Entry<File, String> publicApiXML : publicApiXMLs.entrySet()) {
            long testResultId;
            try {
                testResultId = client.postTestResult(new FileEntity(publicApiXML.getKey()));
            } catch (ValidationException e) {
                // One invalid public API XML should not stop the whole process when supplied externally
                System.out.println("Test result from file '" + publicApiXML.getValue() + "' was not pushed");
                System.out.println(e.getMessage());
                continue;
            }
            if (settings.isCheckResult()) {
                validatePublishResult(testResultId, publicApiXML.getValue());
            } else {
                System.out.println("Test result from file '" + publicApiXML.getValue()
                        + "' was pushed to the server with ID " + testResultId);
            }
        }
    } catch (IOException e) {
        releaseClient();
        System.out.println("Unable to push test result: " + e.getMessage());
        System.exit(ReturnCode.FAILURE.getReturnCode());
    } catch (RuntimeException e) {
        releaseClient();
        System.out.println("Unable to push test result: " + e.getMessage());
        System.exit(ReturnCode.FAILURE.getReturnCode());
    } finally {
        releaseClient();
    }
}

From source file:com.lrs.enviroment.Metadata.java

private Metadata() {
    delegateMap = new LinkedHashMap();
    loadFromDefault();
}

From source file:gov.nih.nci.cabig.caaers.web.fields.AbstractInputField.java

protected AbstractInputField() {
    this.attributes = new LinkedHashMap<String, Object>();
    this.readable = true;
    this.modifiable = true;
}

From source file:net.sourceforge.jabm.report.PayoffMap.java

public void initialise() {
    payoffs = new LinkedHashMap<Strategy, StatisticalSummary>();
    strategyIndex = new Vector<Strategy>();
    for (Strategy strategy : strategies) {
        strategyIndex.add(strategy);/*from   w w w.j a v a2 s.co m*/
        payoffs.put(strategy, createStatisticalSummary(strategy));
    }
}

From source file:controllers.CCOController.java

@ModelAttribute
public void setInfo(Map<String, Object> model) {
    Map<String, Object> res = new LinkedHashMap();
    for (CarCompletionGroup ccog : carCompletionGroupService.getGroups()) {
        res.put(StringAdapter.getString(ccog.getOldId()), ccog.getTitle());
    }//from w  w  w.j  a  va  2 s .c o m
    model.put("groupDict", res);
}

From source file:data.services.ProfileParamService.java

public LinkedHashMap<ProfileParam, BaseParam> getParamsMap(Radical rd) throws Exception {
    LinkedHashMap<ProfileParam, BaseParam> ppMap = new LinkedHashMap();
    List<ProfileParam> pplist = getParams(rd);
    List<BaseParam> bpList = baseParamService.getParams();
    for (ProfileParam pp : pplist) {
        ppMap.put(pp, new BaseParam());
        for (BaseParam bp : bpList) {
            if (pp.getUid().trim().equals(bp.getUid().trim())) {
                ppMap.put(pp, bp);//from   w w  w  . j av a 2s. c o  m
            }
        }
    }
    //throw new Exception(pplist.size()+" " +bpList.size()+" "+ ppMap.size() );
    return ppMap;
}