- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中xdi2.core.io.XDIWriterRegistry.getDefault()
方法的一些代码示例,展示了XDIWriterRegistry.getDefault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XDIWriterRegistry.getDefault()
方法的具体详情如下:
包路径:xdi2.core.io.XDIWriterRegistry
类名称:XDIWriterRegistry
方法名:getDefault
[英]Returns an XDIWriter for the default format.
[中]返回默认格式的XDIWriter。
代码示例来源:origin: projectdanube/xdi2
/**
* Returns an XDIWriter for the specified format, e.g.
* <ul>
* <li>XDI/JSON</li>
* <li>XDI DISPLAY</li>
* </ul>
* @param format The desired format.
* @return An XDIWriter, or null if no appropriate implementation could be found.
*/
public static XDIWriter forFormat(String format, Properties parameters) {
if (format == null) return XDIWriterRegistry.getDefault();
Class<? extends XDIWriter> writerClass = writerClassesByFormat.get(format);
if (writerClass == null) return null;
try {
Constructor<? extends XDIWriter> constructor = writerClass.getConstructor(Properties.class);
return constructor.newInstance(parameters);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: projectdanube/xdi2
/**
* Returns an XDIWriter for the specified file extension, e.g.
* <ul>
* <li>.json</li>
* <li>.xdi</li>
* </ul>
* @param fileExtension The desired file extension.
* @return An XDIWriter, or null if no appropriate implementation could be found.
*/
public static XDIWriter forFileExtension(String fileExtension, Properties parameters) {
if (fileExtension == null) return XDIWriterRegistry.getDefault();
Class<? extends XDIWriter> writerClass = writerClassesByFileExtension.get(fileExtension);
if (writerClass == null) return null;
try {
Constructor<? extends XDIWriter> constructor = writerClass.getConstructor(Properties.class);
return constructor.newInstance(parameters);
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: projectdanube/xdi2
/**
* Returns an XDIWriter for the specified mime type, e.g.
* <ul>
* <li>application/xdi+json</li>
* <li>text/xdi</li>
* </ul>
* @param mimeType The desired mime type.
* @return An XDIWriter, or null if no appropriate implementation could be found.
*/
public static XDIWriter forMimeType(MimeType mimeType) {
if (mimeType == null) return XDIWriterRegistry.getDefault();
Class<? extends XDIWriter> writerClass = writerClassesByMimeType.get(mimeType.mimeTypeWithoutParameters());
if (writerClass == null) return null;
try {
Constructor<? extends XDIWriter> constructor = writerClass.getConstructor(Properties.class);
return constructor.newInstance(mimeType.getParameters());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
代码示例来源:origin: projectdanube/xdi2
@Override
public String toString(String format, Properties parameters) {
if (format == null) format = XDIWriterRegistry.getDefault().getFormat();
XDIWriter writer = XDIWriterRegistry.forFormat(format, parameters);
if (writer == null) throw new Xdi2RuntimeException("Unknown format for XDI serialization: " + format);
StringWriter buffer = new StringWriter();
try {
writer.write(this, buffer);
} catch (IOException ex) {
return "[Exception: " + ex.getMessage() + "]";
}
return buffer.toString();
}
代码示例来源:origin: projectdanube/xdi2
private static void sendText(WebSocketTransportRequest request, WebSocketTransportResponse response, TransportMessagingResponse messagingResponse) throws IOException {
// use default writer
XDIWriter writer = null;
MimeType sendMimeType = null;
writer = sendMimeType != null ? XDIWriterRegistry.forMimeType(sendMimeType) : null;
if (writer == null) writer = XDIWriterRegistry.getDefault();
// send out the message result
if (log.isDebugEnabled()) log.debug("Sending result in " + sendMimeType + " with writer " + writer.getClass().getSimpleName() + ".");
StringWriter buffer = new StringWriter();
writer.write(messagingResponse.getGraph(), buffer);
// TODO figure out if we can use .getAsync() and avoid concurrency problems
if (buffer.getBuffer().length() > 0) {
synchronized (response.getBasic()) {
response.getBasic().sendText(buffer.getBuffer().toString());
}
}
if (log.isDebugEnabled()) log.debug("Output complete.");
}
代码示例来源:origin: projectdanube/xdi2
@Override
public InterceptorResult before(MessageEnvelope messageEnvelope, ExecutionContext executionContext, ExecutionResult executionResult) throws Xdi2MessagingException {
if (this.isEnableMessageEnvelope()) {
StringWriter stringWriter = new StringWriter();
try {
XDIWriterRegistry.getDefault().write(messageEnvelope.getGraph(), stringWriter);
} catch (IOException ex) {
throw new Xdi2MessagingException("Cannot write graph: " + ex.getMessage(), ex, executionContext);
}
String param = stringWriter.getBuffer().toString();
this.executeCommandLine(param, executionContext);
}
return InterceptorResult.DEFAULT;
}
代码示例来源:origin: projectdanube/xdi2
private void sendOk(HttpTransportRequest request, HttpTransportResponse response, TransportMessagingResponse messagingResponse) throws IOException {
response.setStatus(HttpTransportResponse.SC_OK);
Map<String, String> headers = new HashMap<String, String> ();
headers.putAll(this.getHeaders());
if (HttpTransportRequest.METHOD_GET.equals(request.getMethod())) headers.putAll(this.getHeadersGet());
if (HttpTransportRequest.METHOD_POST.equals(request.getMethod())) headers.putAll(this.getHeadersPost());
if (HttpTransportRequest.METHOD_PUT.equals(request.getMethod())) headers.putAll(this.getHeadersPut());
if (HttpTransportRequest.METHOD_DELETE.equals(request.getMethod())) headers.putAll(this.getHeadersDelete());
if (HttpTransportRequest.METHOD_OPTIONS.equals(request.getMethod())) headers.putAll(this.getHeadersOptions());
for (Map.Entry<String, String> header : headers.entrySet()) {
response.setHeader(header.getKey(), header.getValue());
}
if (messagingResponse != null) {
// find a suitable writer based on accept headers
if (log.isDebugEnabled()) log.debug("Accept: " + request.getHeader("Accept"));
XDIWriter writer = null;
String acceptHeader = request.getHeader("Accept");
MimeType sendMimeType = acceptHeader != null ? AcceptHeader.parse(acceptHeader).bestMimeType(false, true) : null;
writer = sendMimeType != null ? XDIWriterRegistry.forMimeType(sendMimeType) : null;
if (writer == null) writer = XDIWriterRegistry.getDefault();
// send out the message result
if (log.isDebugEnabled()) log.debug("Sending result in " + sendMimeType + " with writer " + writer.getClass().getSimpleName() + ".");
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
writer.write(messagingResponse.getGraph(), buffer);
response.setContentType(writer.getMimeType().toString());
response.setContentLength(buffer.size());
response.writeBody(buffer.toByteArray(), true);
}
if (log.isDebugEnabled()) log.debug("Output complete.");
}
代码示例来源:origin: projectdanube/xdi2
private void readGraph(ExecutionContext executionContext) throws Xdi2MessagingException {
XDIReader xdiReader = XDIReaderRegistry.forFormat(this.mimeType, null);
if (xdiReader == null) throw new Xdi2MessagingException("Cannot read this format: " + this.mimeType, null, executionContext);
Graph graph = this.getGraph();
graph.clear();
FileReader reader = null;
try {
File file = new File(this.path);
reader = new FileReader(file);
xdiReader.read(graph, reader);
reader.close();
} catch (FileNotFoundException ex) {
} catch (Exception ex) {
throw new Xdi2MessagingException("Cannot read file: " + ex.getMessage(), ex, executionContext);
} finally {
if (reader != null) {
try {
reader.close();
} catch (Exception ex) { }
}
}
if (xdiReader instanceof AutoReader) this.mimeType = ((AutoReader) xdiReader).getLastSuccessfulReader().getFormat();
if (this.mimeType == null) this.mimeType = XDIWriterRegistry.getDefault().getFormat();
}
代码示例来源:origin: projectdanube/xdi2
public void testDefaults() throws Exception {
assertNotNull(XDIReaderRegistry.getDefault());
assertNotNull(XDIWriterRegistry.getDefault());
}
我正在使用 this stackOverflow post 中的代码,这符合我的预期: Enumeration keys = UIManager.getDefaults().keys();
我经常使用 TimeZone.getDefault 调用,我收到了来自客户的关于运行缓慢的报告。使用 jstack 检查线程堆栈跟踪,我看到许多线程被此方法阻塞: "LoadBalancerClien
package com.soft.mash.contactmanager; import android.app.Activity; import android.os.Bundle; import
当我运行以下行时, System.out.println(java.util.TimeZone.getDefault()); 我得到了以下输出。 sun.util.calendar.Zon
这个硬编码的 GMT+2 很有魅力。 calendarCurrent.setTimeZone(TimeZone.getTimeZone("GTM+2")); 当然我不需要硬编码,所以我正在使用 cal
My server is in US and I am accessing the application in India through web browser, in that case wha
目前我的系统区域设置是en-UK,它曾经是en-US(我已经重新启动了我的电脑以使这个更改生效) 当我打印 Locale.getDefault().getCountry().toString() 时,
最近开始学习 kotlin 编程语言的 android 系统编程。在编写用于从应用程序本身发送 SMS 的简单应用程序时,我遇到了 SmsManager.getDefault() 现在已弃用的问题,因
我有以下代码: import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import
我有一个非常简单的代码: public static void main(String[] arg){ FileSystems.getDefault(); } 在Java7中运行良好 但抛出
我正在使用 eclipse 的作业 API 将大任务作为作业运行,一旦任务完成,我将 boolean 变量设置为 true,如果该变量为 true,我将在 UI 线程中执行 WizardDialog。
我正在使用 TimeZone.getDefault() 设置 Calendar 类的时区: Calendar cal = Calendar.getInstance(TimeZone.getDefaul
unix 机器上的服务器总是使用 en 作为默认语言环境。以下是语言环境输出 LANG=en_US LC_CTYPE="C" LC_NUMERIC="C" LC_TIME="C" LC_CO
本文整理了Java中xdi2.core.io.XDIReaderRegistry.getDefault()方法的一些代码示例,展示了XDIReaderRegistry.getDefault()的具体用
本文整理了Java中xdi2.core.io.XDIWriterRegistry.getDefault()方法的一些代码示例,展示了XDIWriterRegistry.getDefault()的具体用
即使将所有 SWT 代码包装在“Display.getDefault().asyncExec”中,我也无法更新我的 UI。 假设我有一个监听器,称为单击一个按钮。 Listener enterlisn
我的应用程序中有一个广播接收器,它会在设备的区域设置更改时被调用。我的应用程序在一些设备上存在错误,特别是 Nexus 5x 和 Galaxy S8+(很可能还有其他设备),其中 Locale.get
如果查找返回 null 该怎么办?我正在使用 org.openide.util.Lookup 的 Lookup.getDefault().lookup() ,它用于查找对象的实例。一般模式是传递一个
我在导入我的项目时在 eclipse 中遇到上述错误。我已经在 java 构建路径中添加了 jsse jar。错误代码为 var = SSLContext.getDefault().getSocket
我们有一个案例,其中运行使用 1.8.0_092 的 Java 8 应用程序的 PC 从 Locale.getDefault() 返回 null。虽然处理这个很简单,但我更担心返回 null,因为 d
我是一名优秀的程序员,十分优秀!