public void parse(Configuration configuration, Sheet sheet, Entity entity) {
    int startRow = NumberUtils.toInt(configuration.getStartRow());

    while (true) {

      String logicalName =
          ParserUtils.getCellValue(sheet, startRow, configuration.getAttributeLogicalCol());
      String physicalName =
          ParserUtils.getCellValue(sheet, startRow, configuration.getAttributePhysicalCol());

      if (ParserUtils.isEmptyBoth(logicalName, physicalName) || startRow > EXCEL_LIMIT_ROW) {
        break;
      }

      Attribute attr = new Attribute();
      attr.setLogicalName(logicalName);
      attr.setPhysicalName(physicalName);

      parsePrimaryKey(configuration, sheet, startRow, attr);

      parseNotNull(configuration, sheet, startRow, attr);

      parseDataType(configuration, sheet, startRow, attr);

      parseLength(configuration, sheet, startRow, attr);

      parseDefaultValue(configuration, sheet, startRow, attr);

      parseDefinition(configuration, sheet, startRow, attr);

      entity.addAttribute(attr);
      startRow++;
    }
    ;
  }
예제 #2
0
  @Test
  public void testGetAlignmentSets() throws Exception {
    AMR amr = new AMR();
    AMR.Node root = amr.addNode("r", "root");
    AMR.Node child1 = amr.addNode("c1", "child1");
    AMR.Node child2 = amr.addNode("c2", "child2");
    AMR.Arc arc1 = amr.addArc(root, child1, "arc1");
    AMR.Arc arc2 = amr.addArc(root, child2, "arc2");

    child1.alignment = 0;
    root.alignment = 1;
    child2.alignment = 2;

    Map<Integer, Set<AMR.Node>> alignmentSets = ParserUtils.getAlignmentSets(amr);
    assertEquals(1, alignmentSets.get(0).size());
    assertEquals(child1, alignmentSets.get(0).iterator().next());
    assertEquals(1, alignmentSets.get(1).size());
    assertEquals(root, alignmentSets.get(1).iterator().next());
    assertEquals(1, alignmentSets.get(2).size());
    assertEquals(child2, alignmentSets.get(2).iterator().next());

    child2.alignment = 0;

    alignmentSets = ParserUtils.getAlignmentSets(amr);
    assertEquals(2, alignmentSets.get(0).size());
    assertTrue(alignmentSets.get(0).contains(child1));
    assertTrue(alignmentSets.get(0).contains(child2));
    assertEquals(1, alignmentSets.get(1).size());
    assertEquals(root, alignmentSets.get(1).iterator().next());
  }
예제 #3
0
  /**
   * Parses the input; looks for the appropriate header. Then parses the position list until no more
   * positions can be found.
   */
  private void parseInput(String input) throws IOException, PatternSyntaxException {
    // search for header input. once found, shuttle all input to the appropriate
    // handler type.
    Pattern pp1 = Pattern.compile(HEADER_REGEX_1);
    Pattern pp2 = Pattern.compile(HEADER_REGEX_2);

    // init
    final List<PositionInfo> posList = new LinkedList<PositionInfo>();
    BufferedReader br = new BufferedReader(new StringReader(input));

    // header parse loop
    String line = ParserUtils.getNextLongLine(br);
    while (line != null) {
      Matcher m = pp1.matcher(line);
      if (m.lookingAt()) {
        phase = makePhase(null, m.group(1), m.group(2));
        parsePositions(br, posList);
        break;
      }

      m = pp2.matcher(line);
      if (m.lookingAt()) {
        phase = makePhase(m.group(1), m.group(2), m.group(3));
        parsePositions(br, posList);
        break;
      }

      line = ParserUtils.getNextLongLine(br);
    }

    // cleanup & create array
    br.close();
    posInfo = posList.toArray(new PositionInfo[posList.size()]);
  } // parseInput()
 private void parseLength(Configuration configuration, Sheet sheet, int startRow, Attribute attr) {
   String value = ParserUtils.getCellValue(sheet, startRow, configuration.getLengthCol());
   if (StringUtils.isNotEmpty(value)) {
     if (ParserUtils.isDouble(value)) {
       value = String.valueOf((int) Double.parseDouble(value));
     }
     attr.setLength(value);
   }
 }
  @Nonnull
  public JsclVector parse(@Nonnull Parameters p, @Nullable Generic previousSumElement)
      throws ParseException {
    int pos0 = p.position.intValue();

    ParserUtils.skipWhitespaces(p);

    ParserUtils.tryToParse(p, pos0, ',');

    return ParserUtils.parseWithRollback(VectorParser.parser, pos0, previousSumElement, p);
  }
