当前位置: 首页>>代码示例>>Java>>正文


Java Maps类代码示例

本文整理汇总了Java中com.beust.jcommander.internal.Maps的典型用法代码示例。如果您正苦于以下问题:Java Maps类的具体用法?Java Maps怎么用?Java Maps使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Maps类属于com.beust.jcommander.internal包,在下文中一共展示了Maps类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getQRCodeImge

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
/**
 * 将内容contents生成长为width,宽为width的图片,返回刘文静
 */
public static ServletOutputStream getQRCodeImge(String contents, int width, int height) throws IOException {
    ServletOutputStream stream = null;
    try {
        Map<EncodeHintType, Object> hints = Maps.newHashMap();
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.M);
        hints.put(EncodeHintType.CHARACTER_SET, "UTF8");
        BitMatrix bitMatrix = new MultiFormatWriter().encode(contents, BarcodeFormat.QR_CODE, width, height, hints);
        MatrixToImageWriter.writeToStream(bitMatrix, "png", stream);
        return stream;
    } catch (Exception e) {
        log.error("create QR code error!", e);
        return null;
    } finally {
        if (stream != null) {
            stream.close();
        }
    }
}
 
开发者ID:fanqinghui,项目名称:wish-pay,代码行数:22,代码来源:ZxingUtils.java

