@Override protected String getDescription() { if (id != null) return "item identifier #" + id; else return "item identifier " + locator.getExternalForm(); } }
@Override protected String getDescription() { return "subject locator " + locator.getExternalForm(); } }
@Override protected String getDescription() { return "subject identifier " + locator.getExternalForm(); } }
@Override public String toString(LocatorIF loc) { return loc.getExternalForm(); } }
@Override public String toExternalForm() { return wrapped.getExternalForm(); }
private void addDatatype(AttributesImpl atts, LocatorIF datatype) { if (!datatype.equals(DataTypes.TYPE_STRING)) atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, "datatype", CDATA, datatype.getExternalForm()); } }
private void write(Collection<LocatorIF> locators, String element, ContentHandler dh) throws SAXException { for (LocatorIF loc: locators) { atts.clear(); atts.addAttribute(EMPTY_NAMESPACE, EMPTY_LOCALNAME, HREF, CDATA, loc.getExternalForm()); dh.startElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, element, atts); dh.endElement(EMPTY_NAMESPACE, EMPTY_LOCALNAME, element); } }
@Override public int compare(LocatorIF loc1, LocatorIF loc2) { if (loc1 == loc2) return 0; // Compare address int c_address = loc1.getExternalForm().compareTo(loc2.getExternalForm()); if (c_address != 0) return c_address; // Compare notation return loc1.getNotation().compareTo(loc2.getNotation()); } }
private AResource getResource(LocatorIF locator) { return new AResourceWrapper(locator.getExternalForm()); }
protected String getSubjectIndicatorRef(TopicIF topic, LocatorIF indicator) { TopicMapIF topicmap = topic.getTopicMap(); LocatorIF baseloc = topicmap.getStore().getBaseAddress(); String address = indicator.getExternalForm(); if (baseloc != null) { String base = baseloc.getExternalForm(); if (base != null && address.startsWith(base) && address.indexOf('#') != -1) { String id = address.substring(address.indexOf('#')); if (isValidXMLId(id.substring(1))) return id; } } return address; }
public static Reader makeReader(LocatorIF locator, EncodingSnifferIF sniffer) throws IOException { return makeReader(StreamUtils.getInputStream(locator.getExternalForm()), null, sniffer); }
private AResource getResource(TopicIF topic) { LocatorIF locator = null; if (locator == null && !topic.getSubjectLocators().isEmpty()) locator = (LocatorIF) topic.getSubjectLocators().iterator().next(); if (locator == null && !topic.getSubjectIdentifiers().isEmpty()) locator = (LocatorIF) topic.getSubjectIdentifiers().iterator().next(); if (locator != null) return new AResourceWrapper(locator.getExternalForm()); return makeAnonymousNode(topic); }
@Override public String toString(OccurrenceIF occ) { if (occ.getLocator() != null) return occ.getLocator().getExternalForm(); else return "$" + occ.getValue(); } }
/** * INTERNAL: Serialize the given datatype for a variant or occurrence * construct. If the datatype is equal to the default datatype ( * {@link PSI#XSD_STRING}), nothing will be serialized. * * @param type a locator defining the datatype. * @see PSI#XSD_STRING */ private void serializeDataType(LocatorIF type) throws IOException { if (type != null && !PSI.getXSDString().equals(type)) { writer.pair("datatype", type.getExternalForm()); } }
private void testExternalForm(String uri, String external) { try { LocatorIF locator = new URILocator(uri); assertTrue("incorrect external form for URI '" + uri + "': '" + locator.getExternalForm() + "', correct '" + external + "'", locator.getExternalForm().equals(external)); } catch (java.net.MalformedURLException e) { fail("INTERNAL ERROR: " + e); } }
private void parseFile(ContentHandler handler) throws IOException, SAXException { InputSource source = new InputSource(tmbase.getExternalForm()); XMLReader parser = new DefaultXMLReaderFactory().createXMLReader(); parser.setContentHandler(handler); parser.parse(source); }
private void testAbsoluteResolution(String base, String uri, String external) { try { // tests based on http://tools.ietf.org/html/rfc3986#section-5.4.1 LocatorIF baseURI = new URILocator(base); LocatorIF locator = baseURI.resolveAbsolute(uri); assertTrue("incorrect external form for URI '" + uri + "': '" + locator.getExternalForm() + "', correct '" + external + "'", locator.getExternalForm().equals(external)); } catch (java.net.MalformedURLException e) { fail("INTERNAL ERROR: " + e); } }
private void testExternalForm(String uri, String frag) { try { LocatorIF base = new URILocator(uri); LocatorIF locator = base.resolveAbsolute("#" + frag); String correct = base.getExternalForm() + "#" + frag; String external = locator.getExternalForm(); assertTrue("incorrect external form for URI '" + locator.getAddress() + "': '" + external + "', correct '" + correct + "'", external.equals(correct)); } catch (java.net.MalformedURLException e) { fail("INTERNAL ERROR: " + e); } } }
public void testLocatorExternalFormOntopiaOnly() throws TMAPIException { String male = "http://www.ex%25-st.com/"; InMemoryTopicMapStore store = new InMemoryTopicMapStore(); TopicMapIF tm = store.getTopicMap(); LocatorIF l = URILocator.create(male); assertEquals(male, l.getExternalForm()); TopicIF t = tm.getBuilder().makeTopic(); TopicIF ot = tm.getBuilder().makeTopic(); OccurrenceIF occ = tm.getBuilder().makeOccurrence(t, ot, l); assertEquals(male, occ.getValue()); assertEquals(male, occ.getLocator().getExternalForm()); } }
@Test public void testOccurrenceURIExport() throws IOException, SAXException { prepareTopicMap(); TopicIF topic = builder.makeTopic(); TopicIF occtype = builder.makeTopic(); LocatorIF loc = new URILocator("http://example.org/foo+bar"); builder.makeOccurrence(topic, occtype, loc); // export to file export(); // reread file with SAX SearchAttributeValue handler = new SearchAttributeValue("resourceRef", "href", loc.getExternalForm(), SearchAttributeValue.REQUIRED); parseFile(handler); handler.check(); }