예제 #6
0
  /**
   * Parse search results from a search result site
   *
   * @param pUrl
   */
  private void parseSearchResults(String pUrl) {
    LOGGER.info("Started parsing: " + pUrl);
    Document doc = null;

    doc = ParserUtils.connectGetUrl(ParserUtils.getUri(pUrl).toASCIIString());
    doc.setBaseUri(DEFAULT_VSP_URL);
    Elements results = doc.select("div[class*=map-list-item]");
    for (Element result : results) {
      PersistentEntity ent = new PersistentEntity();
      Elements infoElement = result.select("div[class*=info-content]");
      LOGGER.debug(infoElement.select("p[class*=establishment-category]").first().ownText());
      String tmp =
          result
              .select("div[class*=info-content]")
              .select("p[class*=establishment-category]")
              .first()
              .ownText();

      ent.setIndustry(new Utf8(tmp.split("/")[0]));
      ent.setLabel(new Utf8(tmp));
      // getting same as value to where it is
      EylloLink link =
          ParserUtils.detectUrl(
              infoElement.select("p[class*=establishment-name]").select("a").first());
      if (link != null) {
        LOGGER.debug(DEFAULT_VSP_URL + link.getLinkHref());
        ent.putToSameAs(
            new Utf8(DEFAULT_VSP_URL + link.getLinkHref()), new Utf8(link.getLinkText()));
        ent.setName(new Utf8(link.getLinkText()));
      }
      // getting its address and phone
      PersistentPoint point = new PersistentPoint();
      infoElement = result.select("div[class*=establishment-details]").select("p");
      ent.addToTelephones(new Utf8(infoElement.get(0).ownText()));
      point.setAddress(new Utf8(infoElement.get(0).text()));
      if (!result.attr("data-lng").toString().equals("")
          && !result.attr("data-lat").toString().equals("")) {
        // Format in [lon, lat], note, the order of lon/lat here in order to conform with GeoJSON.
        point.addToCoordinates(Double.parseDouble(result.attr("data-lng")));
        point.addToCoordinates(Double.parseDouble(result.attr("data-lat")));
        point.setAccuracy(EylloLocation.GEOCODER_VERIF_ACC_HIGH);
      }
      ent.setPersistentpoint(point);
      ent.addToScenarioId(getScenarioId());

      this.pEntities.add(ent);
    }
    LOGGER.info("Completed getting basic information from entities.");
  }
 private void parseDefaultValue(
     Configuration configuration, Sheet sheet, int startRow, Attribute attr) {
   String value = ParserUtils.getCellValue(sheet, startRow, configuration.getDefaultValueCol());
   if (StringUtils.isNotEmpty(value)) {
     attr.setDefaultValue(value);
   }
 }
