public BinaryContentProvider() { addSupportedMimeTypes("application/octet-stream,*/*"); addSupportedType(byte[].class, byte[].class); setSupportsWrite(true); setSupportsRead(true); }
public InputStreamContentProvider() { addSupportedMimeTypes("application/octet-stream,*/*"); addSupportedType(InputStream.class, InputStream.class); setSupportsWrite(true); setSupportsRead(true); }
@SuppressWarnings("unchecked") @Override public <T> HTTPContentReader<T> createReader(Class<T> type, Type genericType, ContentType contentType) { return (HTTPContentReader<T>) new XmlHTTPContentReader(); }
public StringContentProvider() { addSupportedMimeTypes("text/plain,text/xml,text/html,text/*,application/xml,application/*,*/*"); addSupportedType(String.class, String.class); setSupportsWrite(true); setSupportsRead(true); }
public OgcXmlContentProvider() { addSupportedMimeTypes("application/vnd.ogc.wfs_xml,application/vnd.ogc.wms_xml,application/vnd.ogc.se_xml"); addSupportedType(Document.class, Document.class); addSupportedType(Element.class, Element.class); setSupportsWrite(true); setSupportsRead(true); }
public XmlContentProvider() { addSupportedMimeTypes("application/xml,application/soap+xml,text/xml"); addSupportedType(Document.class, Document.class); addSupportedType(Element.class, Element.class); setSupportsWrite(true); setSupportsRead(true); }
@Override public <T> HTTPContentWriter createWriter(T content, Class<T> type, Type genericType, ContentType contentType) { return new InputStreamHTTPContentWriter((InputStream) content); }
private <T> boolean isSupported(Class<T> type, Type genericType, ContentType contentType, boolean allowWildCardMatch) { if (!isTypeSupported(type, genericType)) { return false; } return isContentTypeSupported(contentType, allowWildCardMatch); }
private <T> HTTPContentReader<T> findReader(Class<T> type, Type genericType, ContentType contentType) { for (ContentProvider p : m_providers) { if (p.canRead(type, genericType, contentType)) { return p.createReader(type, genericType, contentType); } } return null; }
private synchronized void createDefaultContentTransformerResolver() { if (m_contentTransformerResolver == null) { ContentProviderRegistry registry = new ContentProviderRegistry(); registry.resolveProviders(); m_contentTransformerResolver = registry; } }
@Override public <T> String guessDefaultContentType(Class<T> type, Type genericType) { for (ContentProvider p : m_providers) { if (p.canWrite(type, genericType, new ContentType("*/*"))) { return p.getDefaultContentType(type, genericType); } } return ""; }
@Override public <T> boolean canWrite(Class<T> type, Type genericType, ContentType contentType) { return m_canWrite && isSupported(type, genericType, contentType, true); }
@SuppressWarnings("unchecked") @Override public <T> HTTPContentReader<T> createReader(Class<T> type, Type genericType, ContentType contentType) { return (HTTPContentReader<T>) new InputStreamHTTPContentReader(); } }
@Override public <T> HTTPContentWriter createWriter(T content, Class<T> type, Type genericType, ContentType contentType) { return new BinaryHTTPContentWriter((byte[]) content); }
private <T> boolean isTypeSupported(Class<T> type, Type genericType) { for (TypeMatch supportedType : m_supportedTypes) { if (supportedType.matches(type, genericType)) { return true; } } return false; }
@Override public <T> HTTPContentWriter createWriter(T content, Class<T> type, Type genericType, ContentType contentType) { return new StringHTTPContentWriter((String) content); }
@SuppressWarnings("unchecked") @Override public <T> HTTPContentReader<T> createReader(Class<T> type, Type genericType, ContentType contentType) { return (HTTPContentReader<T>) new StringHTTPContentReader(); } }
@SuppressWarnings("unchecked") @Override public <T> HTTPContentReader<T> createReader(Class<T> type, Type genericType, ContentType contentType) { return (HTTPContentReader<T>) new BinaryHTTPContentReader(); } }
@SuppressWarnings("unchecked") @Override public <T> HTTPContentReader<T> createReader(Class<T> type, Type genericType, ContentType contentType) { return (HTTPContentReader<T>) new XmlHTTPContentReader(); }
@Override public <T> boolean canRead(Class<T> type, Type genericType, ContentType contentType) { return m_canRead && isSupported(type, genericType, contentType, false); }