java.nio.Charset
instance
+ than as a plain encoding name.
+ Reader createGuardedReader(InputStream stream, String encoding) throws UnsupportedEncodingException
+ replaced with
+ Reader createGuardedReader(InputStream stream, Charset charset)
Writer createGuardedWriter(OutputStream stream, String encoding) throws UnsupportedEncodingException
+ replaced with
+ Reader createGuardedReader(InputStream stream, Charset charset)
This document lists changes made to the Editor Guarded Sections API.
+ + +@FOOTER@
+ + +
- StyledDocument
.
It allows clients to manipulate named guarded sections that prevents user to
modify the content. So if you like to create, modify or delete guarded sections the
@@ -55,7 +55,7 @@
-
- AbstractGuardedSectionsProvider
.
In order to bind guarded sections to your editor see
@@ -164,7 +164,8 @@
// load content to kit
if (guardedProvider != null) {
guardedEditor.setDocument(doc);
- Reader reader = guardedProvider.createGuardedReader(stream, "your encoding");
+ Charset cs = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
+ Reader reader = guardedProvider.createGuardedReader(stream, cs);
try {
kit.read(reader, doc, 0);
} finally {
@@ -177,7 +178,8 @@
protected void saveFromKitToStream(StyledDocument doc, EditorKit kit, OutputStream stream) throws IOException, BadLocationException {
if (guardedProvider != null) {
- Writer writer = guardedProvider.createGuardedWriter(stream, null);
+ Charset cs = FileEncodingQuery.getEncoding(this.getDataObject().getPrimaryFile());
+ Writer writer = guardedProvider.createGuardedWriter(stream, cs);
try {
kit.write(writer, doc, 0, doc.getLength());
} finally {
@@ -827,7 +829,7 @@
-->
Editors/<mime path>
in the module layer file. The first one is chosen for the given mime path.
Index: editor/guards/manifest.mf
===================================================================
RCS file: /cvs/editor/guards/manifest.mf,v
retrieving revision 1.2
diff -u -r1.2 manifest.mf
--- editor/guards/manifest.mf 24 Oct 2006 12:53:00 -0000 1.2
+++ editor/guards/manifest.mf 19 Jun 2007 16:58:41 -0000
@@ -1,5 +1,5 @@
Manifest-Version: 1.0
-OpenIDE-Module: org.netbeans.modules.editor.guards/0
+OpenIDE-Module: org.netbeans.modules.editor.guards/1
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/editor/guards/Bundle.properties
-OpenIDE-Module-Specification-Version: 0.1
+OpenIDE-Module-Specification-Version: 1.0
Index: editor/guards/nbproject/project.properties
===================================================================
RCS file: /cvs/editor/guards/nbproject/project.properties,v
retrieving revision 1.2
diff -u -r1.2 project.properties
--- editor/guards/nbproject/project.properties 24 Oct 2006 12:53:01 -0000 1.2
+++ editor/guards/nbproject/project.properties 19 Jun 2007 16:58:41 -0000
@@ -12,10 +12,11 @@
# "Portions Copyrighted [year] [name of copyright owner]"
#
# The Original Software is NetBeans. The Initial Developer of the Original
-# Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+# Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
# Microsystems, Inc. All Rights Reserved.
is.autoload=true
javac.compilerargs=-Xlint:unchecked
javac.source=1.5
+javadoc.apichanges=${basedir}/apichanges.xml
javadoc.arch=${basedir}/arch.xml
Index: editor/guards/src/org/netbeans/spi/editor/guards/GuardedSectionsProvider.java
===================================================================
RCS file: /cvs/editor/guards/src/org/netbeans/spi/editor/guards/GuardedSectionsProvider.java,v
retrieving revision 1.3
diff -u -r1.3 GuardedSectionsProvider.java
--- editor/guards/src/org/netbeans/spi/editor/guards/GuardedSectionsProvider.java 29 Nov 2006 18:49:24 -0000 1.3
+++ editor/guards/src/org/netbeans/spi/editor/guards/GuardedSectionsProvider.java 19 Jun 2007 16:58:41 -0000
@@ -13,7 +13,7 @@
* "Portions Copyrighted [year] [name of copyright owner]"
*
* The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
* Microsystems, Inc. All Rights Reserved.
*/
@@ -22,8 +22,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.nio.charset.Charset;
import org.netbeans.spi.editor.guards.support.AbstractGuardedSectionsProvider;
/**
@@ -37,19 +37,18 @@
/**
* Creates a reader able to read persisted sections.
* @param stream stream containing persisted sections
- * @param encoding encoding to decode read bytes
+ * @param charset charset to decode read bytes, null
implies
+ * the system default charset.
* @return the reader
- * @throws if the encoding is not supported
*/
- Reader createGuardedReader(InputStream stream, String encoding) throws UnsupportedEncodingException;
+ Reader createGuardedReader(InputStream stream, Charset charset);
/**
* Creates a writer able to write persisted sections.
* @param stream stream where the output should be written
- * @param encoding encoding used by the writer
+ * @param charset charset used by the writer
* @return the writer
- * @throws if the encoding is not supported
*/
- Writer createGuardedWriter(OutputStream stream, String encoding) throws UnsupportedEncodingException;
+ Writer createGuardedWriter(OutputStream stream, Charset charset);
}
Index: editor/guards/src/org/netbeans/spi/editor/guards/support/AbstractGuardedSectionsProvider.java
===================================================================
RCS file: /cvs/editor/guards/src/org/netbeans/spi/editor/guards/support/AbstractGuardedSectionsProvider.java,v
retrieving revision 1.5
diff -u -r1.5 AbstractGuardedSectionsProvider.java
--- editor/guards/src/org/netbeans/spi/editor/guards/support/AbstractGuardedSectionsProvider.java 29 Nov 2006 18:49:23 -0000 1.5
+++ editor/guards/src/org/netbeans/spi/editor/guards/support/AbstractGuardedSectionsProvider.java 19 Jun 2007 16:58:41 -0000
@@ -13,7 +13,7 @@
* "Portions Copyrighted [year] [name of copyright owner]"
*
* The Original Software is NetBeans. The Initial Developer of the Original
- * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
+ * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
* Microsystems, Inc. All Rights Reserved.
*/
@@ -22,8 +22,8 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
-import java.io.UnsupportedEncodingException;
import java.io.Writer;
+import java.nio.charset.Charset;
import java.util.List;
import javax.swing.text.BadLocationException;
import org.netbeans.api.editor.guards.GuardedSection;
@@ -45,16 +45,20 @@
private final GuardedSectionsImpl impl;
+ /**
+ * Creates an AbstractGuardedSectionsProvider.
+ * @param editor an editor abstraction
+ */
protected AbstractGuardedSectionsProvider(GuardedEditorSupport editor) {
this.impl = new GuardedSectionsImpl(editor);
}
- public final Reader createGuardedReader(InputStream stream, String encoding) throws UnsupportedEncodingException {
- return impl.createGuardedReader(this, stream, encoding);
+ public final Reader createGuardedReader(InputStream stream, Charset charset) {
+ return impl.createGuardedReader(this, stream, charset);
}
- public final Writer createGuardedWriter(OutputStream stream, String encoding) throws UnsupportedEncodingException {
- return impl.createGuardedWriter(this, stream, encoding);
+ public Writer createGuardedWriter(OutputStream stream, Charset charset) {
+ return impl.createGuardedWriter(this, stream, charset);
}
/**