@NotNull
  public static <CommitInfo> List<CommitInfo> getCommitRecords(
      @NotNull Project project,
      @Nullable HgCommandResult result,
      @NotNull Function<String, CommitInfo> converter,
      boolean silent) {
    final List<CommitInfo> revisions = new LinkedList<CommitInfo>();
    if (result == null) {
      return revisions;
    }

    List<String> errors = result.getErrorLines();
    if (errors != null && !errors.isEmpty()) {
      if (result.getExitValue() != 0) {
        if (silent) {
          LOG.warn(errors.toString());
        } else {
          VcsNotifier.getInstance(project)
              .notifyError(
                  HgVcsMessages.message("hg4idea.error.log.command.execution"), errors.toString());
        }
        return Collections.emptyList();
      }
      LOG.warn(errors.toString());
    }
    String output = result.getRawOutput();
    List<String> changeSets = StringUtil.split(output, HgChangesetUtil.CHANGESET_SEPARATOR);
    return ContainerUtil.mapNotNull(changeSets, converter);
  }
 // 获取批次范围
 @RequestMapping("/getBatchNos")
 @ResponseBody
 public String getBatchNos(HttpServletRequest request, HttpServletResponse response) {
   List<BigDecimal> batchNos = gardeniaExtrationService.getBatchNos();
   System.out.println("获取栀子批次范围成功:" + batchNos.toString());
   return batchNos.toString();
 }
Exemplo n.º 3
0
 @Override
 public String toString() {
   return "\n\tProduction: "
       + (productionTemplate != null ? productionTemplate.toString() : "null")
       + " conditions: "
       + (conditions != null ? conditions.toString() : "null");
 }
 // 获取干膏范围
 @RequestMapping("/getDryConcreteWeights")
 @ResponseBody
 public String getDryConcreteWeights(HttpServletRequest request, HttpServletResponse response) {
   List<Double> dryconcreteweights = gardeniaExtrationService.getDryConcreteWeights();
   System.out.println("查询栀子干膏范围:" + dryconcreteweights.toString());
   return dryconcreteweights.toString();
 }
 // 获取含量范围
 @RequestMapping("/getContents")
 @ResponseBody
 public String getContents(HttpServletRequest request, HttpServletResponse response) {
   List<Double> contents = gardeniaExtrationService.getContents();
   System.out.println("查询栀子含量范围:" + contents.toString());
   return contents.toString();
 }
Exemplo n.º 6
0
  public <T> T evaluate(Object object, Class<T> context) {
    Point point;
    Expression param1 = parameters.get(0);

    if (param1.equals(ToDirectPositionFunction.SRS_NAME)) {

      if (parameters.size() > 5 || parameters.size() < 4) {
        throw new IllegalArgumentException(
            "Wrong number of parameters for toPoint function: "
                + parameters.toString()
                + ". Usage: toPoint('SRS_NAME'(optional), srsName(optional), point 1, point 2, gml:id(optional))");
      }
      CoordinateReferenceSystem crs = null;
      String srsName = parameters.get(1).evaluate(object, String.class);
      try {
        crs = CRS.decode((String) srsName);
      } catch (NoSuchAuthorityCodeException e) {
        throw new IllegalArgumentException(
            "Invalid or unsupported SRS name detected for toPoint function: "
                + srsName
                + ". Cause: "
                + e.getMessage());
      } catch (FactoryException e) {
        throw new RuntimeException("Unable to decode SRS name. Cause: " + e.getMessage());
      }
      GeometryFactory fac = new GeometryFactory(new PrecisionModel());
      point =
          fac.createPoint(
              new Coordinate(
                  parameters.get(2).evaluate(object, Double.class),
                  parameters.get(3).evaluate(object, Double.class)));
      // set attributes
      String gmlId = null;
      if (parameters.size() == 5) {
        gmlId = parameters.get(4).evaluate(object, String.class);
      }
      setUserData(point, crs, gmlId);
    } else {

      if (parameters.size() > 3 || parameters.size() < 2) {
        throw new IllegalArgumentException(
            "Wrong number of parameters for toPoint function: "
                + parameters.toString()
                + ". Usage: toPoint('SRS_NAME'(optional), srsName(optional), point 1, point 2, gml:id(optional))");
      }
      GeometryFactory fac = new GeometryFactory();

      point =
          fac.createPoint(
              new Coordinate(
                  param1.evaluate(object, Double.class),
                  parameters.get(1).evaluate(object, Double.class)));

      if (parameters.size() == 3) {
        String gmlId = parameters.get(2).evaluate(object, String.class);
        setUserData(point, null, gmlId);
      }
    }
    return (T) point;
  }
