org.joox.Match类的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.joox.Match类的一些代码示例,展示了Match类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Match类的具体详情如下:
包路径:org.joox.Match
类名称:Match

Match介绍

[英]A wrapper type for org.w3c.dom.Element

This is the main type of the jOOX library. It wraps an ordered list of DOM elements without duplicates and provides useful operations upon all of the contained elements. The wrapped DOM elements have been previously "matched" by a jOOX operation.

The API has been inspired by http://jquery.com, a fantastic DOM abstraction library for JavaScript.
[中]组织的包装器类型。w3c。多姆。要素
这是jOOX库的主要类型。它包装了一个有序的DOM元素列表,没有重复项,并对所有包含的元素提供了有用的操作。包装好的DOM元素之前已经被jOOX操作“匹配”。
API的灵感来自http://jquery.com,这是一个很棒的JavaScript DOM抽象库。

代码示例

代码示例来源:origin: org.jboss.windup.rules/rules-impl

protected List<EnvironmentReference> processEnvironmentReference(Element element)
{
  List<EnvironmentReference> resources = new LinkedList<EnvironmentReference>();
  // find JMS references...
  List<Element> queueReferences = $(element).find("resource-ref").get();
  for (Element e : queueReferences)
  {
    String id = $(e).attr("id");
    String type = $(e).child("res-type").text();
    String name = $(e).child("res-ref-name").text();
    type = StringUtils.trim(type);
    name = StringUtils.trim(name);
    EnvironmentReference ref = envRefDao.createEnvironmentReference(name, type);
    ref.setReferenceId(id);
    resources.add(ref);
  }
  return resources;
}

代码示例来源:origin: org.jboss.windup.config/windup-config-xml

@Override
public Void processElement(ParserContext handlerManager, Element element)
{
  List<Element> children = $(element).children().get();
  for (Element child : children)
  {
    handlerManager.processElement(child);
  }
  return null;
}

代码示例来源:origin: windup/windup

@Override
public List<AddonId> processElement(ParserContext context, Element element) throws ConfigurationException
{
  List<Element> children = $(element).children().get();
  List<AddonId> addonIds = new ArrayList<>();
  for (Element child : children)
  {
    Object result = context.processElement(child);
    switch ($(child).tag())
    {
    case "addon":
      addonIds.add((AddonId)result);
      break;
    }
      }
  return addonIds;
}

代码示例来源:origin: windup/windup

private String extractChildTagAndTrim(Element element, String property)
  {
    String result = $(element).find(property).first().text();
    return StringUtils.trimToNull(result);
  }
}

代码示例来源:origin: org.jooq/joox-java-6

/**
 * Find the index among siblings of the same tag name
 */
private static final int siblingIndex(Element element) {
  // The document element has index 0
  if (element.getParentNode() == element.getOwnerDocument())
    return 0;
  // All other elements are compared with siblings with the same name
  // TODO: How to deal with namespaces here? Omit or keep?
  else
    return $(element).parent().children(element.getTagName()).get().indexOf(element);
}

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee

private Iterable<Element> findLocalBeanById(Document doc, String id)
{
  List<Element> elements = new LinkedList<>();
  elements.addAll($(doc).children().filter(attr("id", id)).get());
  if (elements.isEmpty())
  {
    elements.addAll($(doc).children().filter(attr("name", id)).get());
  }
  return elements;
}

代码示例来源:origin: stackoverflow.com

