@Override
public ContentHandler createContentHandler(String mimetype) {
switch (mimetype) {
case "audio/aiff": return new aiff();
case "audio/basic": return new basic();
case "audio/wav": return new wav();
case "audio/x-aiff": return new x_aiff();
case "audio/x-wav": return new x_wav();
case "image/gif": return new gif();
case "image/jpeg": return new jpeg();
case "image/png": return new png();
case "image/x-xbitmap": return new x_xbitmap();
case "image/x-xpixmap": return new x_xpixmap();
default: return null;
}
}
java类java.net.ContentHandler的实例源码
MultimediaContentHandlers.java 文件源码
项目:openjdk-jdk10
阅读 18
收藏 0
点赞 0
评论 0
MultimediaContentHandlers.java 文件源码
项目:openjdk9
阅读 18
收藏 0
点赞 0
评论 0
@Override
public ContentHandler createContentHandler(String mimetype) {
switch (mimetype) {
case "audio/aiff": return new aiff();
case "audio/basic": return new basic();
case "audio/wav": return new wav();
case "audio/x-aiff": return new x_aiff();
case "audio/x-wav": return new x_wav();
case "image/gif": return new gif();
case "image/jpeg": return new jpeg();
case "image/png": return new png();
case "image/x-xbitmap": return new x_xbitmap();
case "image/x-xpixmap": return new x_xpixmap();
default: return null;
}
}
ContentHandlerTest.java 文件源码
项目:In-the-Box-Fork
阅读 20
收藏 0
点赞 0
评论 0
/**
* @tests java.net.ContentHandler#getContent(java.net.URLConnection,
* java.lang.Class[])
*/
public void test_getContent() throws IOException {
URLConnection conn = new URL("http://www.apache.org").openConnection();
Class[] classes = { Foo.class, String.class, };
ContentHandler handler = new ContentHandlerImpl();
((ContentHandlerImpl) handler).setContent(new Foo());
Object content = handler.getContent(conn, classes);
assertEquals("Foo", ((Foo) content).getFoo());
((ContentHandlerImpl) handler).setContent(new FooSub());
content = handler.getContent(conn, classes);
assertEquals("FooSub", ((Foo) content).getFoo());
Class[] classes2 = { FooSub.class, String.class, };
((ContentHandlerImpl) handler).setContent(new Foo());
content = handler.getContent(conn, classes2);
assertNull(content);
}
ContentHandlerTest.java 文件源码
项目:cn1
阅读 25
收藏 0
点赞 0
评论 0
/**
* @tests java.net.ContentHandler#getContent(java.net.URLConnection,
* java.lang.Class[])
*/
public void test_getContent() throws IOException {
URLConnection conn = new URL("http://www.apache.org").openConnection();
Class[] classes = { Foo.class, String.class, };
ContentHandler handler = new ContentHandlerImpl();
((ContentHandlerImpl) handler).setContent(new Foo());
Object content = handler.getContent(conn, classes);
assertEquals("Foo", ((Foo) content).getFoo());
((ContentHandlerImpl) handler).setContent(new FooSub());
content = handler.getContent(conn, classes);
assertEquals("FooSub", ((Foo) content).getFoo());
Class[] classes2 = { FooSub.class, String.class, };
((ContentHandlerImpl) handler).setContent(new Foo());
content = handler.getContent(conn, classes2);
assertNull(content);
}
ContentHandlerTest.java 文件源码
项目:freeVM
阅读 24
收藏 0
点赞 0
评论 0
/**
* @tests java.net.ContentHandler#getContent(java.net.URLConnection,
* java.lang.Class[])
*/
public void test_getContent() throws IOException {
URLConnection conn = new URL("http://www.apache.org").openConnection();
Class[] classes = { Foo.class, String.class, };
ContentHandler handler = new ContentHandlerImpl();
((ContentHandlerImpl) handler).setContent(new Foo());
Object content = handler.getContent(conn, classes);
assertEquals("Foo", ((Foo) content).getFoo());
((ContentHandlerImpl) handler).setContent(new FooSub());
content = handler.getContent(conn, classes);
assertEquals("FooSub", ((Foo) content).getFoo());
Class[] classes2 = { FooSub.class, String.class, };
((ContentHandlerImpl) handler).setContent(new Foo());
content = handler.getContent(conn, classes2);
assertNull(content);
}
ContentHandlerTest.java 文件源码
项目:freeVM
阅读 19
收藏 0
点赞 0
评论 0
/**
* @tests java.net.ContentHandler#getContent(java.net.URLConnection,
* java.lang.Class[])
*/
public void test_getContent() throws IOException {
URLConnection conn = new URL("http://www.apache.org").openConnection();
Class[] classes = { Foo.class, String.class, };
ContentHandler handler = new ContentHandlerImpl();
((ContentHandlerImpl) handler).setContent(new Foo());
Object content = handler.getContent(conn, classes);
assertEquals("Foo", ((Foo) content).getFoo());
((ContentHandlerImpl) handler).setContent(new FooSub());
content = handler.getContent(conn, classes);
assertEquals("FooSub", ((Foo) content).getFoo());
Class[] classes2 = { FooSub.class, String.class, };
((ContentHandlerImpl) handler).setContent(new Foo());
content = handler.getContent(conn, classes2);
assertNull(content);
}
MediaServer.java 文件源码
项目:android-vlc-remote
阅读 19
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
protected final <T> T read(ContentHandler handler) throws IOException {
String spec = mUri.toString();
URL url = new URL(spec);
HttpURLConnection http = (HttpURLConnection) url.openConnection();
try {
String password = PasswordManager.get(mContext).getPassword(mUri.getAuthority());
if (password != null) {
Credentials credentials = new UsernamePasswordCredentials("", password);
Header authorization = BasicScheme.authenticate(credentials, HTTP.UTF_8, false);
http.setRequestProperty(authorization.getName(), authorization.getValue());
}
int responseCode = http.getResponseCode();
String responseMessage = http.getResponseMessage();
if (responseCode != HttpURLConnection.HTTP_OK) {
throw new HttpResponseException(responseCode, responseMessage);
}
return (T) handler.getContent(http);
} finally {
http.disconnect();
}
}
DefaultContentHandlerFactory.java 文件源码
项目:javify
阅读 21
收藏 0
点赞 0
评论 0
public ContentHandler createContentHandler(String mimeType)
{
if (imageTypes.contains(mimeType))
return ImageHandler.instance;
// Currently, only image types are handled.
return null;
}
DefaultContentHandlerFactory.java 文件源码
项目:jvm-stm
阅读 18
收藏 0
点赞 0
评论 0
public ContentHandler createContentHandler(String mimeType)
{
if (imageTypes.contains(mimeType))
return ImageHandler.instance;
// Currently, only image types are handled.
return null;
}
DefaultContentHandlerFactory.java 文件源码
项目:JamVM-PH
阅读 20
收藏 0
点赞 0
评论 0
public ContentHandler createContentHandler(String mimeType)
{
if (imageTypes.contains(mimeType))
return ImageHandler.instance;
// Currently, only image types are handled.
return null;
}
DefaultContentHandlerFactory.java 文件源码
项目:classpath
阅读 18
收藏 0
点赞 0
评论 0
public ContentHandler createContentHandler(String mimeType)
{
if (imageTypes.contains(mimeType))
return ImageHandler.instance;
// Currently, only image types are handled.
return null;
}
XmlContentHandler.java 文件源码
项目:android-vlc-remote
阅读 17
收藏 0
点赞 0
评论 0
protected final void parse(URLConnection connection, org.xml.sax.ContentHandler handler)
throws IOException {
InputStream input = connection.getInputStream();
try {
// The server sends UTF-8 instead of the HTTP default (ISO-8859-1).
Xml.Encoding encoding = Xml.Encoding.UTF_8;
Xml.parse(input, encoding, handler);
} catch (Exception e) {
IOException ioe = new IOException("Invalid XML");
ioe.initCause(e);
throw ioe;
} finally {
input.close();
}
}
MediaServer.java 文件源码
项目:android-vlc-remote
阅读 19
收藏 0
点赞 0
评论 0
protected final <T> Remote<T> load(ContentHandler handler) {
String spec = mUri.toString();
try {
T data = read(handler);
return Remote.data(data);
} catch (Throwable t) {
Log.e(TAG, "Unable to load: " + spec, t);
return Remote.error(t);
}
}
QuickShare.java 文件源码
项目:samplegit
阅读 18
收藏 0
点赞 0
评论 0
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "[onCreate]");
sInstance = this;
JRFileResponseCache jrfrc = new JRFileResponseCache(this);
ResponseCache.setDefault(jrfrc);
java.net.ContentHandler bmch = JRFileResponseCache.capture(new JRBitmapContentHandler(), null);
java.net.ContentHandler pfch = JRFileResponseCache.capture(JRFileResponseCache.sink(), null);
mImageLoader = new ImageLoader(ImageLoader.DEFAULT_TASK_LIMIT, null, bmch, pfch,
ImageLoader.DEFAULT_CACHE_SIZE, null);
/* If the Story class changes, then the Archiver can't load the new stories, which is fine,
They'll just get re-downloaded/added, but we also have to clear the links hash, so that
the new stories get added. */
try {
ArrayList<Story> loadedStories = Archiver.load(ARCHIVE_STORIES_ARRAY, this);
mStories.clear();
mStories.addAll(loadedStories);
mStoryLinks = Archiver.load(ARCHIVE_STORY_LINKS_HASH, this);
logd(TAG, "[ctor] loaded " + mStories.size() + " stories from disk");
} catch (Archiver.LoadException e) {
mStories.clear();
mStoryLinks = new HashSet<String>();
logd(TAG, "[ctor] stories reset");
}
}
ContentHandlerFactoryTest.java 文件源码
项目:In-the-Box-Fork
阅读 16
收藏 0
点赞 0
评论 0
public ContentHandler createContentHandler(String mimetype) {
isCreateContentHandlerCalled = true;
return new TestContentHandler();
}
URLHandler.java 文件源码
项目:sana.mobile
阅读 28
收藏 0
点赞 0
评论 0
@Override
public ContentHandler createContentHandler(String mimetype) {
return null;
}