예제 #8
0
  public static WorksheetEntry fromParser(XmlPullParser parser)
      throws XmlPullParserException, IOException {
    final int depth = parser.getDepth();
    final WorksheetEntry entry = new WorksheetEntry();

    String tag = null;
    int type;
    while (((type = parser.next()) != END_TAG || parser.getDepth() > depth)
        && type != END_DOCUMENT) {
      if (type == START_TAG) {
        tag = parser.getName();
        if (LINK.equals(tag)) {
          final String rel = parser.getAttributeValue(null, REL);
          final String href = parser.getAttributeValue(null, HREF);
          if (REL_LISTFEED.equals(rel)) {
            entry.mListFeed = href;
          }
        }
      } else if (type == END_TAG) {
        tag = null;
      } else if (type == TEXT) {
        final String text = parser.getText();
        if (TITLE.equals(tag)) {
          entry.mTitle = text;
        } else if (UPDATED.equals(tag)) {
          entry.mUpdated = ParserUtils.parseTime(text);
        }
      }
    }
    return entry;
  }
예제 #9
0
 public static ExtensionElement parseExtensionElement(
     String str, String str2, XmlPullParser xmlPullParser)
     throws XmlPullParserException, IOException, SmackException {
   ParserUtils.assertAtStartTag(xmlPullParser);
   ExtensionElementProvider extensionProvider = ProviderManager.getExtensionProvider(str, str2);
   if (extensionProvider == null) {
     int depth = xmlPullParser.getDepth();
     ExtensionElement defaultExtensionElement = new DefaultExtensionElement(str, str2);
     while (true) {
       switch (xmlPullParser.next()) {
         case VideoSize.HVGA /*2*/:
           String name = xmlPullParser.getName();
           if (!xmlPullParser.isEmptyElementTag()) {
             if (xmlPullParser.next() != 4) {
               break;
             }
             defaultExtensionElement.setValue(name, xmlPullParser.getText());
             break;
           }
           defaultExtensionElement.setValue(name, "");
           break;
         case Version.API03_CUPCAKE_15 /*3*/:
           if (xmlPullParser.getDepth() != depth) {
             break;
           }
           return defaultExtensionElement;
         default:
           break;
       }
     }
   }
   return (ExtensionElement) extensionProvider.parse(xmlPullParser);
 }