Exemplo n.º 7
0
  /**
   * 翻转线路,生成逆向行驶数组,并保存
   *
   * @timestamp Feb 23, 2016 11:41:56 PM
   * @param h
   */
  private void reverse(String h, StandardArea area) {
    String[] rs = h.split(",");
    List<String> list = new ArrayList<>();
    Collections.addAll(list, rs);

    String one =
        list.toString() //
            .replaceAll("\\[", "")
            .replaceAll("\\]", "")
            .replaceAll(" ", "");
    Collections.reverse(list);
    String two =
        list.toString() //
            .replaceAll("\\[", "")
            .replaceAll("\\]", "")
            .replaceAll(" ", "");
    for (int i = 30; i <= 100; i = i + 10) { // 30KM/H到100KM/H不等
      StandardRoute route = new StandardRoute();
      route.setSpeed(Double.parseDouble(String.format("%.2f", (i / 3.6 * 100)))); // 速度单位-->cm/s
      route.setRouteTable(one);
      route.setAreaId(area.getId());
      routeService.insertRoute(route);
      route = new StandardRoute();
      route.setSpeed(Double.parseDouble(String.format("%.2f", (i / 3.6 * 100)))); // 速度单位-->cm/s
      route.setRouteTable(two);
      route.setAreaId(area.getId());
      routeService.insertRoute(route);
    }
  }
Exemplo n.º 8
0
  public void addColumns(List<String> labels, List<String> columnKeyL, String type, String width) {

    boolean useColumKeyAsHeader = labels == null;

    // Add as many columns as there are keys. Check if labels are used or if the columnkey should be
    // used.
    if (useColumKeyAsHeader && labels.size() < columnKeyL.size()) {
      Log.e("vortex", "There are too few labels in addColumns! Labels: " + labels.toString());
      o.addRow("");
      o.addRedText("There are too few labels in addColumns! Labels: " + labels.toString());
      return;
    }
    if (columnKeyL == null) {
      Log.e("vortex", "columnkeys missing for addColumn!!");
      o.addRow("");
      o.addRow("columnkeys missing for addColumn!!");
      return;
    }
    String k, l;
    for (int i = 0; i < columnKeyL.size(); i++) {

      k = columnKeyL.get(i);
      l = (useColumKeyAsHeader ? null : labels.get(i));
      // Add the column
      addColumn(l, k, type, width);
    }
    for (String s : columnKeys) Log.d("vortex", "my columns: " + s);
  }
