use of com.thoughtworks.xstream.XStream in project intellij-plugins by StepicOrg.
the class StepikProjectManager method getXStream.
@NotNull
public static XStream getXStream() {
if (xStream == null) {
xStream = new XStream(new DomDriver());
xStream.alias("StepikProjectManager", StepikProjectManager.class);
xStream.alias("CourseNode", CourseNode.class);
xStream.alias("SectionNode", SectionNode.class);
xStream.alias("LessonNode", LessonNode.class);
xStream.alias("StepNode", StepNode.class);
xStream.alias("Limit", Limit.class);
xStream.alias("SupportedLanguages", SupportedLanguages.class);
xStream.alias("VideoUrl", VideoUrl.class);
xStream.alias("LinkedTreeMap", LinkedTreeMap.class);
xStream.alias("Sample", Sample.class);
xStream.alias("Course", Course.class);
xStream.alias("Section", Section.class);
xStream.alias("CompoundUnitLesson", CompoundUnitLesson.class);
xStream.alias("Step", Step.class);
xStream.alias("User", User.class);
xStream.autodetectAnnotations(true);
xStream.setClassLoader(StepikProjectManager.class.getClassLoader());
xStream.registerConverter(new SupportedLanguagesConverter());
xStream.registerConverter(new SampleConverter());
xStream.ignoreUnknownElements();
xStream.setMode(XStream.ID_REFERENCES);
}
return xStream;
}
use of com.thoughtworks.xstream.XStream in project Asqatasun by Asqatasun.
the class CSSHandlerImpl method initialize.
private void initialize() {
if (initialized) {
return;
}
initializeStyleSet();
initializeCssOnErrorSet();
XStream xstream = new XStream();
for (RelatedContent relatedContent : ssp.getRelatedContentSet()) {
if (relatedContent instanceof StylesheetContent) {
StylesheetContent sc = (StylesheetContent) relatedContent;
if (isStylesheetTestable(sc)) {
styleMap.put(((Content) relatedContent).getURI(), (CascadingStyleSheet) xstream.fromXML((sc).getAdaptedContent()));
} else {
addStylesheetOnError(sc);
}
}
}
initialized = true;
}
use of com.thoughtworks.xstream.XStream in project Asqatasun by Asqatasun.
the class JSHandlerImpl method initialize.
private void initialize() {
if (initialized) {
return;
}
XStream xstream = new XStream();
for (RelatedContent relatedContent : ssp.getRelatedContentSet()) {
if (relatedContent instanceof JavascriptContent) {
if (javaScriptSet == null) {
javaScriptSet = new HashSet<>();
}
javaScriptSet.addAll((Set<JSResource>) xstream.fromXML(((JavascriptContent) relatedContent).getAdaptedContent()));
}
}
initialized = true;
}
use of com.thoughtworks.xstream.XStream in project nhin-d by DirectProject.
the class XStreamFactory method getXStreamInstance.
/**
* Gets an instance of an {@link XStream} object. This factory method creates a specialized implementation of the XStream engine
* to properly support XML object referencing
* @return An instance of an {@link XStream} XML serialization engine object.
*/
public static XStream getXStreamInstance() {
final XStream xStreamWithFieldIgnore = new XStream() {
protected MapperWrapper wrapMapper(final MapperWrapper next) {
return new MapperWrapper(next) {
public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") final Class definedIn, final String fieldName) {
///CLOVER:OFF
if (definedIn == Object.class)
return false;
///CLOVER:ON
return super.shouldSerializeMember(definedIn, fieldName);
}
};
}
};
xStreamWithFieldIgnore.setMode(XStream.NO_REFERENCES);
return xStreamWithFieldIgnore;
}
use of com.thoughtworks.xstream.XStream in project GDSC-SMLM by aherbert.
the class SettingsManager method unsafeLoadSettings.
/**
* Load the settings from the input stream. The stream will be closed.
* <p>
* If this fails then an error message is written to the ImageJ log
*
* @param inputStream
* the input stream
* @param silent
* Set to true to suppress writing an error message to the ImageJ log
* @return The settings (or null)
*/
public static GlobalSettings unsafeLoadSettings(InputStream inputStream, boolean silent) {
XStream xs = createXStream();
GlobalSettings config = null;
try {
config = (GlobalSettings) xs.fromXML(inputStream);
} catch (ClassCastException ex) {
//ex.printStackTrace();
} catch (XStreamException ex) {
ex.printStackTrace();
} finally {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (config == null)
if (!silent)
IJ.log("Unable to load settings from input stream");
return config;
}
Aggregations