public synchronized boolean contains(TypeNameMatch type) { return super.contains(type); }
/** * Absolute position of object denoted by key in the * history or -1 if !containsKey(key). The higher the * newer. * * @param key The key of the object to inspect * @return value between 0 and MAX_HISTORY_SIZE - 1, or -1 */ public synchronized int getPosition(K key) { if (!containsKey(key)) return -1; return fPositions.get(key).intValue(); }
public synchronized Object remove(V object) { Object removed= fHistory.remove(getKey(object)); rebuildPositions(); return removed; }
root = parser.parse(inputSource).getDocumentElement(); } catch (SAXException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, fFileName)); } catch (ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, fFileName)); } catch (IOException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, fFileName)); Element type= (Element) node; if (type.getNodeName().equalsIgnoreCase(fInfoNodeName)) { Object object= createFromElement(type); if (object != null) { fHistory.put(getKey(object), object); rebuildPositions();
private void save(OutputStream stream) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Element rootElement = document.createElement(fRootNodeName); document.appendChild(rootElement); Iterator values= getValues().iterator(); while (values.hasNext()) { Object object= values.next(); Element element= document.createElement(fInfoNodeName); setAttributes(object, element); rootElement.appendChild(element); } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(stream); transformer.transform(source, result); } catch (TransformerException e) { throw createException(e, Messages.format(CorextMessages.History_error_serialize, fFileName)); } catch (ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_serialize, fFileName)); } }
public int compare(Object o1, Object o2) { if (((String)o1).equals(o2)) return 0; History history= QualifiedTypeNameHistory.getDefault(); int pos1= history.getPosition(o1); int pos2= history.getPosition(o2); if (pos1 == pos2) return Collator.getInstance().compare(o1, o2); if (pos1 > pos2) { return -1; } else { return 1; } }
public synchronized boolean contains(Object object) { return fHistory.containsKey(getKey(object)); }
public synchronized Object removeKey(Object key) { Object removed= fHistory.remove(key); rebuildPositions(); return removed; }
public synchronized void accessed(TypeNameMatch info) { // Fetching the timestamp might not be cheap (remote file system // external Jars. So check if we alreay have one. if (!fTimestampMapping.containsKey(info)) { fTimestampMapping.put(info, new Long(getContainerTimestamp(info))); } super.accessed(info); }
public synchronized void load() { IPath stateLocation= JavaPlugin.getDefault().getStateLocation().append(fFileName); File file= stateLocation.toFile(); if (file.exists()) { InputStreamReader reader= null; try { reader = new InputStreamReader(new FileInputStream(file), "utf-8");//$NON-NLS-1$ load(new InputSource(reader)); } catch (IOException e) { JavaPlugin.log(e); } catch (CoreException e) { JavaPlugin.log(e); } finally { try { if (reader != null) reader.close(); } catch (IOException e) { JavaPlugin.log(e); } } } }
root = parser.parse(inputSource).getDocumentElement(); } catch (SAXException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); } catch (ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); } catch (IOException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); Element type= (Element) node; if (type.getNodeName().equalsIgnoreCase(fInfoNodeName)) { V object= createFromElement(type); if (object != null) { fHistory.put(getKey(object), object); rebuildPositions();
private void save(OutputStream stream) throws CoreException { try { DocumentBuilderFactory factory= DocumentBuilderFactory.newInstance(); DocumentBuilder builder= factory.newDocumentBuilder(); Document document= builder.newDocument(); Element rootElement = document.createElement(fRootNodeName); document.appendChild(rootElement); Iterator<V> values= getValues().iterator(); while (values.hasNext()) { Object object= values.next(); Element element= document.createElement(fInfoNodeName); setAttributes(object, element); rootElement.appendChild(element); } Transformer transformer=TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); //$NON-NLS-1$ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$ DOMSource source = new DOMSource(document); StreamResult result = new StreamResult(stream); transformer.transform(source, result); } catch (TransformerException e) { throw createException(e, Messages.format(CorextMessages.History_error_serialize, BasicElementLabels.getResourceName(fFileName))); } catch (ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_serialize, BasicElementLabels.getResourceName(fFileName))); } }
public synchronized Object remove(Object object) { Object removed= fHistory.remove(getKey(object)); rebuildPositions(); return removed; }
public int compare(Object o1, Object o2) { if (((String)o1).equals(o2)) return 0; History history= QualifiedTypeNameHistory.getDefault(); int pos1= history.getPosition(o1); int pos2= history.getPosition(o2); if (pos1 == pos2) return Collator.getInstance().compare(o1, o2); if (pos1 > pos2) { return -1; } else { return 1; } }
public synchronized boolean contains(V object) { return fHistory.containsKey(getKey(object)); }
public synchronized Object removeKey(Object key) { Object removed= fHistory.remove(key); rebuildPositions(); return removed; }
@Override public synchronized void accessed(TypeNameMatch info) { // Fetching the timestamp might not be cheap (remote file system // external Jars. So check if we alreay have one. if (!fTimestampMapping.containsKey(info)) { fTimestampMapping.put(info, Long.valueOf(getContainerTimestamp(info))); } super.accessed(info); }
public synchronized void load() { IPath stateLocation= JavaPlugin.getDefault().getStateLocation().append(fFileName); File file= stateLocation.toFile(); if (file.exists()) { InputStreamReader reader= null; try { reader = new InputStreamReader(new FileInputStream(file), "utf-8");//$NON-NLS-1$ load(new InputSource(reader)); } catch (IOException e) { JavaPlugin.log(e); } catch (CoreException e) { JavaPlugin.log(e); } finally { try { if (reader != null) reader.close(); } catch (IOException e) { JavaPlugin.log(e); } } } }
root = parser.parse(inputSource).getDocumentElement(); } catch (SAXException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); } catch (ParserConfigurationException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); } catch (IOException e) { throw createException(e, Messages.format(CorextMessages.History_error_read, BasicElementLabels.getResourceName(fFileName))); Element type= (Element) node; if (type.getNodeName().equalsIgnoreCase(fInfoNodeName)) { V object= createFromElement(type); if (object != null) { fHistory.put(getKey(object), object); rebuildPositions();