Exemplo n.º 9
0
  @Override
  public void NotifyDataChanged(int notifyType) {
    switch (notifyType) {
        // 网络加载的备料单列表发生变化
      case NOTICE_PREPARE_ADAPTER:
        if (prepareAdapter != null) {
          prepareAdapter.notifyDataSetChanged();
          Log.i("Inmake:NotifyItem", prepareDataList.toString());
          showNullItemImg(prepareDataList, nullItemLayoutPrepare);
        }

        loadingView.dismiss();
        break;
        // 搜索的备料单列表发生变化
      case NOTICE_SEARCH_ADAPTER:
        Log.e("Inmake:NotifyItem", "searchItemList" + searchItemList.toString());
        if (searchAdapter != null) {
          searchAdapter.notifyDataSetChanged();
          Log.e("Inmake:NotifyItem", searchItemList.toString());
          showNullItemImg(searchItemList, nullItemLayoutSearch);
        }
        loadingView.dismiss();
        break;
    }
  }
  @Test
  public void testAfterWriteAllPassedInRecovery() throws Exception {
    Chunk<String> chunk = new Chunk<String>(Arrays.asList("foo", "bar"));
    processor =
        new FaultTolerantChunkProcessor<String, String>(
            new PassThroughItemProcessor<String>(),
            new ItemWriter<String>() {
              public void write(List<? extends String> items) throws Exception {
                // Fail if there is more than one item
                if (items.size() > 1) {
                  throw new RuntimeException("Planned failure!");
                }
                list.addAll(items);
              }
            },
            batchRetryTemplate);
    processor.setListeners(
        Arrays.asList(
            new ItemListenerSupport<String, String>() {
              @Override
              public void afterWrite(List<? extends String> item) {
                after.addAll(item);
              }
            }));
    processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());

    processAndExpectPlannedRuntimeException(chunk);
    processor.process(contribution, chunk);
    processor.process(contribution, chunk);

    assertEquals("[foo, bar]", list.toString());
    assertEquals("[foo, bar]", after.toString());
  }
  @Test
  public void testCommandsUtils() {

    String name01 = " , ,";
    List<String> test01 = CommandsUtils.inputsConvert(name01);
    List<String> testDef01 = new ArrayList<String>(0);
    System.out.println(test01.toString());
    assertEquals(test01, testDef01);

    String name02 = " , ,.";
    List<String> test02 = CommandsUtils.inputsConvert(name02);
    List<String> testDef02 = new ArrayList<String>(0);
    testDef02.add(".");
    System.out.println(test02.toString());
    assertEquals(test02, testDef02);

    String name03 = " a, b,c";
    List<String> test03 = CommandsUtils.inputsConvert(name03);
    List<String> testDef03 = new ArrayList<String>(0);
    testDef03.add("a");
    testDef03.add("b");
    testDef03.add("c");
    System.out.println(test03.toString());
    assertEquals(test03, testDef03);
  }
 @Test
 public void testAfterWrite() throws Exception {
   Chunk<String> chunk = new Chunk<String>(Arrays.asList("foo", "fail", "bar"));
   processor.setListeners(
       Arrays.asList(
           new ItemListenerSupport<String, String>() {
             @Override
             public void afterWrite(List<? extends String> item) {
               after.addAll(item);
             }
           }));
   processor.setWriteSkipPolicy(new AlwaysSkipItemSkipPolicy());
   processAndExpectPlannedRuntimeException(chunk);
   processor.process(contribution, chunk);
   assertEquals(2, chunk.getItems().size());
   processAndExpectPlannedRuntimeException(chunk);
   assertEquals(1, chunk.getItems().size());
   processor.process(contribution, chunk);
   assertEquals(0, chunk.getItems().size());
   // foo is written once because it the failure is detected before it is
   // committed the first time
   assertEquals("[foo, bar]", list.toString());
   // the after listener is called once per successful item, which is
   // important
   assertEquals("[foo, bar]", after.toString());
 }