예제 #10
0
  /** Parses the positions. */
  private void parsePositions(BufferedReader br, final List<PositionInfo> posList)
      throws IOException, PatternSyntaxException {
    Pattern mrp = Pattern.compile(PARSE_REGEX);

    String line = ParserUtils.getNextLongLine(br);
    while (line != null) {
      Matcher m = mrp.matcher(line);
      if (m.find()) {
        posList.add(new PositionInfo(m.group(1), m.group(2), ParserUtils.filter(m.group(3))));
      } else {
        // parse failed; break out of loop
        break;
      }

      line = ParserUtils.getNextLongLine(br);
    }
  } // parsePositions()
 public void kabelDeutschlandRedirect() throws Exception {
   final URL url =
       ParserUtils.testRedirect(
           context,
           "<script type=\"text/javascript\"> window.location = \"http://www.hotspot.kabeldeutschland.de/portal/?RequestedURI=http%3A%2F%2Fwww.fahrinfo-berlin.de%2FFahrinfo%2Fbin%2Fajax-getstop.bin%2Fdny%3Fgetstop%3D1%26REQ0JourneyStopsS0A%3D255%26REQ0JourneyStopsS0G%3Dgneisenustra%25DFe%3F%26js%3Dtrue&RedirectReason=Policy&RedirectAqpId=100&DiscardAqpId=100&SubscriberId=4fa432d4a653e5f8b2acb27aa862f98d&SubscriberType=ESM&ClientIP=10.136.25.241&SystemId=10.143.181.2-1%2F2&GroupId=1&PartitionId=2&Application=Unknown&ApplicationGroup=Unknown\" </script>");
   assertNotNull(url);
   assertEquals("www.hotspot.kabeldeutschland.de", url.getHost());
 }
 @Test
 public void testTemplateComplete() throws IOException, PrivateEc2ParserException {
   InputStream templateStream =
       ClassLoader.getSystemResourceAsStream("./cfn_templates/complete.template");
   ToStringBuilder.setDefaultStyle(ToStringStyle.SHORT_PREFIX_STYLE);
   PrivateEc2Template template = ParserUtils.mapJson(PrivateEc2Template.class, templateStream);
   assertNotNull(template);
 }
 @Test
 public void testTemplateWithTags() throws IOException, PrivateEc2ParserException {
   InputStream templateStream =
       ClassLoader.getSystemResourceAsStream("./cfn_templates/tags.template");
   PrivateEc2Template template = ParserUtils.mapJson(PrivateEc2Template.class, templateStream);
   assertNotNull(template);
   assertNotNull(template.getEC2Instance().getProperties().getTags());
   assertFalse(template.getEC2Instance().getProperties().getTags().isEmpty());
 }
 @Test
 public void vodafoneRedirect() throws Exception {
   final URL url =
       ParserUtils.testRedirect(
           context,
           "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN \" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"; xml:lang=\"en\"><head><title>Vodafone Center</title><meta http-equiv=\"Cache-Control\" content=\"no-cache\"/><meta http-equiv=\"refresh\" content=\"1;URL=https://center.vodafone.de/vfcenter/index.html?targetUrl=http%3A%2F%2Fwww.fahrinfo-berlin.de/Fahrinfo/bin/query.bin/dn%3fstart=Suchen&REQ0JourneyStopsS0ID=A%253D1%2540L%253D9083301&REQ0JourneyStopsZ0ID=A%253D1%2540L%253D9195009&REQ0HafasSearchForw=1&REQ0JourneyDate=16.06.14&REQ0JourneyTime=16%253A32&REQ0JourneyProduct_prod_list_1=11111011&h2g-direct=11&L=vs_oeffi\"/><style type=\"text/css\">*{border:none;font-family:Arial,Helvetica,sans-serif} body{font-size:69%;line-height:140%;background-color:#F4F4F4 !important}</style></head><body><h1>Sie werden weitergeleitet ...</h1><p>Sollten Sie nicht weitergeleitet werden, klicken Sie bitte <a href=\"https://center.vodafo");
   assertNotNull(url);
   assertEquals("center.vodafone.de", url.getHost());
 }
 @Test
 public void tplinkRedirect() throws Exception {
   final URL url =
       ParserUtils.testRedirect(
           context,
           "<body><script language=\"javaScript\">location.href=\"http://tplinkextender.net/\";</script></body></html>");
   assertNotNull(url);
   assertEquals("tplinkextender.net", url.getHost());
 }
 @Test
 public void mshtmlRedirect() throws Exception {
   final URL url =
       ParserUtils.testRedirect(
           context,
           "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\"><HEAD><TITLE>HTML Redirection</TITLE><META http-equiv=Content-Type content=\"text/html; \"><META http-equiv=Refresh content=\"0;URL=/cgi-bin/index.cgi\"><META content=\"MSHTML 6.00.2900.2873\" name=GENERATOR></HEAD><BODY >  <NOSCRIPT>   If your browser can not redirect you to home page automatically.<br>   Please click <a href=/cgi-bin/welcome.cgi?lang=0>here</a>.   </NOSCRIPT></BODY></HTML>");
   assertNotNull(url);
   assertEquals("example.com", url.getHost());
 }
