Search in sources :

Example 1 with EmbeddedTypeRegistry

use of org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry in project webtools.sourceediting by eclipse.

the class PageDirectiveAdapterImpl method getHandlerFor.

private EmbeddedTypeHandler getHandlerFor(String contentType) {
    EmbeddedTypeRegistry reg = getEmbeddedContentTypeRegistry();
    EmbeddedTypeHandler handler = null;
    if (reg != null)
        handler = reg.getTypeFor(contentType);
    return handler;
}
Also used : EmbeddedTypeRegistry(org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry) EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)

Example 2 with EmbeddedTypeRegistry

use of org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry in project webtools.sourceediting by eclipse.

the class JSPModelLoader method getJSPDefaultEmbeddedType.

/**
 * For JSP files, text/html is the default content type. This may want
 * this different for types like jsv (jsp for voice xml) For now, hard
 * code to new instance. In future, should get instance from registry.
 *
 * Specification cites HTML as the default contentType.
 */
private EmbeddedTypeHandler getJSPDefaultEmbeddedType(IStructuredModel model) {
    EmbeddedTypeRegistry reg = getEmbeddedContentTypeRegistry();
    String mimeType = null;
    // default embedded type for fragments
    if (model != null) {
        IFile file = getFile(model);
        if (file != null) {
            mimeType = JSPFContentProperties.getProperty(JSPFContentProperties.JSPCONTENTTYPE, file, true);
        }
    }
    mimeType = mimeType == null ? getDefaultMimeType() : mimeType;
    return reg.getTypeFor(mimeType);
}
Also used : EmbeddedTypeRegistry(org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry) IFile(org.eclipse.core.resources.IFile)

Example 3 with EmbeddedTypeRegistry

use of org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry in project webtools.sourceediting by eclipse.

the class JSPDocumentLoader method getEmbeddedType.

/**
 * Determine the MIME content type specified in a page directive. This
 * should appear "as early as possible in the JSP page" according to the
 * JSP v1.2 specification.
 */
private EmbeddedTypeHandler getEmbeddedType(IFile file) throws UnsupportedEncodingException, CoreException, IOException {
    EmbeddedTypeHandler handler = null;
    if (fFullPreparedReader == null) {
        handler = getJSPDefaultEmbeddedType();
    } else {
        String mimeType = null;
        IDocumentCharsetDetector jspProvider = getDocumentEncodingDetector();
        Reader fullPreparedReader = getFullPreparedReader();
        BufferedLimitedReader limitedReader = new BufferedLimitedReader(fullPreparedReader, CodedIO.MAX_BUF_SIZE);
        jspProvider.set(limitedReader);
        if (jspProvider instanceof IJSPHeadContentDetector) {
            mimeType = ((IJSPHeadContentDetector) jspProvider).getContentType();
            fullPreparedReader.reset();
        }
        EmbeddedTypeRegistry reg = getEmbeddedContentTypeRegistry();
        if (mimeType == null || mimeType.length() == 0) {
            handler = getJSPDefaultEmbeddedType();
        } else {
            handler = reg.getTypeFor(mimeType);
        }
    }
    return handler;
}
Also used : EmbeddedTypeRegistry(org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry) EmbeddedTypeHandler(org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler) IDocumentCharsetDetector(org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector) BufferedLimitedReader(org.eclipse.wst.sse.core.internal.encoding.util.BufferedLimitedReader) BufferedLimitedReader(org.eclipse.wst.sse.core.internal.encoding.util.BufferedLimitedReader) Reader(java.io.Reader)

Aggregations

EmbeddedTypeRegistry (org.eclipse.wst.sse.core.internal.modelhandler.EmbeddedTypeRegistry)3 EmbeddedTypeHandler (org.eclipse.wst.sse.core.internal.ltk.modelhandler.EmbeddedTypeHandler)2 Reader (java.io.Reader)1 IFile (org.eclipse.core.resources.IFile)1 IDocumentCharsetDetector (org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector)1 BufferedLimitedReader (org.eclipse.wst.sse.core.internal.encoding.util.BufferedLimitedReader)1