Exemplo n.º 13
0
 public static void main(final String[] args) {
   final String htmlText =
       "<br><img src=\"http://tripleamaps.sourceforge.net/images/tww/TechOverview0.png\" alt=\"blah, blah\"/>"
           + "\n<br /><img src=\"\" alt=\"<em>formatted, alt text for a no source image</em>\"/>"
           + "\n<br/><img src=\"http://www.someWebsite.com/some%20Folder/someOtherFolder Which May Contain Spaces/somePicture.gif\"/>"
           + "\n<br><img src=\"http://www.someWebsite.com/some%20Folder/someOtherFolder Which May Contain Spaces/some Picture%20WithSpaces.JPEG\" alt=\"<em>formatted, alt text</em>\"/>"
           + "\n<br><img src='http://www.someWebsite.com/some%20Folder/someOtherFolder Which May Contain Spaces/some Picture%20WithSpaces2.JPEG' alt='formatted, alt text for single quote img tag'/>"
           + "\n<br/><IMG ALT=\"reverse order alt and src tags and capitalized\" SRC=\"http://www.someWebsite.com/some%20Folder/someOtherFolder Which May Contain Spaces/somePicture2.gif\"/>"
           + "\n<br /><br><img src=\"http://tripleamaps.sourceforge.net/images/tww/TechOverview1.png\" alt=\"technically legal to have separate end tag on img\"></img>"
           + "\n<br>And here is a normal link in plain text: http://tripleamaps.sourceforge.net/images/tww/TechOverview1.png"
           + "\n<br />And <SPAN>some regular old html <b>text that</b> might <i>have other</i> formatting in it</SPAN> and stuff."
           + "\n<br />And now for some normal links as links:"
           + "\n<br /><a href=\"http://tripleamaps.sourceforge.net/images/tww/TechOverview2.png\">picture</a>"
           + "\n<br /><a href=\"http://tripleamaps.sourceforge.net/images/tww/TechOverview3.png\"/>"
           + "\n<br /><A HREF=\"http://tripleamaps.sourceforge.net/images/tww/TechOverview4.png\"><em><SPAN>formatted, alt text, with capitalization</SPAN></em></A>"
           + "\n<br /><a href=\"\"><em>formatted, alt text for a no href link</em></a>"
           + "\n<br /><a target='_blank' href='http://www.someWebsite.com/some%20Folder/someOtherFolder Which May Contain Spaces/some Picture%20WithSpaces3.JPEG'><b>reverse order with single quotes and formatted text</b></a>";
   System.out.println(htmlText);
   System.out.println("\n\n\n");
   final List<String> links1 = getAllAhrefLinksFromHTML(htmlText);
   System.out.println(links1.toString());
   System.out.println("\n\n\n");
   final List<String> links2 = getAllImgSrcLinksFromHTML(htmlText);
   System.out.println(links2.toString());
   System.out.println("\n\n\n");
   final String newHTMLstring = localizeImgLinksInHTML(htmlText);
   System.out.println("\n" + newHTMLstring);
 }
Exemplo n.º 14
0
  public String highchart5() {
    DAO dao = new DAO();
    Enterprise e = enterprise.selectByEtpEmail(etpEmail);
    System.err.println(e);
    List<Highchart5> list = dao.highchart5DAO(e);

    Highchart5Add vo = new Highchart5Add();
    List<Highchart5Add> daylist = new ArrayList<Highchart5Add>();
    System.out.println(list.toString() + "1");

    for (Highchart5 temp : list) {
      if (temp.getDayby().equals("월요일")) {
        vo.setMon(temp.getRs());
      } else if (temp.getDayby().equals("화요일")) {
        vo.setTue(temp.getRs());
      } else if (temp.getDayby().equals("수요일")) {
        vo.setWed(temp.getRs());
      } else if (temp.getDayby().equals("목요일")) {
        vo.setThur(temp.getRs());
      } else if (temp.getDayby().equals("금요일")) {
        vo.setFri(temp.getRs());
      } else if (temp.getDayby().equals("토요일")) {
        vo.setSat(temp.getRs());
      } else if (temp.getDayby().equals("일요일")) {
        vo.setSun(temp.getRs());
      }
    }
    daylist.add(vo);
    request.put("dayForReservation", daylist);

    System.out.println(daylist.toString() + "2");

    return SUCCESS;
  }
Exemplo n.º 15
0
  /**
   * @param clientAlgorithms
   * @param serverAlgorithms
   * @return
   * @throws AlgorithmNotAgreedException
   */
  protected String determineAlgorithm(List clientAlgorithms, List serverAlgorithms)
      throws AlgorithmNotAgreedException {
    if (log.isDebugEnabled()) {
      log.debug("Determine Algorithm");
      log.debug("Client Algorithms: " + clientAlgorithms.toString());
      log.debug("Server Algorithms: " + serverAlgorithms.toString());
    }

    String algorithmClient;
    String algorithmServer;
    Iterator itClient = clientAlgorithms.iterator();

    while (itClient.hasNext()) {
      algorithmClient = (String) itClient.next();

      Iterator itServer = serverAlgorithms.iterator();

      while (itServer.hasNext()) {
        algorithmServer = (String) itServer.next();

        if (algorithmClient.equals(algorithmServer)) {
          log.debug("Returning " + algorithmClient);

          return algorithmClient;
        }
      }
    }

    throw new AlgorithmNotAgreedException("Could not agree algorithm");
  }