예제 #17
0
  @Override
  public int parse(List<String> mergedLines, int index) {
    boolean elseReached = false;

    int i = index;
    for (int ii = mergedLines.size(); i < ii; ++i) {
      String line = mergedLines.get(i);

      String clearLine;
      if (line.startsWith("--")) {
        clearLine = ParserUtils.substr(line, "--".length());
      } else {
        Matcher matcher = ParserUtils.inlineComment.matcher(line);
        if (matcher.matches()) {
          clearLine = matcher.group(1).trim();
        } else {
          multiPart.addPart(new LiteralPart(line));
          continue;
        }
      }

      if ("end".equalsIgnoreCase(clearLine)) {
        newCondition();
        return i + 1;
      }

      if ("else".equalsIgnoreCase(clearLine)) {
        newCondition();
        lastCondExpr = "true";
        elseReached = true;
        continue;
      }

      Matcher matcher = elseIfPattern.matcher(clearLine);
      if (matcher.matches()) { // else if
        if (elseReached) throw new RuntimeException("syntax error, else if position is illegal");

        newCondition();
        lastCondExpr = EqlUtils.trimToEmpty(matcher.group(1));
        if (EqlUtils.isBlank(lastCondExpr))
          throw new RuntimeException("syntax error, no condition in else if");

        continue;
      }

      PartParser partParser = PartParserFactory.tryParse(clearLine);
      if (partParser != null) {
        i = partParser.parse(mergedLines, i + 1) - 1;
        multiPart.addPart(partParser.createPart());
      }
    }

    return i;
  }
 @Test
 public void test() throws Exception {
   String templateFile = "./cfn_templates/WordPress_Single_Instance_With_RDS.template";
   InputStream templateStream = ClassLoader.getSystemResourceAsStream(templateFile);
   PrivateEc2Template template = ParserUtils.mapJson(PrivateEc2Template.class, templateStream);
   assertNotNull(template);
   assertNotNull(template.getEC2Instance());
   assertNotNull(template.getEC2Instance().getProperties());
   assertNotNull(template.getEC2Instance().getProperties().getImageId().getValue());
   assertNull(template.getEC2Volume(null));
 }
예제 #19
0
  @Test
  public void testIsAlignmentChunkable() throws Exception {
    AMR amr = new AMR();
    AMR.Node root = amr.addNode("r", "root");
    AMR.Node child1 = amr.addNode("c1", "child1");
    AMR.Node child2 = amr.addNode("c2", "child2");
    AMR.Arc arc1 = amr.addArc(root, child1, "arc1");
    AMR.Arc arc2 = amr.addArc(root, child2, "arc2");

    child1.alignment = 0;
    root.alignment = 1;
    child2.alignment = 2;

    assertEquals(true, ParserUtils.isAlignmentChunkable(amr));

    child2.alignment = 0;
    assertEquals(false, ParserUtils.isAlignmentChunkable(amr));

    child1.alignment = 1;
    assertEquals(true, ParserUtils.isAlignmentChunkable(amr));
  }
 protected void writeLong(long val2) {
   int digits = ParserUtils.digits(val2);
   // starting from the end, write each digit
   for (int i = digits - 1; i >= 0; i--) {
     // write the lowest digit.
     buffer.put(buffer.position() + i, (byte) (val2 % 10 + '0'));
     // remove that digit.
     val2 /= 10;
   }
   assert val2 == 0;
   // move the position to after the digits.
   buffer.position(buffer.position() + digits);
 }