Match c = metadata.children();
for (int i = 0; i < c.size(); i++) {
  metadata_name = c.find("name").text();
  metadata_link_href = c.find("link").attr("href").toString();
  metadata_link_name = c.find("link").find("text").text();
  metadata_time = c.find("time").text();
rte2.children();
for(Match rtetag : rte2.children().each()) {
  if(rtetag.tag().equalsIgnoreCase("name")) {
    rtetag.text();
  if(rtetag.tag().equalsIgnoreCase("rtept")) {
    for(Match rtepttag : rtetag.children().andSelf().each()) {
      if(rtepttag.tag().equals("name")) {
        point_name = rtepttag.text();
      if(rtepttag.tag().equals("cmt")) {
        point_cmt = rtepttag.text();
      if(rtepttag.tag().equals("rtept")) {
        if(last_lon == null) {
          last_lon = point_lon;
          last_lat = point_lat;
        point_lat = rtepttag.attr("lat");
        point_lon = rtepttag.attr("lon");

代码示例来源:origin: org.jboss.windup.rules.apps/rules-java-ee

version = $(doc).attr("version");
  String namespace = $(doc).find("web-app").namespaceURI();
  if (StringUtils.isBlank(namespace))

代码示例来源:origin: windup/windup

private String extractJndiRefBeanName(Element bean)
{
  for (Element dataSource : $(bean).children("property").filter(attr("name", "dataSource")).get())
  {
    // read ref...
    String jndiRef = $(dataSource).attr("ref");
    if (StringUtils.isBlank(jndiRef))
    {
      LOG.info("Looking at ref child of property tag...");
      //look to see if the ref is a child of the property tag...
      jndiRef = $(dataSource).child("ref").attr("bean");
    }
    if(StringUtils.isNotBlank(jndiRef)) {
      return jndiRef;
    }
  }
  return null;
}

代码示例来源:origin: windup/windup

String id = $(element).attr("id");
List<Element> children = $(element).children().get();
for (Element child : children)
  switch ($(child).tag())

代码示例来源:origin: org.jooq/joox-java-6

@Override
  public String map(Context context) {
    return $(context).attr(attributeName);
  }
};

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee

private List<EnvironmentReferenceModel> processEnvironmentReference(GraphContext context, Element element)
{
  EnvironmentReferenceService environmentReferenceService = new EnvironmentReferenceService(context);
  List<EnvironmentReferenceModel> resources = new ArrayList<>();
  // find JMS references...
  for (Element resourceRef : $(element).find("resource-ref").get())
  {
    processElement(environmentReferenceService, resources, resourceRef, "res-type", "res-ref-name",  EnvironmentReferenceTagType.RESOURCE_REF);
  }
  for (Element resourceRef : $(element).find("ejb-ref").get())
  {
    processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_REF);
  }
  for (Element resourceRef : $(element).find("ejb-local-ref").get())
  {
    processElement(environmentReferenceService, resources, resourceRef, "ejb-ref-type", "ejb-ref-name", EnvironmentReferenceTagType.EJB_LOCAL_REF);
  }
  for (Element resourceRef : $(element).find("message-destination-ref").get())
  {
    processElement(environmentReferenceService, resources, resourceRef, "message-destination-type", "message-destination-ref-name", EnvironmentReferenceTagType.MSG_DESTINATION_REF);
  }
  return resources;
}

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-api

@Override
  public TechnologyMetadata processElement(ParserContext handlerManager, Element element) throws ConfigurationException
  {
    // create an anonymous class, because the technology handler is abstract.
    TechnologyReference technologyReference = new MetadataTechnologyHandler()
    {
    }.processElement(handlerManager, $(element).child("technology").get(0));

    JavaTechnologyMetadata javaTechnologyMetadata = new JavaTechnologyMetadata(technologyReference);
    List<Element> children = $(element).children(ADDITIONAL_CLASSPATH).get();
    for (Element child : children)
    {
      String additionalClasspath = child.getTextContent();
      additionalClasspath = FilenameUtils.separatorsToSystem(additionalClasspath);

      Path path = handlerManager.getXmlInputPath().getParent().resolve(additionalClasspath);
      javaTechnologyMetadata.addAdditionalClasspath(path);
    }

    return javaTechnologyMetadata;
  }
}

代码示例来源:origin: org.jboss.windup.rules/rules-impl

version = $(doc).find("web-app").first().attr("version");
  String namespace = $(doc).find("web-app").namespaceURI();
  if (StringUtils.isBlank(namespace))

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee

private Map<String, Integer> parseTxTimeout(Element elementRef, String ejbName)
{
  Map<String, Integer> transactionTimeouts = new HashMap<>();
  for (Element methodRef : $(elementRef).child("method-attributes").find("method").get())
  {
    String methodName = $(methodRef).child("method-name").content();
    String transactionTimeout = $(methodRef).child("transaction-timeout").content();
    if(StringUtils.isNotBlank(transactionTimeout)) {
      try {
        Integer txTimeout = Integer.parseInt(transactionTimeout);
        transactionTimeouts.put(methodName, txTimeout);
      }
      catch(Exception e) {
        LOG.info("EJB: "+ejbName+" contains bad reference to TX Timeout on Method: "+methodName);
      }
    }
  }
  return transactionTimeouts;
}

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee

private void processElement(EnvironmentReferenceService environmentReferenceService, List<EnvironmentReferenceModel> resources, Element element, String typeLocation, String nameLocation, EnvironmentReferenceTagType refType)
{
  String id = $(element).attr("id");
  String type = $(element).child(typeLocation).text();
  String name = $(element).child(nameLocation).text();
  type = StringUtils.trim(type);
  name = StringUtils.trim(name);
  EnvironmentReferenceModel ref = environmentReferenceService.findEnvironmentReference(name, refType);
  if (ref == null)
  {
    ref = environmentReferenceService.create();
    ref.setName(name);
    ref.setReferenceType(type);
    ref.setReferenceTagType(refType);
    LOG.info("Added: "+ref);
  }
  else {
    if(ref.getReferenceTagType() != null && (ref.getReferenceTagType() != refType)) {
      LOG.warning("Expected type: "+EnvironmentReferenceTagType.RESOURCE_REF +" but actually: "+ref.getReferenceType());
    }
  }
  ref.setReferenceId(id);
  resources.add(ref);
}

代码示例来源:origin: windup/windup

private void processBinding(EnvironmentReferenceService envRefService, JNDIResourceService jndiResourceService, Set<ProjectModel> applications,
      Element resourceRef, String tagName)
{
  String href = $(resourceRef).child(tagName).attr("href");
  String resourceId = StringUtils.substringAfterLast(href, "ejb-jar.xml#");
  String jndiLocation = $(resourceRef).attr("jndiName");
  if (StringUtils.isNotBlank(jndiLocation) && StringUtils.isNotBlank(resourceId))
  {
    JNDIResourceModel resource = jndiResourceService.createUnique(applications, jndiLocation);
    LOG.info("JNDI Name: " + jndiLocation + " to Resource: " + resourceId);
    // now, look up the resource which is resolved by DiscoverEjbConfigurationXmlRuleProvider
    for (EnvironmentReferenceModel ref : envRefService.findAllByProperty(EnvironmentReferenceModel.REFERENCE_ID, resourceId))
    {
      envRefService.associateEnvironmentToJndi(resource, ref);
    }
  }
}

代码示例来源:origin: org.jboss.windup.rules.apps/windup-rules-java-ee

private Map<String, Integer> parseTxTimeout(Element enterpriseBeanTag, String ejbName)
  {
    Map<String, Integer> transactionTimeouts = new HashMap<>();
    String transactionTimeoutSeconds = $(enterpriseBeanTag).child("transaction-descriptor").child("trans-timeout-seconds").text();
    String methodName = "*";
    if (StringUtils.isNotBlank(transactionTimeoutSeconds))
    {
      try
      {
        Integer txTimeout = Integer.parseInt(transactionTimeoutSeconds);
        transactionTimeouts.put(methodName, txTimeout);
      }
      catch (Exception e)
      {
        LOG.info("EJB: " + ejbName + " contains bad reference to TX Timeout on Method: " + methodName);
      }
    }

    return transactionTimeouts;
  }
}

代码示例来源:origin: org.jooq/joox-java-6

@Override
  public boolean filter(Context context) {
    return pattern.matcher($(context).text()).matches();
  }
};

代码示例来源:origin: org.jboss.windup.legacy.application/grapher

public void writeGraph(final OutputStream os) throws IOException {
  // read in the html template resource.
  InputStream is = this.getClass().getClassLoader().getResourceAsStream("dagred3/HtmlTemplate.html");
  String result;
  {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    writer.writeGraph(baos);
    result = baos.toString();
  }
  
  if(LOG.isDebugEnabled())  {
    LOG.debug("Graphlib: "+result);
  }
  
  
  // read the document.
  Document document;
  try {
    document = $(is).document();
    // append in the gexf.
    $(document).find("#graphlib-source").append(result);
    writeDocument(document, os);
  } catch (SAXException e) {
    throw new IOException("Exception loading document.", e);
  }
}

相关文章