Exemplo n.º 16
0
  private static KieBuilder getKieBuilderFromFileSystemWithResources(
      final KieFileSystem kfs, final boolean failIfBuildError, final Resource... resources) {
    for (Resource res : resources) {
      kfs.write(res);
    }

    final KieBuilder kbuilder = KieServices.Factory.get().newKieBuilder(kfs);
    kbuilder.buildAll();

    // Messages from KieBuilder with increasing severity
    List<Message> msgs = kbuilder.getResults().getMessages(Message.Level.INFO);
    if (msgs.size() > 0) {
      LOGGER.info("KieBuilder information: {}", msgs.toString());
    }

    msgs = kbuilder.getResults().getMessages(Message.Level.WARNING);
    if (msgs.size() > 0) {
      LOGGER.warn("KieBuilder warnings: {}", msgs.toString());
    }

    msgs = kbuilder.getResults().getMessages(Message.Level.ERROR);
    if (msgs.size() > 0) {
      LOGGER.error("KieBuilder errors: {}", msgs.toString());
    }

    if (failIfBuildError) {
      Assertions.assertThat(msgs).as(msgs.toString()).isEmpty();
    }

    return kbuilder;
  }
  @Test
  public void testAllocate() {
    AllocateMessageQueueAveragely allocateMessageQueueAveragely =
        new AllocateMessageQueueAveragely();
    String topic = "topic_test";
    String currentCID = "CID";
    int queueSize = 19;
    int consumerSize = 10;
    List<MessageQueue> mqAll = new ArrayList<MessageQueue>();
    for (int i = 0; i < queueSize; i++) {
      MessageQueue mq = new MessageQueue(topic, "brokerName", i);
      mqAll.add(mq);
    }

    List<String> cidAll = new ArrayList<String>();
    for (int j = 0; j < consumerSize; j++) {
      cidAll.add("CID" + j);
    }
    System.out.println(mqAll.toString());
    System.out.println(cidAll.toString());
    for (int i = 0; i < consumerSize; i++) {
      List<MessageQueue> rs =
          allocateMessageQueueAveragely.allocate("", currentCID + i, mqAll, cidAll);
      System.out.println("rs[" + currentCID + i + "]:" + rs.toString());
    }
  }
