Map<String, Object> result = createContentDescription(ContentHandler.Validity.INDETERMINATE); if (isRequestedProperty(ContentHandler.BYTE_ORDER_MARK_PROPERTY, options)) ByteOrderMark byteOrderMark = getByteOrderMark(uri, inputStream, options, context); if (byteOrderMark != null) if (isRequestedProperty(ContentHandler.CHARSET_PROPERTY, options)) String charset = getCharset(uri, inputStream, options, context); if (charset != null) if (isRequestedProperty(ContentHandler.LINE_DELIMITER_PROPERTY, options)) String lineDelimiter = getLineDelimiter(uri, inputStream, options, context); if (lineDelimiter != null)
/** * Returns whether the named property is one requested in the options. * @param property the property in question. * @param options the options in which to look for the requested property. * @return whether the named property is one requested in the options. * @see #getRequestedProperties(Map) */ protected boolean isRequestedProperty(String property, Map<?, ?> options) { if (ContentHandler.VALIDITY_PROPERTY.equals(property) || ContentHandler.CONTENT_TYPE_PROPERTY.equals(property)) { return true; } else { Set<String> requestedProperties = getRequestedProperties(options); if (requestedProperties == null) { return true; } else { return requestedProperties.contains(property); } } }
/** * Returns the line delimiter of the input stream; it's computed from the bytes interpreted using the {@link #getCharset(URI, InputStream, Map, Map) appropriate character set}. * @param uri the URI of the input stream. * @param inputStream the input stream. * @param options any options that might influence the interpretation of the content. * @param context a cache for previously computed information. * @return the line delimiter of the input stream. * @throws IOException if there is a problem loading the content. * @since 2.9 */ protected String getLineDelimiter(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { String result = (String)context.get(ContentHandler.LINE_DELIMITER_PROPERTY); if (result == null) { String charset = getCharset(uri, inputStream, options, context); if (charset != null) { result = getLineDelimiter(inputStream, charset); if (result != null) { context.put(ContentHandler.LINE_DELIMITER_PROPERTY, result); } } } return result; }
String lineDelimiter = ContentHandlerImpl.getLineDelimiter(inputStream, encoding); if (lineDelimiter != null)
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the character set from the workspace. * @since 2.9 */ @Override protected String getCharset(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getCharset(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } }
return super.contentDescription(uri, inputStream, options, context);
/** * Returns the line delimiter of the input stream; it's computed from the bytes interpreted using the {@link #getCharset(URI, InputStream, Map, Map) appropriate character set}. * @param uri the URI of the input stream. * @param inputStream the input stream. * @param options any options that might influence the interpretation of the content. * @param context a cache for previously computed information. * @return the line delimiter of the input stream. * @throws IOException if there is a problem loading the content. * @since 2.9 */ protected String getLineDelimiter(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { String result = (String)context.get(ContentHandler.LINE_DELIMITER_PROPERTY); if (result == null) { String charset = getCharset(uri, inputStream, options, context); if (charset != null) { result = getLineDelimiter(inputStream, charset); if (result != null) { context.put(ContentHandler.LINE_DELIMITER_PROPERTY, result); } } } return result; }
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the line delimiter from the project/workspace preferences. * @since 2.9 */ @Override protected String getLineDelimiter(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getLineDelimiter(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } } }
return super.contentDescription(uri, inputStream, options, context);
Map<String, Object> result = createContentDescription(ContentHandler.Validity.INDETERMINATE); if (isRequestedProperty(ContentHandler.BYTE_ORDER_MARK_PROPERTY, options)) ByteOrderMark byteOrderMark = getByteOrderMark(uri, inputStream, options, context); if (byteOrderMark != null) if (isRequestedProperty(ContentHandler.CHARSET_PROPERTY, options)) String charset = getCharset(uri, inputStream, options, context); if (charset != null) if (isRequestedProperty(ContentHandler.LINE_DELIMITER_PROPERTY, options)) String lineDelimiter = getLineDelimiter(uri, inputStream, options, context); if (lineDelimiter != null)
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the character set from the workspace. * @since 2.9 */ @Override protected String getCharset(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getCharset(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } }
/** * Returns whether the named property is one requested in the options. * @param property the property in question. * @param options the options in which to look for the requested property. * @return whether the named property is one requested in the options. * @see #getRequestedProperties(Map) */ protected boolean isRequestedProperty(String property, Map<?, ?> options) { if (ContentHandler.VALIDITY_PROPERTY.equals(property) || ContentHandler.CONTENT_TYPE_PROPERTY.equals(property)) { return true; } else { Set<String> requestedProperties = getRequestedProperties(options); if (requestedProperties == null) { return true; } else { return requestedProperties.contains(property); } } }
/** * This implementation only gets called when platform's content describer throws an exception, i.e., when the resource doesn't exist. * For {@link URI#isPlatformResource() platform resource URIs}, it determines the line delimiter from the project/workspace preferences. * @since 2.9 */ @Override protected String getLineDelimiter(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException { if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null) { return PlatformResourceURIHandlerImpl.WorkbenchHelper.getLineDelimiter(uri.toPlatformString(true), options); } else { return super.getCharset(uri, inputStream, options, context); } } }