@Override public boolean addAll(Collection<? extends MappingNode> c) { boolean result = false; Iterator<? extends MappingNode> iter = c.iterator(); MappingNode o; while(iter.hasNext()) { o = iter.next(); result |= add(o); } // while return result; } // addAll(Collection)
@Override public void remove() { if (!removeCalled && index > 0 ) { index--; MappingDefinition.this.remove(nodes.get(index)); }// if possible remove removeCalled = true; } // remove
@Override public boolean retainAll(Collection<?> c) { int aprioriSize = nodes.size(); List<MappingNode> scrap = new ArrayList<MappingNode>(); MappingNode node; for (int index = 0; index < nodes.size(); index++) { node = nodes.get(index); if (c.contains(node)) { scrap.add(node); } } //for removeAll(scrap); return (aprioriSize != nodes.size()); }
/** Initialize this onto gazetteer * @return .*/ @Override public Resource init() throws ResourceInstantiationException { try { checkParameters(); FeatureMap params = Factory.newFeatureMap(); mappingDefinition = new MappingDefinition(); mappingDefinition.setURL(mappingURL); mappingDefinition.load(); params.put("caseSensitive",caseSensitive); params.put("listsURL",listsURL); params.put("encoding",encoding); params.put("mappingDefinition",mappingDefinition); gaz = (Gazetteer)Factory.createResource(gazetteerName,params); } catch (InvalidFormatException e) { throw new ResourceInstantiationException(e); } return this; } // init
Lookup lookup1 = new Lookup(s, majorType, minorType, language); if(mappingDefinition != null) { MappingNode mappingnode = mappingDefinition.getNodeByList(s); if(null != mappingnode) { lookup1.oClass = mappingnode.getClassID();
defaultLookup.list = node.getList(); if ( null != mappingDefinition){ MappingNode mnode = mappingDefinition.getNodeByList(defaultLookup.list); if (null!=mnode){ defaultLookup.oClass = mnode.getClassID(); lookup.list = node.getList(); if(null != mappingDefinition) { MappingNode mnode = mappingDefinition.getNodeByList(lookup.list); if(null != mnode) { lookup.oClass = mnode.getClassID();
@Override public boolean addAll(int index, Collection<? extends MappingNode> c) { int size = nodes.size(); Iterator<? extends MappingNode> iter = c.iterator(); MappingNode o; while(iter.hasNext()) { o = iter.next(); add(index++, o); } // while return (size != nodes.size()); }// addAll(int,Collection)
@Override public boolean removeAll(Collection<?> c) { boolean result = false; Iterator<?> iter = c.iterator(); Object o; while (iter.hasNext()) { o = iter.next(); result |= remove(o); } return result; }// removeAll()
/**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();