Exemplo n.º 18
0
 /**
  * Retreives qr code data and the lable's and their respective weights.
  *
  * @return
  */
 private Boolean QRcodeRetreive() {
   if (QR_CODE_QUESTION == null) return false;
   qrCodeDAO = new QRCodeDAO(getBaseContext());
   QrCode qrCode = qrCodeDAO.getSingleQRcodeLocationOnQuestion(QR_CODE_QUESTION);
   if (qrCode == null) {
     return false;
   }
   String val = qrCode.getVALUES();
   label = new ArrayList<String>();
   Weights = new ArrayList<Integer>();
   WeightsOld = new ArrayList<Integer>();
   String current = "";
   for (int i = 0; i < val.length(); i++) {
     char curr = val.charAt(i);
     if (curr == ':') {
       label.add(current);
       current = "";
       continue;
     }
     if (curr == ';') {
       Weights.add(Integer.parseInt(current));
       WeightsOld.add(Integer.parseInt(current));
       current = "";
       continue;
     }
     current = current + curr;
   }
   Question_Solution = qrCode.getQuestionSolution();
   MAXGRADE = qrCode.getMaxGrade();
   GRADE = MAXGRADE;
   GRADEACTUAL = MAXGRADE;
   Log.d(TAG, "QRcodeRetreive: qr code labels" + label.toString());
   Log.d(TAG, "QRcodeRetreive: qr code weights" + Weights.toString());
   return true;
 }
  @Override
  public String execute() {
    try {
      String nolights = "All lights are off :(";
      int time = 1;
      int totalLength = 0;
      List<Integer> evenSeq = new Vector<Integer>();
      List<Integer> oddSeq = new Vector<Integer>();
      for (; time <= timeLimit && totalLength < nlights; time++, totalLength++) {
        int num = time - 1;
        if (num % 2 == 0) {
          evenSeq.add(num);
        } else {
          oddSeq.add(num);
        }
      }
      String end = "";
      if (timeLimit % 2 != 0) {
        end = evenSeq.toString();
      } else {
        end = oddSeq.toString();
      }
      end = end.replaceAll("[\\[\\],]", "");
      if (end.equalsIgnoreCase("")) {
        return nolights;
      }
      return end;

    } catch (Exception e) {
      return "E:" + e;
    }
  }
  /** Test support of "@requiresDependencyResolution compile+runtime". */
  public void testit() throws Exception {
    File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-4293");

    Verifier verifier = newVerifier(testDir.getAbsolutePath());
    verifier.setAutoclean(false);
    verifier.deleteDirectory("target");
    verifier.deleteArtifacts("org.apache.maven.its.mng4293");
    Properties filterProps = verifier.newDefaultFilterProperties();
    verifier.filterFile("pom-template.xml", "pom.xml", "UTF-8", filterProps);
    verifier.filterFile("settings-template.xml", "settings.xml", "UTF-8", filterProps);
    verifier.getCliOptions().add("--settings");
    verifier.getCliOptions().add("settings.xml");
    verifier.executeGoal("validate");
    verifier.verifyErrorFreeLog();
    verifier.resetStreams();

    List compileClassPath = verifier.loadLines("target/compile-cp.txt", "UTF-8");
    assertTrue(compileClassPath.toString(), compileClassPath.contains("system-0.1.jar"));
    assertTrue(compileClassPath.toString(), compileClassPath.contains("provided-0.1.jar"));
    assertTrue(compileClassPath.toString(), compileClassPath.contains("compile-0.1.jar"));
    assertFalse(compileClassPath.toString(), compileClassPath.contains("test-0.1.jar"));

    List runtimeClassPath = verifier.loadLines("target/runtime-cp.txt", "UTF-8");
    assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("compile-0.1.jar"));
    assertTrue(runtimeClassPath.toString(), runtimeClassPath.contains("runtime-0.1.jar"));
    assertFalse(runtimeClassPath.toString(), runtimeClassPath.contains("test-0.1.jar"));
  }
Exemplo n.º 21
0
    public TypedDescriptor(String text, List<Integer> keyCodes, List<Integer> modifiers) {
      myText = text;
      myKeyCodes.addAll(keyCodes);
      myModifiers.addAll(modifiers);

      assert myKeyCodes.size() == myModifiers.size()
          : "codes=" + myKeyCodes.toString() + " modifiers=" + myModifiers.toString();
    }
 private void assertSequence(List<DependencyNode> actual, String... expected) {
   assertEquals(actual.toString(), expected.length, actual.size());
   for (int i = 0; i < expected.length; i++) {
     DependencyNode node = actual.get(i);
     assertEquals(
         actual.toString(), expected[i], node.getDependency().getArtifact().getArtifactId());
   }
 }
