Search in sources :

Example 31 with EncodingMemento

use of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento in project webtools.sourceediting by eclipse.

the class CSSResourceEncodingDetector method handleSpecDefault.

private void handleSpecDefault() {
    String encodingName;
    encodingName = getSpecDefaultEncoding();
    if (encodingName != null) {
        // createEncodingMemento(encodingName,
        // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
        fEncodingMemento = new EncodingMemento();
        fEncodingMemento.setJavaCharsetName(encodingName);
        fEncodingMemento.setAppropriateDefault(encodingName);
    }
}
Also used : EncodingMemento(org.eclipse.wst.sse.core.internal.encoding.EncodingMemento)

Example 32 with EncodingMemento

use of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento in project webtools.sourceediting by eclipse.

the class TestStructuredDocument method testGetEncodingMemento.

public void testGetEncodingMemento() throws IOException, CoreException {
    IStructuredModel model = getTestModel();
    try {
        IStructuredDocument sDoc = null;
        sDoc = model.getStructuredDocument();
        EncodingMemento memento = sDoc.getEncodingMemento();
        assertNotNull("couldn't get encoding memento", memento);
    } finally {
        if (model != null) {
            model.releaseFromEdit();
        }
    }
}
Also used : EncodingMemento(org.eclipse.wst.sse.core.internal.encoding.EncodingMemento) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) IStructuredModel(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)

Example 33 with EncodingMemento

use of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento in project webtools.sourceediting by eclipse.

the class AbstractResourceEncodingDetector method createEncodingMemento.

/**
 * Note: once this instance is created, trace info still needs to be
 * appended by caller, depending on the context its created.
 */
private void createEncodingMemento(String detectedCharsetName) {
    fEncodingMemento = new EncodingMemento();
    fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName));
    fEncodingMemento.setDetectedCharsetName(detectedCharsetName);
    // TODO: if detectedCharset and spec default is
    // null, need to use "work
    // bench based" defaults.
    fEncodingMemento.setAppropriateDefault(getSpecDefaultEncoding());
}
Also used : EncodingMemento(org.eclipse.wst.sse.core.internal.encoding.EncodingMemento)

Example 34 with EncodingMemento

use of org.eclipse.wst.sse.core.internal.encoding.EncodingMemento in project webtools.sourceediting by eclipse.

the class AbstractResourceEncodingDetector method handleSpecDefault.

private void handleSpecDefault() {
    String encodingName;
    encodingName = getSpecDefaultEncoding();
    if (encodingName != null) {
        // createEncodingMemento(encodingName,
        // EncodingMemento.USED_CONTENT_TYPE_DEFAULT);
        fEncodingMemento = new EncodingMemento();
        fEncodingMemento.setJavaCharsetName(encodingName);
        fEncodingMemento.setAppropriateDefault(encodingName);
    }
}
Also used : EncodingMemento(org.eclipse.wst.sse.core.internal.encoding.EncodingMemento)

Aggregations

EncodingMemento (org.eclipse.wst.sse.core.internal.encoding.EncodingMemento)34 InputStream (java.io.InputStream)6 BufferedInputStream (java.io.BufferedInputStream)5 File (java.io.File)5 FileInputStream (java.io.FileInputStream)5 IOException (java.io.IOException)4 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 XMLResourceEncodingDetector (org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector)3 InputStreamReader (java.io.InputStreamReader)2 MalformedInputException (java.nio.charset.MalformedInputException)2 JSPResourceEncodingDetector (org.eclipse.jst.jsp.core.internal.contenttype.JSPResourceEncodingDetector)2 MalformedInputExceptionWithDetail (org.eclipse.wst.sse.core.internal.exceptions.MalformedInputExceptionWithDetail)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Reader (java.io.Reader)1 Charset (java.nio.charset.Charset)1 CharsetDecoder (java.nio.charset.CharsetDecoder)1 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)1