/** * Reads templates from a reader and returns them. The reader must present * a serialized form as produced by the <code>save</code> method. * * @param reader the reader to read templates from * @return the read templates, encapsulated in instances of <code>TemplatePersistenceData</code> * @throws IOException if reading from the stream fails */ public TemplatePersistenceData[] read(Reader reader) throws IOException { return read(reader, null); }
/** * Reads templates from a stream and adds them to the templates. * * @param reader the reader to read templates from * @param bundle a resource bundle to use for translating the read templates, or <code>null</code> if no translation should occur * @return the read templates, encapsulated in instances of <code>TemplatePersistenceData</code> * @throws IOException if reading from the stream fails */ public TemplatePersistenceData[] read(Reader reader, ResourceBundle bundle) throws IOException { return read(new InputSource(reader), bundle, null); }
/** * Reads templates from a stream and adds them to the templates. * * @param stream the byte stream to read templates from * @param bundle a resource bundle to use for translating the read templates, or <code>null</code> if no translation should occur * @return the read templates, encapsulated in instances of <code>TemplatePersistenceData</code> * @throws IOException if reading from the stream fails */ public TemplatePersistenceData[] read(InputStream stream, ResourceBundle bundle) throws IOException { return read(new InputSource(stream), bundle, null); }
/** * Reads the template with identifier <code>id</code> from a reader and * returns it. The reader must present a serialized form as produced by the * <code>save</code> method. * * @param reader the reader to read templates from * @param id the id of the template to return * @return the read template, encapsulated in an instances of * <code>TemplatePersistenceData</code> * @throws IOException if reading from the stream fails * @since 3.1 */ public TemplatePersistenceData readSingle(Reader reader, String id) throws IOException { TemplatePersistenceData[] datas= read(new InputSource(reader), null, id); if (datas.length > 0) return datas[0]; return null; }
@Override public TemplatePersistenceData[] read(Reader reader, ResourceBundle bundle) throws IOException { org.eclipse.text.templates.TemplatePersistenceData[] list= super.read(reader, bundle); TemplatePersistenceData[] result= new TemplatePersistenceData[list.length]; for (int i= 0; i < list.length; i++) { result[i]= new TemplatePersistenceData(list[i]); } return result; }
@Override public TemplatePersistenceData[] read(InputStream stream, ResourceBundle bundle) throws IOException { org.eclipse.text.templates.TemplatePersistenceData[] list= super.read(stream, bundle); TemplatePersistenceData[] result= new TemplatePersistenceData[list.length]; for (int i= 0; i < list.length; i++) { result[i]= new TemplatePersistenceData(list[i]); } return result; }
@Override public TemplatePersistenceData[] read(Reader reader) throws IOException { org.eclipse.text.templates.TemplatePersistenceData[] list= super.read(reader); TemplatePersistenceData[] result= new TemplatePersistenceData[list.length]; for (int i= 0; i < list.length; i++) { result[i]= new TemplatePersistenceData(list[i]); } return result; }
private void loadCustomTemplates() throws IOException { String pref= fPreferenceStore.get(fKey, null); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas= reader.read(input); for (TemplatePersistenceData data : datas) { add(data); } } }
private void loadCustomTemplates() throws IOException { String pref= fPreferenceStore.getString(getKey()); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas= reader.read(input); for (TemplatePersistenceData data : datas) { add(data); } } }
public static boolean hasProjectSpecificTempates(IProject project) { String pref= new ProjectScope(project).getNode(JavaManipulation.getPreferenceNodeId()).get(KEY, null); if (pref != null && pref.trim().length() > 0) { Reader input= new StringReader(pref); TemplateReaderWriter reader= new TemplateReaderWriter(); TemplatePersistenceData[] datas; try { datas= reader.read(input); return datas.length > 0; } catch (IOException e) { // ignore } } return false; }
InputStream input= new BufferedInputStream(new FileInputStream(file)); try { TemplatePersistenceData[] datas= reader.read(input, null); for (int i= 0; i < datas.length; i++) { updateTemplate(datas[i]);
if (file.exists()) { try (InputStream input = new BufferedInputStream(new FileInputStream(file))) { TemplatePersistenceData[] datas= reader.read(input, null); for (int i= 0; i < datas.length; i++) { TemplatePersistenceData data= datas[i];