public Control load(ILoadingContext loadingContext, InputStream stream, URL input, Map<String, Object> options) throws Exception {
// Detect from url or file path.
long start = System.currentTimeMillis();
Control control = null;
ElementManager manager = new ElementManager();
if (input != null) {
Element element = null;
if (stream == null) {
element = manager.load(input, (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK));
}
else {
IBeforeParsingCallback callback = (IBeforeParsingCallback) options.get(IXWTLoader.BEFORE_PARSING_CALLBACK);
InputStream inputStream = stream;
if (callback != null) {
int size = stream.read();
byte[] buffer = new byte[size];
stream.read(buffer);
String content = new String(buffer);
stream.close();
content = callback.onParsing(content);
inputStream = new ByteArrayInputStream(content.getBytes());
element = manager.load(stream, input);
}
element = manager.load(inputStream, input);
}
IRenderingContext context = new ExtensionContext(loadingContext,
manager, manager.getRootElement().getNamespace());
Object visual = createCLRElement(context, element, options);
if (TRACE_BENCH) {
System.out.println("Loaded: "
+ (System.currentTimeMillis() - start) + " "
+ input.toString());