示例2: findAbbreviatedValue

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
private static <V> V findAbbreviatedValue(Map<? extends IKey, V> map, IKey name,
    boolean caseSensitive) {
  String string = name.getName();
  Map<String, V> results = Maps.newHashMap();
  for (IKey c : map.keySet()) {
    String n = c.getName();
    boolean match = (caseSensitive && n.startsWith(string))
        || ((! caseSensitive) && n.toLowerCase().startsWith(string.toLowerCase()));
    if (match) {
      results.put(n, map.get(c));
    }
  }

  V result;
  if (results.size() > 1) {
    throw new ParameterException("Ambiguous option: " + name
        + " matches " + results.keySet());
  } else if (results.size() == 1) {
    result = results.values().iterator().next();
  } else {
    result = null;
  }

  return result;
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:26,代码来源:FuzzyMap.java

示例3: getAlipayNotify

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
/**
 * 获取阿里支付链接的所有参数列表
 *
 * @param request
 * @return
 */
public static Map<String, String> getAlipayNotify(HttpServletRequest request) {
    Map<String, String> params = Maps.newHashMap();
    Map requestParams = request.getParameterMap();
    for (Iterator<String> iter = requestParams.keySet().iterator(); iter.hasNext(); ) {
        String name = iter.next();
        String[] values = (String[]) requestParams.get(name);
        String valueStr = "";
        for (int i = 0; i < values.length; i++) {
            valueStr = (i == values.length - 1) ? valueStr + values[i]
                    : valueStr + values[i] + ",";
        }
        //乱码解决,这段代码在出现乱码时使用。如果mysign和sign不相等也可以使用这段代码转化
        //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "gbk");
        params.put(name, valueStr);
    }
    return params;
}
 
开发者ID:fanqinghui,项目名称:wish-pay,代码行数:24,代码来源:AliPayUtil.java

示例4: sort

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Override
public Map sort(Class type, Map keyedByFieldKey) {
    Annotation sequence = type.getAnnotation(XMLSequence.class);
    if (sequence != null) {
        final String[] fieldsOrder = ((XMLSequence) sequence).value();
        Map<Object, Object> result = Maps.newLinkedHashMap();
        Set<Map.Entry<FieldKey, Field>> fields = keyedByFieldKey.entrySet();
        for (String fieldName : fieldsOrder) {
            if (fieldName != null) {
                for (Map.Entry<FieldKey, Field> fieldEntry : fields) {
                    if (fieldName.equals(fieldEntry.getKey().getFieldName())) {
                        result.put(fieldEntry.getKey(), fieldEntry.getValue());
                    }
                }
            }
        }
        return result;
    } else {
        return keyedByFieldKey;
    }

}
 
开发者ID:GojaFramework,项目名称:goja,代码行数:23,代码来源:SequenceFieldKeySorter.java

示例5: checkComplexMetrics

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test(groups = "orm")
public void checkComplexMetrics() {
  final Alarm newAlarm = new Alarm(alarmDef, AlarmState.ALARM);

  for (final String hostname : Arrays.asList("vivi", "eleanore")) {
    for (final String metricName : Arrays.asList("cpu", "load")) {
      final Map<String, String> dimensions = Maps.newHashMap();
      dimensions.put("first", "first_value");
      dimensions.put("second", "second_value");
      dimensions.put("hostname", hostname);
      final MetricDefinition md = new MetricDefinition(metricName, dimensions);
      newAlarm.addAlarmedMetric(new MetricDefinitionAndTenantId(md, TENANT_ID));
    }
  }
  dao.createAlarm(newAlarm);

  final Alarm found = dao.findById(newAlarm.getId());
  // Have to check both ways because there was a bug in AlarmDAOImpl and it showed up if both
  // ways were tested
  assertTrue(newAlarm.equals(found));
  assertTrue(found.equals(newAlarm));
}
 
开发者ID:openstack,项目名称:monasca-thresh,代码行数:23,代码来源:AlarmSqlImplTest.java

示例6: findAbbreviatedValue

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
private static <V> V findAbbreviatedValue(Map<? extends IKey, V> map, IKey name,
                                          boolean caseSensitive) {
    String string = name.getName();
    Map<String, V> results = Maps.newHashMap();
    for (IKey c : map.keySet()) {
        String n = c.getName();
        boolean match = (caseSensitive && n.startsWith(string))
                || ((!caseSensitive) && n.toLowerCase().startsWith(string.toLowerCase()));
        if (match) {
            results.put(n, map.get(c));
        }
    }

    V result;
    if (results.size() > 1) {
        throw new ParameterException("Ambiguous option: " + name
                + " matches " + results.keySet());
    } else if (results.size() == 1) {
        result = results.values().iterator().next();
    } else {
        result = null;
    }

    return result;
}
 
开发者ID:Corporatique-dev,项目名称:Corporatique,代码行数:26,代码来源:FuzzyMap.java

示例7: testFilterResponseContextAdapter

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test
public void testFilterResponseContextAdapter()
{
  DataMap dataMap = new DataMap();
  dataMap.put("foo", "bar");
  Map<String, String> headers = Maps.newHashMap();
  headers.put("x", "y");
  RecordTemplate entity = new Foo(dataMap);
  PartialRestResponse partialResponse =
      new PartialRestResponse.Builder().status(HttpStatus.S_200_OK).headers(headers).entity(entity).build();
  FilterResponseContext context = new Rest4JCallback.FilterResponseContextAdapter(partialResponse);
  assertEquals(headers, context.getResponseHeaders());
  assertEquals(entity, context.getResponseEntity());
  assertEquals(HttpStatus.S_200_OK, context.getHttpStatus());

  context.setHttpStatus(HttpStatus.S_404_NOT_FOUND);
  context.setResponseEntity(null);
  assertNull(context.getResponseEntity());
  assertEquals(HttpStatus.S_404_NOT_FOUND, context.getHttpStatus());
}
 
开发者ID:ppdai,项目名称:rest4j,代码行数:21,代码来源:TestRest4JCallback.java

示例8: tesParsingCorrectPayloadReturnsCorrectEventObject

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test(groups = SMALL)
public void tesParsingCorrectPayloadReturnsCorrectEventObject() {
    Map<String, Object> expectedNewEntity = Maps.newHashMap();
    expectedNewEntity.put("id", 1);
    expectedNewEntity.put("value", "def");

    Map<String, Object> expectedOldEntity = Maps.newHashMap();
    expectedOldEntity.put("id", 1);
    expectedOldEntity.put("value", "abc");

    Event<Map<String, Object>> event = mapper.parseResponse(JSON_CORRECT_RESPONSE);
    assertEquals(event.getEventType(), Event.UPDATE_TYPE);
    assertEquals(event.getEntityName(), "test");
    assertEquals(event.getNewEntity(), expectedNewEntity);
    assertEquals(event.getOldEntity(), expectedOldEntity);

}
 
开发者ID:eBay,项目名称:reactive-source,代码行数:18,代码来源:PsqlEventMapperTest.java

示例9: asDataPointsShouldReturnCorrectMissingSensedDataPoints

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test
public void asDataPointsShouldReturnCorrectMissingSensedDataPoints() {

    List<DataPoint<PhysicalActivity>> dataPoints = mapper.asDataPoints(singletonList(responseNode));

    PhysicalActivity expectedPhysicalActivity = new PhysicalActivity.Builder("Bike")
            .setDistance(new LengthUnitValue(METER, 6318.2688961))
            .setEffectiveTimeFrame(
                    TimeInterval.ofEndDateTimeAndDuration(OffsetDateTime.parse("2015-04-29T16:07:07-04:00"),
                            new DurationUnitValue(SECOND, 343)))
            .setCaloriesBurned(new KcalUnitValue(KILOCALORIE, 27.16863765916))
            .build();

    assertThat(dataPoints.get(1).getBody(), equalTo(expectedPhysicalActivity));

    DataPointHeader testDataPointHeader = dataPoints.get(1).getHeader();
    Map<String, Object> testProperties = Maps.newHashMap();
    testProperties.put(HEADER_EXTERNAL_ID_KEY, "SbiOBJjJJk8n2xLpNTMFng12pGRjX-qe");
    testProperties.put(HEADER_SOURCE_UPDATE_KEY, "2015-04-29T20:07:56Z");
    testProperties.put(HEADER_SCHEMA_ID_KEY, PhysicalActivity.SCHEMA_ID);
    testDataPointHeader(testDataPointHeader, testProperties);
}
 
开发者ID:openmhealth,项目名称:shimmer,代码行数:23,代码来源:JawbonePhysicalActivityDataPointMapperUnitTests.java

示例10: testEstimateOlapQuery

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test(expectedExceptions = {UnsupportedOperationException.class})
public void testEstimateOlapQuery() throws Exception {
  SessionState.setCurrentSessionState(ss);
  ExplainQueryContext ctx = createExplainContext("cube SELECT ID FROM test_cube", queryConf);
  ctx.setOlapQuery(true);
  ctx.getDriverContext().setDriverRewriterPlan(driver, new DriverQueryPlan() {
    @Override
    public String getPlan() {
      return null;
    }

    @Override
    public QueryCost getCost() {
      return null;
    }

    @Override
    public Map<String, Set<?>> getPartitions() {
      return Maps.newHashMap();
    }
  });
  QueryCost cost = driver.estimate(ctx);
  assertEquals(cost.getEstimatedResourceUsage(), 0.0);
  cost.getEstimatedExecTimeMillis();
}
 
开发者ID:apache,项目名称:lens,代码行数:26,代码来源:TestHiveDriver.java

示例11: shouldParseDeterministicExpression

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
public void shouldParseDeterministicExpression() {
  final Map<String, String> dimensions = Maps.newHashMap();
  final ArrayList<AlarmExpression> expressions = Lists.newArrayList(
      new AlarmExpression("count(log.error{},deterministic,20) > 5")
  );
  final MetricDefinition metricDefinition = new MetricDefinition("log.error", dimensions);

  final AlarmSubExpression logErrorExpr = new AlarmSubExpression(
      AggregateFunction.COUNT,
      metricDefinition,
      AlarmOperator.GT,
      5,
      20,
      1,
      true // each expression is deterministic
  );

  for (final AlarmExpression expr : expressions) {
    final List<AlarmSubExpression> subExpressions = expr.getSubExpressions();

    assertTrue(expr.isDeterministic());  // each expression is deterministic
    assertEquals(1, subExpressions.size());
    assertEquals(subExpressions.get(0), logErrorExpr);
  }
}
 
开发者ID:openstack,项目名称:monasca-common,代码行数:26,代码来源:AlarmExpressionTest.java

示例12: listOfMapStringString

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test
public void listOfMapStringString() {
    createTable("CREATE TABLE table1 (id INT PRIMARY KEY, data TEXT)");
    this.addConfigHook(c ->
            c.setConverter("table1", "data", new ObjectToJsonStringConverter(List.class, new TypeReference<List<Map<String, String>>>() {
            })));


    Table t1 = lSql.table("table1");

    List<Map<String, String>> list = Lists.newLinkedList();
    Map<String, String> e = Maps.newHashMap();
    e.put("a", "1");
    e.put("b", "2");
    list.add(e);
    list.add(e);

    t1.insert(Row.fromKeyVals("id", 1, "data", list));
    Row row = t1.load(1).get();
    assertEquals(row.get("data"), list);
}
 
开发者ID:w11k,项目名称:lsql,代码行数:22,代码来源:ObjectToJsonStringConverterTest.java

示例13: listOfMapStringStringInALinkedRow

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
@Test
public void listOfMapStringStringInALinkedRow() {
    createTable("CREATE TABLE table1 (id SERIAL PRIMARY KEY, data TEXT)");
    this.addConfigHook(c ->
            c.setConverter(
                    "table1",
                    "data",
                    new ObjectToJsonStringConverter(List.class, new TypeReference<List<Map<String, String>>>() {
                    })));

    Table t1 = lSql.table("table1");

    List<Map<String, String>> list = Lists.newLinkedList();
    Map<String, String> e = Maps.newHashMap();
    e.put("a", "1");
    e.put("b", "2");
    list.add(e);
    list.add(e);
    t1.newLinkedRow("id", 1, "data", list).save();

    Row row = t1.load(1).get();
    assertEquals(row.get("data"), list);
}
 
开发者ID:w11k,项目名称:lsql,代码行数:24,代码来源:ObjectToJsonStringConverterTest.java

示例14: newCacheFileLineProcessor

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
/**
 * Returns a new line processor for the cache file. The processor generates map of song IDs to
 * file names.
 */
static LineProcessor<Map<Integer, String>> newCacheFileLineProcessor() {
    return new LineProcessor<Map<Integer, String>>() {

        @SuppressWarnings("CanBeFinal")
        Map<Integer, String> map = Maps.newHashMap();

        @Override
        public boolean processLine(String line) throws IOException {
            String[] split = line.split("\\|");
            map.put(Integer.valueOf(split[0]), split[1]);
            return true;
        }

        @Override
        public Map<Integer, String> getResult() {
            return map;
        }
    };
}
 
开发者ID:danhawkes,项目名称:basking,代码行数:24,代码来源:WriteCacheFileTask.java

示例15: createDescriptions

import com.beust.jcommander.internal.Maps; //导入依赖的package包/类
/**
 * Create the ParameterDescriptions for all the \@Parameter found.
 */
private void createDescriptions() {
    descriptions = Maps.newHashMap();

    for (Object object : objects) {
        addDescription(object);
    }
}
 
开发者ID:georghinkel,项目名称:ttc2017smartGrids,代码行数:11,代码来源:JCommander.java


注:本文中的com.beust.jcommander.internal.Maps类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。