List of usage examples for java.util LinkedHashMap put
V put(K key, V value);
From source file:com.streamsets.pipeline.lib.parser.excel.TestWorkbookParser.java
@Test public void testParseCorrectlyHandlesFileThatIgnoresHeaders() throws IOException, DataParserException, InvalidFormatException { Workbook workbook = createWorkbook("/excel/TestExcel.xlsx"); WorkbookParser parser = new WorkbookParser(settingsIgnoreHeader, getContext(), workbook, "Sheet1::0"); Record firstContentRow = parser.parse(); LinkedHashMap<String, Field> contentMap = new LinkedHashMap<>(); for (int i = 0; i <= 4; i++) { contentMap.put(String.valueOf(i), Field.create(new BigDecimal(i + 1))); }// w w w. j ava2 s . c om Field expected = Field.createListMap(contentMap); assertEquals(expected, firstContentRow.get()); }
From source file:com.streamsets.pipeline.lib.parser.excel.TestWorkbookParser.java
@Test public void testParseCorrectlyHandlesFileWithNoHeaders() throws IOException, InvalidFormatException, DataParserException { Workbook workbook = createWorkbook("/excel/TestExcel.xlsx"); WorkbookParser parser = new WorkbookParser(settingsNoHeader, getContext(), workbook, "Sheet1::0"); Record firstContentRow = parser.parse(); LinkedHashMap<String, Field> contentMap = new LinkedHashMap<>(); for (int i = 0; i <= 4; i++) { contentMap.put(String.valueOf(i), Field.create("column" + (i + 1))); }/*from ww w . j av a 2 s.co m*/ Field expected = Field.createListMap(contentMap); assertEquals(expected, firstContentRow.get()); }
From source file:gr.seab.r2rml.test.ComplianceTests.java
@Test public void testAll() { log.info("test all"); LinkedHashMap<String, String[]> tests = new LinkedHashMap<String, String[]>(); tests.put("D000-1table1column0rows", new String[] { "r2rml.ttl" }); tests.put("D001-1table1column1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D002-1table2columns1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl", "r2rmle.ttl", "r2rmlf.ttl", "r2rmlg.ttl", "r2rmlh.ttl", "r2rmli.ttl", "r2rmlj.ttl" }); tests.put("D003-1table3columns1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl" }); tests.put("D004-1table2columns1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D005-1table3columns3rows2duplicates", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D006-1table1primarykey1column1row", new String[] { "r2rmla.ttl" }); tests.put("D007-1table1primarykey2columns1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl", "r2rmle.ttl", "r2rmlf.ttl", "r2rmlg.ttl", "r2rmlh.ttl" }); tests.put("D008-1table1compositeprimarykey3columns1row", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl" }); tests.put("D009-2tables1primarykey1foreignkey", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl" }); tests.put("D010-1table1primarykey3colums3rows", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl" }); tests.put("D011-M2MRelations", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D012-2tables2duplicates0nulls", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl", "r2rmle.ttl" }); tests.put("D013-1table1primarykey3columns2rows1nullvalue", new String[] { "r2rmla.ttl" }); tests.put("D014-3tables1primarykey1foreignkey", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl" }); tests.put("D015-1table3columns1composityeprimarykey3rows2languages", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D016-1table1primarykey10columns3rowsSQLdatatypes", new String[] { "r2rmla.ttl", "r2rmlb.ttl", "r2rmlc.ttl", "r2rmld.ttl", "r2rmle.ttl" }); tests.put("D017-I18NnoSpecialChars", new String[] {}); tests.put("D018-1table1primarykey2columns3rows", new String[] { "r2rmla.ttl" }); tests.put("D019-1table1primarykey3columns3rows", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D020-1table1column5rows", new String[] { "r2rmla.ttl", "r2rmlb.ttl" }); tests.put("D021-2tables2primarykeys1foreignkeyReferencesAllNulls", new String[] {}); tests.put("D022-2tables1primarykey1foreignkeyReferencesNoPrimaryKey", new String[] {}); tests.put("D023-2tables2primarykeys2foreignkeysReferencesToNon-primarykeys", new String[] {}); tests.put("D024-2tables2primarykeys1foreignkeyToARowWithSomeNulls", new String[] {}); tests.put("D025-3tables3primarykeys3foreignkeys", new String[] {}); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("test-context.xml"); int counter = 0; for (String key : tests.keySet()) { if (counter > 2 && counter < 26) { String folder = "src/test/resources/postgres/" + key + "/"; initialiseSourceDatabase(folder + "create.sql"); for (String mappingFile : tests.get(key)) { //Override property file Parser parser = (Parser) context.getBean("parser"); Properties p = parser.getProperties(); mappingFile = folder + mappingFile; if (new File(mappingFile).exists()) { p.setProperty("mapping.file", mappingFile); } else { log.error("File " + mappingFile + " does not exist."); }//ww w.java 2 s. c om p.setProperty("jena.destinationFileName", mappingFile.substring(0, mappingFile.indexOf(".") + 1) + "nq"); parser.setProperties(p); MappingDocument mappingDocument = parser.parse(); Generator generator = (Generator) context.getBean("generator"); generator.setProperties(parser.getProperties()); generator.setResultModel(parser.getResultModel()); log.info("--- generating " + p.getProperty("jena.destinationFileName") + " from " + mappingFile + " ---"); generator.createTriples(mappingDocument); } } counter++; } context.close(); }
From source file:com.qwazr.search.annotations.AnnotatedIndexService.java
/** * Set a collection of fields by reading the annotated fields. * * @return the field map//from w w w.ja v a2s . c om */ public LinkedHashMap<String, FieldDefinition> createUpdateFields() { checkParameters(); final LinkedHashMap<String, FieldDefinition> indexFields = new LinkedHashMap<>(); if (indexFieldMap != null) indexFieldMap.forEach((name, indexField) -> indexFields.put(name, new FieldDefinition(indexField))); return indexService.setFields(schemaName, indexName, indexFields); }
From source file:com.streamsets.pipeline.lib.parser.excel.TestWorkbookParser.java
@Test public void testParseCorrectlyHandlesFilesWithHeaders() throws IOException, InvalidFormatException, DataParserException { Workbook workbook = createWorkbook("/excel/TestExcel.xlsx"); WorkbookParser parser = new WorkbookParser(settingsWithHeader, getContext(), workbook, "Sheet1::0"); Record firstContentRow = parser.parse(); LinkedHashMap<String, Field> contentMap = new LinkedHashMap<>(); for (int i = 1; i <= 5; i++) { contentMap.put("column" + i, Field.create(new BigDecimal(i))); }//from w ww .j a v a 2 s .com Field expected = Field.createListMap(contentMap); assertEquals(expected, firstContentRow.get()); assertEquals("Sheet1", firstContentRow.getHeader().getAttribute("worksheet")); }
From source file:com.streamsets.pipeline.lib.parser.excel.TestWorkbookParser.java
@Test public void testParseHandlesStartingFromANonZeroOffset() throws IOException, InvalidFormatException, DataParserException { InputStream file = getFile("/excel/TestOffset.xlsx"); Workbook workbook = WorkbookFactory.create(file); WorkbookParserSettings settings = WorkbookParserSettings.builder().withHeader(ExcelHeader.IGNORE_HEADER) .build();/*from ww w. ja v a 2 s .com*/ WorkbookParser parser = new WorkbookParser(settings, getContext(), workbook, "Sheet2::2"); Record firstContentRow = parser.parse(); LinkedHashMap<String, Field> contentMap = new LinkedHashMap<>(); for (int i = 0; i <= 2; i++) { contentMap.put(String.valueOf(i), Field.create(new BigDecimal(i + 4))); } Field expected = Field.createListMap(contentMap); assertEquals(expected, firstContentRow.get()); }
From source file:com.proofpoint.jmx.MBeanRepresentation.java
public MBeanRepresentation(MBeanServer mbeanServer, ObjectName objectName, ObjectMapper objectMapper) throws JMException { this.objectName = objectName; MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName); className = mbeanInfo.getClassName(); description = mbeanInfo.getDescription(); descriptor = toMap(mbeanInfo.getDescriptor()); ///*from w ww . jav a 2s. c om*/ // Attributes // LinkedHashMap<String, MBeanAttributeInfo> attributeInfos = Maps.newLinkedHashMap(); for (MBeanAttributeInfo attributeInfo : mbeanInfo.getAttributes()) { attributeInfos.put(attributeInfo.getName(), attributeInfo); } String[] attributeNames = attributeInfos.keySet().toArray(new String[attributeInfos.size()]); ImmutableList.Builder<AttributeRepresentation> attributes = ImmutableList.builder(); for (Attribute attribute : mbeanServer.getAttributes(objectName, attributeNames).asList()) { String attributeName = attribute.getName(); // use remove so we only include one value for each attribute MBeanAttributeInfo attributeInfo = attributeInfos.remove(attributeName); if (attributeInfo == null) { // unknown extra attribute, could have been added after MBeanInfo was fetched continue; } Object attributeValue = attribute.getValue(); AttributeRepresentation attributeRepresentation = new AttributeRepresentation(attributeInfo, attributeValue, objectMapper); attributes.add(attributeRepresentation); } this.attributes = attributes.build(); // // Operations // ImmutableList.Builder<OperationRepresentation> operations = ImmutableList.builder(); for (MBeanOperationInfo operationInfo : mbeanInfo.getOperations()) { operations.add(new OperationRepresentation(operationInfo)); } this.operations = operations.build(); }
From source file:edu.csun.ecs.cs.multitouchj.ui.event.ObjectEventManager.java
protected void handleObjectObserverEvent(ObjectType objectType, ObjectObserverEvent event) { if (isRunning()) { synchronized (activeObjects) { LinkedHashMap<Integer, ObjectObserverEvent> objects = activeObjects.get(objectType); // remove is needed to keep its order if (objects.containsKey(event.getId())) { objects.remove(event.getId()); }/*from ww w. j av a 2 s .c om*/ objects.put(event.getId(), event); setUpdated(true); } } }
From source file:com.opengamma.analytics.financial.interestrate.capletstripping.SABRTermStructureModelProvider.java
/** * General set up for a SABRTermStructureModelProvider * @param knotPoints Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the positions of the knot points on each of those curves * @param interpolators Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the interpolator used to describe that curve * @param parameterTransforms Map between parameter curve names ("alpha", "beta", "rho" and "nu") and the parameter transform used for that curve * @param knownParameterTermSturctures Map between known curve names (could be "alpha", "beta", "rho" and "nu") and the known curve(s) *//*from w w w. j a va 2 s. co m*/ public SABRTermStructureModelProvider(LinkedHashMap<String, double[]> knotPoints, final LinkedHashMap<String, Interpolator1D> interpolators, final LinkedHashMap<String, ParameterLimitsTransform> parameterTransforms, final LinkedHashMap<String, InterpolatedDoublesCurve> knownParameterTermSturctures) { Validate.notNull(knotPoints, "null node points"); Validate.notNull(interpolators, "null interpolators"); Validate.isTrue(knotPoints.size() == interpolators.size(), "size mismatch between nodes and interpolators"); if (knownParameterTermSturctures == null) { Validate.isTrue(knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue(knotPoints.containsKey(BETA) && interpolators.containsKey(BETA), "beta curve not found"); Validate.isTrue(knotPoints.containsKey(NU) && interpolators.containsKey(NU), "nu curve not found"); Validate.isTrue(knotPoints.containsKey(RHO) && interpolators.containsKey(RHO), "rho curve not found"); } else { Validate.isTrue((knotPoints.containsKey(ALPHA) && interpolators.containsKey(ALPHA)) ^ knownParameterTermSturctures.containsKey(ALPHA), "alpha curve not found"); Validate.isTrue((knotPoints.containsKey(BETA) && interpolators.containsKey(BETA)) ^ knownParameterTermSturctures.containsKey(BETA), "beta curve not found"); Validate.isTrue((knotPoints.containsKey(NU) && interpolators.containsKey(NU)) ^ knownParameterTermSturctures.containsKey(NU), "nu curve not found"); Validate.isTrue((knotPoints.containsKey(RHO) && interpolators.containsKey(RHO)) ^ knownParameterTermSturctures.containsKey(RHO), "rho curve not found"); } final LinkedHashMap<String, Interpolator1D> transInterpolators = new LinkedHashMap<>(); for (final Map.Entry<String, Interpolator1D> entry : interpolators.entrySet()) { final String name = entry.getKey(); final Interpolator1D temp = new TransformedInterpolator1D(entry.getValue(), parameterTransforms.get(name)); transInterpolators.put(name, temp); } _curveBuilder = new InterpolatedCurveBuildingFunction(knotPoints, transInterpolators); // _parameterTransforms = parameterTransforms; //TODO all the check for this _knownParameterTermStructures = knownParameterTermSturctures; }
From source file:com.redhat.rcm.version.Cli.java
private static void printModders() { final Map<String, ProjectModder> modders = vman.getModders(); final List<String> keys = new ArrayList<String>(modders.keySet()); Collections.sort(keys);/*from w ww .j a va2s.c o m*/ final LinkedHashMap<String, Object> props = new LinkedHashMap<String, Object>(); for (final String key : keys) { props.put(key, modders.get(key).getDescription()); } final StringBuilder sb = new StringBuilder(); sb.append("The following project modifications are available: "); sb.append(formatHelpMap(props, "\n\n")); sb.append( "\n\nNOTE: To ADD any of these modifiers to the standard list, use the notation '--modifications=+<modifier-id>' (prefixed with '+') or for the properties file use 'modifications=+...'.\n\nThe standard modifiers are: "); for (final String key : ProjectModder.STANDARD_MODIFICATIONS) { sb.append(String.format("\n - %s", key)); } sb.append("\n\n"); System.out.println(sb); }