예제 #21
0
 /** returns the parameters used in this statement's expressions and in the whereClause. */
 public Vector getParameters() {
   Vector v = new Vector();
   Enumeration valenum = getValues().elements();
   while (valenum.hasMoreElements()) {
     tsResultRow row = (tsResultRow) valenum.nextElement();
     for (int i = 0; i < row.size(); i++) {
       tsColumn col = row.getColumnDefinition(i);
       if (col.getColumnType() == tsColumn.COL_EXPR) {
         ParserUtils.getParameterElements(v, col.getExpression());
       }
     }
   }
   return v;
 }
  @Nullable
  public String parse(@Nonnull Parameters p, Generic previousSumElement) throws ParseException {
    final int pos0 = p.position.intValue();

    ParserUtils.skipWhitespaces(p);

    if (p.position.intValue() < p.expression.length()
        && p.expression.startsWith(name, p.position.intValue())) {
      p.position.add(name.length());
      return name;
    } else {
      p.position.setValue(pos0);
      return null;
    }
  }
 @Test
 public void testJoinTemplate() throws IOException, PrivateEc2ParserException {
   InputStream templateStream =
       ClassLoader.getSystemResourceAsStream("./cfn_templates/join.template");
   PrivateEc2Template template = ParserUtils.mapJson(PrivateEc2Template.class, templateStream);
   assertNotNull(template);
   assertNotNull(template);
   assertNotNull(template.getEC2Instance());
   assertNotNull(template.getEC2Instance().getProperties());
   assertNotNull(template.getEC2Instance().getProperties().getAvailabilityZone());
   assertNotNull(template.getEC2Instance().getProperties().getUserData());
   assertEquals(
       "export NIC_ADDR=`hostname`\nexport JAVA_HOME=/home/ubuntu/java\n",
       template.getEC2Instance().getProperties().getUserData().getValue());
 }
 /**
  * @throws IOException
  * @throws PrivateEc2ParserException
  */
 @Test
 public void testTemplateWithEBS() throws IOException, PrivateEc2ParserException {
   InputStream templateStream =
       ClassLoader.getSystemResourceAsStream("./cfn_templates/EC2WithEBSSample.template");
   PrivateEc2Template template = ParserUtils.mapJson(PrivateEc2Template.class, templateStream);
   assertNotNull(template);
   assertNotNull(template.getEC2Instance());
   assertNotNull(template.getEC2Instance().getProperties());
   assertNotNull(template.getEC2Instance().getProperties().getVolumes());
   assertEquals(1, template.getEC2Instance().getProperties().getVolumes().size());
   assertNotNull(template.getEC2Instance().getProperties().getVolumes().get(0).getVolumeId());
   assertNotNull(
       "NewVolume",
       template.getEC2Instance().getProperties().getVolumes().get(0).getVolumeId().getValue());
   assertNotNull(template.getEC2Volume("NewVolume"));
 }
  public DataAttributeDefinition(Node node) throws SclParserException {
    this.name = ParserUtils.parseAttribute(node, "name");
    this.bType = ParserUtils.parseAttribute(node, "bType");
    this.type = ParserUtils.parseAttribute(node, "type");
    String fcString = ParserUtils.parseAttribute(node, "fc");

    if (this.name == null) throw new SclParserException(node, "attribute name is missing");

    if (fcString != null) this.fc = FunctionalConstraint.createFromString(fcString);

    if (this.bType == null) throw new SclParserException(node, "attribute bType is missing");
    else {
      if (this.bType.equals("Tcmd")) this.type = "Tcmd";
      else if (this.bType.equals("Dbpos")) this.type = "Dbpos";
      else if (this.bType.equals("Check")) this.type = "Check";

      attributeType = AttributeType.createFromSclString(this.bType);
    }

    boolean dchgTrigger = false;
    boolean qchgTrigger = false;
    boolean dupdTrigger = false;

    String dchg = ParserUtils.parseAttribute(node, "dchg");

    if (dchg != null) dchgTrigger = new Boolean(dchg);

    String dupd = ParserUtils.parseAttribute(node, "dupd");

    if (dupd != null) dupdTrigger = new Boolean(dupd);

    String qchg = ParserUtils.parseAttribute(node, "qchg");

    if (qchg != null) qchgTrigger = new Boolean(qchg);

    this.triggerOptions = new TriggerOptions(dchgTrigger, qchgTrigger, dupdTrigger, false, false);

    String countStr = ParserUtils.parseAttribute(node, "count");
    if (countStr != null) count = new Integer(countStr);
  }
예제 #26
0
 public static Feature parseSessionFeature(XmlPullParser xmlPullParser)
     throws XmlPullParserException, IOException {
   boolean z;
   ParserUtils.assertAtStartTag(xmlPullParser);
   int depth = xmlPullParser.getDepth();
   if (xmlPullParser.isEmptyElementTag()) {
     z = $assertionsDisabled;
   } else {
     z = false;
     while (true) {
       switch (xmlPullParser.next()) {
         case VideoSize.HVGA /*2*/:
           String name = xmlPullParser.getName();
           Object obj = -1;
           switch (name.hashCode()) {
             case -79017120:
               if (name.equals(Feature.OPTIONAL_ELEMENT)) {
                 obj = null;
                 break;
               }
               break;
           }
           switch (obj) {
             case VideoSize.QCIF /*0*/:
               z = true;
               break;
             default:
               continue;
           }
         case Version.API03_CUPCAKE_15 /*3*/:
           if (xmlPullParser.getDepth() == depth) {
             break;
           }
           continue;
         default:
           continue;
       }
     }
   }
   return new Feature(z);
 }