Exemplo n.º 23
0
  /**
   * _more_
   *
   * @param symbols _more_
   * @param listener _more_
   * @param smm _more_
   * @return _more_
   */
  public static List makeStationModelMenuItems(
      List symbols, final ObjectListener listener, StationModelManager smm) {
    List items = new ArrayList();
    List subMenus = new ArrayList();
    Hashtable categories = new Hashtable();
    for (int i = 0; i < symbols.size(); i++) {
      StationModel sm = (StationModel) symbols.get(i);
      boolean isUsers = smm.isUsers(sm);
      String name = sm.getName();
      if (name.equals("")) continue;
      List toks = StringUtil.split(name, ">", true, true);
      if (toks.size() > 0) {
        name = (String) toks.get(toks.size() - 1);
      }
      JMenuItem item = new JMenuItem(GuiUtils.getLocalName(name, isUsers));
      item.addActionListener(
          new ObjectListener(sm) {
            public void actionPerformed(ActionEvent ae) {
              listener.setObject(this.theObject);
              listener.actionPerformed(ae);
            }
          });

      toks.remove(toks.size() - 1);
      if (toks.size() == 0) {
        items.add(item);
        continue;
      }
      JMenu categoryMenu = null;
      String catSoFar = "";
      String menuCategory = "";
      for (int catIdx = 0; catIdx < toks.size(); catIdx++) {
        String subCat = (String) toks.get(catIdx);
        catSoFar = catSoFar + "/" + subCat;
        JMenu m = (JMenu) categories.get(catSoFar);
        if (m == null) {
          m = new JMenu(subCat);
          menuCategory = catSoFar;
          categories.put(catSoFar, m);
          if (categoryMenu != null) {
            categoryMenu.add(m, 0);
          } else {
            subMenus.add(m);
          }
        }
        categoryMenu = m;
      }
      if (categoryMenu == null) {
        categoryMenu = new JMenu("");
        categories.put(toks.toString(), categoryMenu);
        subMenus.add(categoryMenu);
        menuCategory = toks.toString();
      }
      categoryMenu.add(item);
    }
    items.addAll(subMenus);
    return items;
  }
Exemplo n.º 24
0
  public static void main(String[] args) {
    List<Integer> intList = Arrays.asList(1, 2, 3);
    fillWithFirst(intList);
    assert intList.toString().equals("[1, 1, 1]");

    List<String> strList = Arrays.asList("one", "two", "three");
    fillWithFirst(strList);
    assert strList.toString().equals("[one, one, one]");
  }
