public void testIsSerializable() throws JaxenException, IOException { BaseXPath path = new BaseXPath("//foo", new DocumentNavigator()); ByteArrayOutputStream out = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(out); oos.writeObject(path); oos.close(); assertTrue(out.toByteArray().length > 0); }
public Object evaluate(Object attributeName, Object pattern, Navigator nav) { List<Object> answer = new ArrayList<Object>(); String attributeValue = StringFunction.evaluate(attributeName, nav); String patternValue = StringFunction.evaluate(pattern, nav); // TODO: Ignore the pattern for now // Should do a type pattern test if ((attributeValue != null) && (attributeValue.length() > 0)) { DocumentNavigator dNav = (DocumentNavigator) nav; NodeRef nodeRef = new NodeRef(attributeValue); if (patternValue.equals("*")) { answer.add(dNav.getNode(nodeRef)); } else { QNamePattern qNamePattern = new JCRPatternMatch(patternValue, dNav.getNamespacePrefixResolver()); answer.addAll(dNav.getNode(nodeRef, qNamePattern)); } } return answer; } }
typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver()); boolean result = dNav.hasAspect(nodeRef, typeQName); return result;
typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver()); boolean result = dNav.isSubtypeOf(nodeRef, typeQName); return result;
public void testGetChildAxisIterator() throws UnsupportedAxisException { try { // Check true DocumentNavigator docNav = new DocumentNavigator(null, null, null, null, false, false); Iterator nodeIter = docNav.getChildAxisIterator(null, "true", "", null); assertNotNull(nodeIter); boolean value = (Boolean) nodeIter.next(); assertTrue("The true value should be returned. See MNT-10730", value); // Check false nodeIter = docNav.getChildAxisIterator(null, "false", "", null); assertNotNull(nodeIter); value = (Boolean) nodeIter.next(); assertFalse("The false value should be returned. See MNT-10730", value); } catch (NullPointerException exp) { fail("The boolean value should be returned. See MNT-10730"); } } }
namespacePrefixResolver.registerNamespace(BaseNodeServiceTest.TEST_PREFIX, BaseNodeServiceTest.NAMESPACE); DocumentNavigator documentNavigator = new DocumentNavigator(dictionaryService, nodeService, searcher, namespacePrefixResolver, false, false); documentNavigator.setFollowAllParentLinks(true); documentNavigator.setFollowAllParentLinks(false);
public Object evaluate(List nodes, Object pattern, Navigator nav) { if (nodes.size() != 1) { return false; } QName qname = null; NodeRef nodeRef = null; if (nav.isElement(nodes.get(0))) { qname = null; // should use all attributes and full text index nodeRef = ((ChildAssociationRef) nodes.get(0)).getChildRef(); } else if (nav.isAttribute(nodes.get(0))) { qname = QName.createQName( nav.getAttributeNamespaceUri(nodes.get(0)), ISO9075.decode(nav.getAttributeName(nodes.get(0)))); nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent; } String patternValue = StringFunction.evaluate(pattern, nav); DocumentNavigator dNav = (DocumentNavigator) nav; return dNav.contains(nodeRef, qname, patternValue, SearchParameters.OR); } }
return dNav.like(car.getChildRef(), qname, pattern, includeFts);
for (String prefix : documentNavigator.getNamespacePrefixResolver().getPrefixes()) addNamespace(prefix, documentNavigator.getNamespacePrefixResolver().getNamespaceURI(prefix));
typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver()); boolean result = dNav.isSubtypeOf(nodeRef, typeQName); return result;
public Object evaluate(List nodes, Object pattern, Navigator nav) { if (nodes.size() != 1) { return false; } QName qname = null; NodeRef nodeRef = null; if (nav.isElement(nodes.get(0))) { qname = null; // should use all attributes and full text index nodeRef = ((ChildAssociationRef) nodes.get(0)).getChildRef(); } else if (nav.isAttribute(nodes.get(0))) { qname = QName.createQName( nav.getAttributeNamespaceUri(nodes.get(0)), ISO9075.decode(nav.getAttributeName(nodes.get(0)))); nodeRef = ((DocumentNavigator.Property) nodes.get(0)).parent; } String patternValue = StringFunction.evaluate(pattern, nav); DocumentNavigator dNav = (DocumentNavigator) nav; return dNav.contains(nodeRef, qname, patternValue, SearchParameters.OR); } }
return dNav.like(car.getChildRef(), qname, pattern, includeFts);
for (String prefix : documentNavigator.getNamespacePrefixResolver().getPrefixes()) addNamespace(prefix, documentNavigator.getNamespacePrefixResolver().getNamespaceURI(prefix));
final Java15Parser parser = new Java15Parser(); final FileInputStream stream = new FileInputStream("VehicleServiceType.java"); final Object c = parser.parse(new InputStreamReader(stream)); final XPath xpath = new BaseXPath("//TypeDeclaration/Annotation/NormalAnnotation[Name/@Image = 'WebService']", new DocumentNavigator()); for (final Iterator iter = xpath.selectNodes(c).iterator(); iter.hasNext();) { final Object obj = iter.next(); // Do code generation based on annotations... }
public Object evaluate(Object attributeName, Object pattern, Navigator nav) { List<Object> answer = new ArrayList<Object>(); String attributeValue = StringFunction.evaluate(attributeName, nav); String patternValue = StringFunction.evaluate(pattern, nav); // TODO: Ignore the pattern for now // Should do a type pattern test if ((attributeValue != null) && (attributeValue.length() > 0)) { DocumentNavigator dNav = (DocumentNavigator) nav; NodeRef nodeRef = new NodeRef(attributeValue); if (patternValue.equals("*")) { answer.add(dNav.getNode(nodeRef)); } else { QNamePattern qNamePattern = new JCRPatternMatch(patternValue, dNav.getNamespacePrefixResolver()); answer.addAll(dNav.getNode(nodeRef, qNamePattern)); } } return answer; } }
typeQName = QName.createQName(qnameStr, ((DocumentNavigator) nav).getNamespacePrefixResolver()); boolean result = dNav.hasAspect(nodeRef, typeQName); return result;
final Java15Parser parser = new Java15Parser(); final FileInputStream stream = new FileInputStream("VehicleServiceType.java"); final Object c = parser.parse(new InputStreamReader(stream)); final XPath xpath = new BaseXPath("//TypeDeclaration/Annotation/NormalAnnotation[Name/@Image = 'WebService']", new DocumentNavigator()); for (final Iterator iter = xpath.selectNodes(c).iterator(); iter.hasNext();) { final Object obj = iter.next(); // Do code generation based on annotations... }
DocumentNavigator documentNavigator = new DocumentNavigator(dictionaryService, nodeService, searchService, namespacePrefixResolver, followAllParentLinks); NodeServiceXPath nsXPath = new NodeServiceXPath(xpath, documentNavigator, paramDefs);
DocumentNavigator documentNavigator = new DocumentNavigator(dictionaryService, nodeService, searchService, namespacePrefixResolver, followAllParentLinks); NodeServiceXPath nsXPath = new NodeServiceXPath(xpath, documentNavigator, paramDefs);
DocumentNavigator documentNavigator = new DocumentNavigator(dictionaryService, nodeService, searchService, namespacePrefixResolver, followAllParentLinks); NodeServiceXPath nsXPath = new NodeServiceXPath(xpath, documentNavigator, paramDefs);