/**Creates a new mapping node given a string representation. * @param node a node from the mapping definition * @throws InvalidFormatException if the node is misformatted */ public MappingNode(String node) throws InvalidFormatException { int firstColumn = node.indexOf(':'); int lastColumn = node.lastIndexOf(':'); if (-1 == firstColumn || -1 == lastColumn ) { throw new InvalidFormatException(); } list = node.substring(0,firstColumn); ontologyID = node.substring(firstColumn+1,lastColumn); classID = node.substring(lastColumn+1); }// MappingNode construct
if(firstColon == -1) { throw new InvalidFormatException("", "Line: " + node); } list = node.substring(0, firstColon); if(secondColon == -1) {
/**Loads the mapping definition * @throws ResourceInstantiationException if load fails. */ public void load() throws ResourceInstantiationException,InvalidFormatException { if (null == url) { throw new ResourceInstantiationException("URL not set (null)."); } try { BufferedReader mapReader = new BomStrippingInputStreamReader((url).openStream(), ENCODING); String line; MappingNode node; while (null != (line = mapReader.readLine())) { if (0 != line.trim().length()) { node = new MappingNode(line); this.add(node); } // if } //while mapReader.close(); } catch (InvalidFormatException ife){ throw new InvalidFormatException(url,"on load"); } catch (IOException ioe) { throw new ResourceInstantiationException(ioe); } } // load();