Exemplo n.º 25
0
 public String toString() {
   String ans;
   if (this.exchangeUnitType == ExchangeUnitType.altruistic) {
     ans = "{" + donor.toString() + "}";
   } else {
     ans = "{" + receiver.toString() + ", " + donor.toString() + "}";
   }
   return CharMatcher.is(',').replaceFrom(ans, '-');
 }
  /**
   * This will have an intent receiver which will call methods that are registered. like the on
   * receive of the sdlcommon
   *
   * @param intent
   */
  public void callMethod(Intent intent) {
    // check the intent
    if (intent != null) {
      String msg = (String) intent.getSerializableExtra("message");
      Message message = Message.parseMessage(msg);

      if (message != null) {
        Log.e(TAG, "Receive a message from android comm proc");
        Log.d(TAG, "Action: " + message.getAction() + " Trigger: " + message.getTriggerName());

        System.out.print(service.getTriggers().toString());
        List<String> idList = message.getServiceIds();
        List<String> typeList = message.getServiceTypes();
        Set<Service> set = new HashSet<Service>();

        try {
          Log.e(TAG, idList.toString() + " " + typeList.toString());
          checkServiceIds(idList, set);
          checkServiceTypes(typeList, set);

          // if there is match for id or type and property is not specified
          if (set.size() > 0 && message.getProperties().size() == 0) {
            if (message.getAction() != null) performActions(message);
            else performTriggers(message);
          }
          // if there is match for id or type and property is specified
          else if (set.size() > 0 && message.getProperties().size() > 0) {
            Set<Service> list = new HashSet<Service>();
            for (String propertyName : message.getProperties()) {
              if (service.isPropertyMatching(
                  propertyName, message.getPropertyAttributes(propertyName))) list.add(service);
              else break;
            }
            if (!list.isEmpty()) {
              // not the set only contains services that have matching properties.
              if (message.getAction() != null) performActions(message);
              else performTriggers(message);
            }
          }
          // if type and id are not specified, perform actions or triggers
          else if (idList.size() == 0 && typeList.size() == 0)
            if (message.getAction() != null) performActions(message);
            else performTriggers(message);

        } catch (IllegalArgumentException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (IllegalAccessException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        } catch (InvocationTargetException e1) {
          // TODO Auto-generated catch block
          e1.printStackTrace();
        }
      }
    }
  }
Exemplo n.º 27
0
 private static void correctListToCheck(
     Splitter splitter, String text, @NotNull String... expected) {
   List<String> words = wordsToCheck(splitter, text);
   List<String> expectedWords = Arrays.asList(expected);
   assertEquals(
       "Splitting:'" + text + "'",
       expectedWords.toString(),
       words != null ? words.toString() : "[]");
 }
  public void testConfigureCamelCaseTokenFilter() throws IOException {
    Settings settings =
        Settings.builder()
            .put(Environment.PATH_HOME_SETTING.getKey(), createTempDir().toString())
            .build();
    Settings indexSettings =
        Settings.builder()
            .put(IndexMetaData.SETTING_VERSION_CREATED, Version.CURRENT)
            .put("index.analysis.filter.wordDelimiter.type", "word_delimiter")
            .put("index.analysis.filter.wordDelimiter.split_on_numerics", false)
            .put("index.analysis.analyzer.custom_analyzer.tokenizer", "whitespace")
            .putArray(
                "index.analysis.analyzer.custom_analyzer.filter", "lowercase", "wordDelimiter")
            .put("index.analysis.analyzer.custom_analyzer_1.tokenizer", "whitespace")
            .putArray(
                "index.analysis.analyzer.custom_analyzer_1.filter", "lowercase", "word_delimiter")
            .build();

    IndexSettings idxSettings = IndexSettingsModule.newIndexSettings("index", indexSettings);

    IndexAnalyzers indexAnalyzers =
        new AnalysisModule(new Environment(settings), emptyList())
            .getAnalysisRegistry()
            .build(idxSettings);
    try (NamedAnalyzer custom_analyser = indexAnalyzers.get("custom_analyzer")) {
      assertNotNull(custom_analyser);
      TokenStream tokenStream = custom_analyser.tokenStream("foo", "J2SE j2ee");
      tokenStream.reset();
      CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class);
      List<String> token = new ArrayList<>();
      while (tokenStream.incrementToken()) {
        token.add(charTermAttribute.toString());
      }
      assertEquals(token.toString(), 2, token.size());
      assertEquals("j2se", token.get(0));
      assertEquals("j2ee", token.get(1));
    }

    try (NamedAnalyzer custom_analyser = indexAnalyzers.get("custom_analyzer_1")) {
      assertNotNull(custom_analyser);
      TokenStream tokenStream = custom_analyser.tokenStream("foo", "J2SE j2ee");
      tokenStream.reset();
      CharTermAttribute charTermAttribute = tokenStream.addAttribute(CharTermAttribute.class);
      List<String> token = new ArrayList<>();
      while (tokenStream.incrementToken()) {
        token.add(charTermAttribute.toString());
      }
      assertEquals(token.toString(), 6, token.size());
      assertEquals("j", token.get(0));
      assertEquals("2", token.get(1));
      assertEquals("se", token.get(2));
      assertEquals("j", token.get(3));
      assertEquals("2", token.get(4));
      assertEquals("ee", token.get(5));
    }
  }
 @Override
 public String toString() {
   return "GpodnetSubscriptionChange [added="
       + added.toString()
       + ", removed="
       + removed.toString()
       + ", timestamp="
       + timestamp
       + "]";
 }
Exemplo n.º 30
0
 /**
  * Gets the probability of a tag, given the n-1 previous tags
  *
  * @param nGram
  * @return
  */
 public double getTransitionProb(List<String> nGram) {
   if (!nGramCount.containsKey(nGram.toString())) return 0;
   if (n > 1) {
     ArrayList<String> nGramMini = new ArrayList<String>();
     nGramMini.addAll(nGram);
     nGramMini.remove(0);
     return (double) nGramCount.get(nGram.toString())
         / nMinusOneGramCount.get(nGramMini.toString());
   } else return nGramCount.get(nGram) / (double) pairs.size();
 }