public static String readString(InputStream is, String encoding) throws IOException { return readString(is, encoding, -1, null); }
private String getString(Object input) { if (input instanceof IStreamContentAccessor) { try { return Utilities.readString((IStreamContentAccessor) input); } catch (CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } return ""; //$NON-NLS-1$ } }
private String getString(Object input) { if (input instanceof IStreamContentAccessor) { try { return Utilities.readString((IStreamContentAccessor) input); } catch (CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } return ""; //$NON-NLS-1$ } }
private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { try { String text= Utilities.readString(sa); document.replace(0, document.getLength(), text); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (BadLocationException e) { throw new InvocationTargetException(e); } }
@Override protected boolean contentsEqual(IProgressMonitor monitor, InputStream is1, InputStream is2, boolean ignoreWhitespace) { try { final String left = Utilities.readString(is1, ResourcesPlugin.getEncoding()); final String right = Utilities.readString(is2, ResourcesPlugin.getEncoding()); return compareStrings(left, right, monitor); } catch (IOException e) { // ignore } return false; }
private void updateDocument(IDocument document, IStreamContentAccessor sa) throws InvocationTargetException { try { String text= Utilities.readString(sa); document.replace(0, document.getLength(), text); } catch (CoreException e) { throw new InvocationTargetException(e); } catch (BadLocationException e) { throw new InvocationTargetException(e); } }
public static String readString(IStreamContentAccessor sca, String encoding) throws CoreException { String s = null; try { try { s= Utilities.readString(sca.getContents(), encoding); } catch (UnsupportedEncodingException e) { if (!encoding.equals(ResourcesPlugin.getEncoding())) { s = Utilities.readString(sca.getContents(), ResourcesPlugin.getEncoding()); } } } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, e.getMessage(), e)); } return s; }
public static String readString(IStreamContentAccessor sca, String encoding) throws CoreException { String s = null; try { try { s= Utilities.readString(sca.getContents(), encoding); } catch (UnsupportedEncodingException e) { if (!encoding.equals(ResourcesPlugin.getEncoding())) { s = Utilities.readString(sca.getContents(), ResourcesPlugin.getEncoding()); } } } catch (IOException e) { throw new CoreException(new Status(IStatus.ERROR, CompareUIPlugin.PLUGIN_ID, 0, e.getMessage(), e)); } return s; }
public static String readString(IStreamContentAccessor sa) throws CoreException { String encoding= null; if (sa instanceof IEncodedStreamContentAccessor) encoding= ((IEncodedStreamContentAccessor)sa).getCharset(); if (encoding == null) encoding= ResourcesPlugin.getEncoding(); return Utilities.readString(sa, encoding); }
public static String readString(IStreamContentAccessor sa) throws CoreException { String encoding= null; if (sa instanceof IEncodedStreamContentAccessor) encoding= ((IEncodedStreamContentAccessor)sa).getCharset(); if (encoding == null) encoding= ResourcesPlugin.getEncoding(); return Utilities.readString(sa, encoding); }
private String getContent() { if (fContent == null) { if (fStructureCreator != null) fContent= fStructureCreator.getContents(fItem, false); else { if (fItem instanceof IStreamContentAccessor) { IStreamContentAccessor sca= (IStreamContentAccessor) fItem; try { fContent= Utilities.readString(sca); } catch (CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } } if (fContent == null) fContent= ""; //$NON-NLS-1$ } return fContent; }
private String getContent() { if (fContent == null) { if (fStructureCreator != null) fContent= fStructureCreator.getContents(fItem, false); else { if (fItem instanceof IStreamContentAccessor) { IStreamContentAccessor sca= (IStreamContentAccessor) fItem; try { fContent= Utilities.readString(sca); } catch (CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } } if (fContent == null) fContent= ""; //$NON-NLS-1$ } return fContent; }
public ITypedElement replace(ITypedElement child, ITypedElement other) { if (fParent == null) { // TODO: I don't believe this code does anything useful but just in case // I'm leaving it in but disabling it for the shared document case // since all the subclasses that have been converted overrode the method anyway DocumentRangeNode src= null; String srcContents= ""; //$NON-NLS-1$ if (other != null) { src= (DocumentRangeNode) child; if (other instanceof IStreamContentAccessor) { try { srcContents= Utilities.readString((IStreamContentAccessor)other); } catch(CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } } if (child == null) // no destination: we have to add the contents into the parent add(srcContents, null, src); } nodeChanged(this); return child; }
@Override public ITypedElement replace(ITypedElement child, ITypedElement other) { if (fParent == null) { // TODO: I don't believe this code does anything useful but just in case // I'm leaving it in but disabling it for the shared document case // since all the subclasses that have been converted overrode the method anyway DocumentRangeNode src= null; String srcContents= ""; //$NON-NLS-1$ if (other != null) { src= (DocumentRangeNode) child; if (other instanceof IStreamContentAccessor) { try { srcContents= Utilities.readString((IStreamContentAccessor)other); } catch(CoreException ex) { // NeedWork CompareUIPlugin.log(ex); } } } if (child == null) // no destination: we have to add the contents into the parent add(srcContents, null, src); } nodeChanged(this); return child; }
private IDocument createDocument() { // If the content provider is a text content provider, attempt to obtain // a shared document (i.e. file buffer) IDocument newDoc = connectToSharedDocument(); if (newDoc == null) { IStreamContentAccessor sca= (IStreamContentAccessor) fElement; String s= null; try { String encoding = internalGetEncoding(); s = Utilities.readString(sca, encoding); } catch (CoreException ex) { this.fViewer.setError(fLeg, ex.getMessage()); } newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$ } return newDoc; }
if (enc == null) enc = ResourcesPlugin.getEncoding(); result[0] = Utilities.readString( connection.getInputStream(), enc, connection.getContentLength(),
private IDocument createDocument() { // If the content provider is a text content provider, attempt to obtain // a shared document (i.e. file buffer) IDocument newDoc = connectToSharedDocument(); if (newDoc == null) { IStreamContentAccessor sca= (IStreamContentAccessor) fElement; String s= null; try { String encoding = getEncoding(); s = Utilities.readString(sca, encoding); } catch (CoreException ex) { this.fViewer.setError(fLeg, ex.getMessage()); } newDoc= new Document(s != null ? s : ""); //$NON-NLS-1$ } return newDoc; }
IStreamContentAccessor sca= (IStreamContentAccessor) input; try { contents= Utilities.readString(sca); } catch (CoreException e) {
@Override public IStructureComparator getStructure(Object input) { String contents= null; IDocument doc= CompareUI.getDocument(input); if (doc == null) { if (input instanceof IStreamContentAccessor) { IStreamContentAccessor sca= (IStreamContentAccessor) input; try { contents= Utilities.readString(sca); } catch (CoreException e) { // return null indicates the error. CompareUIPlugin.log(e); return null; } } if (contents == null) { // Node has no contents return null; } doc= new Document(contents); setupDocument(doc); } try { return createStructureComparator(input, doc, null, null); } catch (CoreException e) { CompareUIPlugin.log(e); return null; } }