예제 #27
0
 /**
  * Conference config date setup uses {@link ParserUtils#parseTime(String)}, so mocking the output.
  */
 private void setUpParserUtils() {
   PowerMockito.mockStatic(ParserUtils.class);
   long conferenceDayDuration = 12 * TimeUtils.HOUR;
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY1_START)).willReturn(0L);
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY1_END))
       .willReturn(conferenceDayDuration);
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY2_START))
       .willReturn((long) (24 * TimeUtils.HOUR));
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY2_END))
       .willReturn((long) (24 * TimeUtils.HOUR) + conferenceDayDuration);
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY3_START))
       .willReturn((long) (2 * 24 * TimeUtils.HOUR));
   BDDMockito.given(ParserUtils.parseTime(BuildConfig.CONFERENCE_DAY3_END))
       .willReturn((long) (2 * 24 * TimeUtils.HOUR) + conferenceDayDuration);
 }
예제 #28
0
  @Test
  public void testAlignmentChunksAndArcs() throws Exception {
    AMR amr = new AMR();
    AMR.Node root = amr.addNode("r", "root");
    AMR.Node child1 = amr.addNode("c1", "child1");
    AMR.Node child2 = amr.addNode("c2", "child2");
    AMR.Arc arc1 = amr.addArc(root, child1, "arc1");
    AMR.Arc arc2 = amr.addArc(root, child2, "arc2");
    amr.sourceText = new String[] {"he", "ran", "dog"};

    child1.alignment = 0;
    root.alignment = 1;
    child2.alignment = 2;

    Pair<AMR[], List<ParserUtils.ChunkArc>> pair = ParserUtils.alignmentChunksAndArcs(amr);
    AMR[] chunks = pair.first;
    List<ParserUtils.ChunkArc> chunkArcs = pair.second;

    assertEquals(3, chunks.length);
    assertEquals(2, chunkArcs.size());
  }
예제 #29
0
 public static Stanza parseStanza(XmlPullParser xmlPullParser)
     throws XmlPullParserException, IOException, SmackException {
   ParserUtils.assertAtStartTag(xmlPullParser);
   String name = xmlPullParser.getName();
   Object obj = -1;
   switch (name.hashCode()) {
     case -1276666629:
       if (name.equals(Presence.ELEMENT)) {
         obj = 2;
         break;
       }
       break;
     case 3368:
       if (name.equals(IQ.IQ_ELEMENT)) {
         obj = 1;
         break;
       }
       break;
     case 954925063:
       if (name.equals(Message.ELEMENT)) {
         obj = null;
         break;
       }
       break;
   }
   switch (obj) {
     case VideoSize.QCIF /*0*/:
       return parseMessage(xmlPullParser);
     case VideoSize.CIF /*1*/:
       return parseIQ(xmlPullParser);
     case VideoSize.HVGA /*2*/:
       return parsePresence(xmlPullParser);
     default:
       throw new IllegalArgumentException("Can only parse message, iq or presence, not " + name);
   }
 }
 @Test
 public void internalError() throws Exception {
   assertTrue(
       ParserUtils.testInternalError(
           "<?xml version=\"1.0\"?>     <!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.0//EN\"    \"http://www.wapforum.org/DTD/xhtml-mobile10.dtd\">      <html xmlns=\"http://www.w3.org/1999/xhtml\">      <head>        <title>          Internal error in gateway     </title>       </head>       <body>        <h1>          Internal error in gateway     </h1>       </body>      </html>"));
 }