/** * Static factory method for creating a <code>TagTester</code> based on a tag name. Please note * that it will return the first tag which matches the criteria. * * @param markup * the markup to look for the tag to create the <code>TagTester</code> from the value * which the attribute must have * @return the <code>TagTester</code> which matches the tag by name in the markup */ public static TagTester createTagByName(String markup, String tagName) { List<TagTester> tester = createTags(markup, xmlTag -> xmlTag.getName().equalsIgnoreCase(tagName), true); if ((tester == null) || (tester.size() == 0)) { return null; } return tester.get(0); }
/** * Static factory method for creating a <code>TagTester</code> based on a tag name. Please note * that it will return the first tag which matches the criteria. * * @param markup * the markup to look for the tag to create the <code>TagTester</code> from the value * which the attribute must have * @return the <code>TagTester</code> which matches the tag by name in the markup */ public static TagTester createTagByName(String markup, String tagName) { List<TagTester> tester = createTags(markup, xmlTag -> xmlTag.getName().equalsIgnoreCase(tagName), true); if ((tester == null) || (tester.size() == 0)) { return null; } return tester.get(0); }
/** * Static factory method for creating a <code>TagTester</code> based on a tag found by an * attribute with a specific value. Please note that it will return the first tag which matches * the criteria. It's therefore good for attributes suck as "id" or "wicket:id", but only if * "wicket:id" is unique in the specified markup. * * @param markup * the markup to look for the tag to create the <code>TagTester</code> from * @param attribute * the attribute which should be on the tag in the markup * @param value * the value which the attribute must have * @param stopAfterFirst * if true search will stop after the first match * @return the <code>TagTester</code> which matches the tag in the markup, that has the given * value on the given attribute */ public static List<TagTester> createTagsByAttribute(String markup, String attribute, String value, boolean stopAfterFirst) { if (Strings.isEmpty(attribute) || Strings.isEmpty(value)) { return Collections.emptyList(); } return createTags(markup, xmlTag -> value.equals(xmlTag.getAttributes().get(attribute)), stopAfterFirst); }
/** * Static factory method for creating a <code>TagTester</code> based on a tag found by an * attribute with a specific value. Please note that it will return the first tag which matches * the criteria. It's therefore good for attributes suck as "id" or "wicket:id", but only if * "wicket:id" is unique in the specified markup. * * @param markup * the markup to look for the tag to create the <code>TagTester</code> from * @param attribute * the attribute which should be on the tag in the markup * @param value * the value which the attribute must have * @param stopAfterFirst * if true search will stop after the first match * @return the <code>TagTester</code> which matches the tag in the markup, that has the given * value on the given attribute */ public static List<TagTester> createTagsByAttribute(String markup, String attribute, String value, boolean stopAfterFirst) { if (Strings.isEmpty(attribute) || Strings.isEmpty(value)) { return Collections.emptyList(); } return createTags(markup, xmlTag -> value.equals(xmlTag.getAttributes().get(attribute)), stopAfterFirst); }