use of biblemulticonverter.schema.zef2005.ObjectFactory in project BibleMultiConverter by schierlm.
the class ZefaniaXML method createXMLBible.
protected XMLBIBLE createXMLBible(Bible bible) throws Exception {
ObjectFactory of = new ObjectFactory();
XMLBIBLE doc = of.createXMLBIBLE();
doc.setBiblename(bible.getName());
doc.setType(EnumModtyp.X_BIBLE);
doc.setINFORMATION(of.createINFORMATION());
MetadataBook metadata = bible.getMetadataBook();
if (metadata != null) {
for (String key : metadata.getKeys()) {
String value = metadata.getValue(key);
if (key.equals(MetadataBookKey.status.toString())) {
doc.setStatus(EnumStatus.fromValue(value));
} else if (key.equals(MetadataBookKey.version.toString())) {
doc.setVersion(value);
} else if (key.equals(MetadataBookKey.revision.toString())) {
doc.setRevision(new BigInteger(value));
} else if (!key.contains("@")) {
Pattern regex = INFORMATION_FIELDS.get(MetadataBookKey.valueOf(key));
if (regex != null && regex.matcher(value).matches())
doc.getINFORMATION().getTitleOrCreatorOrDescription().add(new JAXBElement<String>(new QName(key), String.class, value));
}
}
}
doc.getINFORMATION().getTitleOrCreatorOrDescription().add(new JAXBElement<String>(new QName("format"), String.class, "Zefania XML Bible Markup Language"));
for (Book bk : bible.getBooks()) {
if (bk.getId().equals(BookID.METADATA))
continue;
if (bk.getId().getZefID() <= 0) {
System.out.println("WARNING: Unable to export book " + bk.getAbbr());
continue;
}
BIBLEBOOK bb = of.createBIBLEBOOK();
bb.setBnumber(BigInteger.valueOf(bk.getId().getZefID()));
bb.setBsname(bk.getShortName());
bb.setBname(bk.getLongName());
int cnumber = 0;
for (Chapter ccc : bk.getChapters()) {
cnumber++;
if (ccc.getVerses().size() == 0)
continue;
CHAPTER cc = of.createCHAPTER();
cc.setCnumber(BigInteger.valueOf(cnumber));
bb.getCHAPTER().add(cc);
if (ccc.getProlog() != null) {
PROLOG prolog = of.createPROLOG();
prolog.setVref(BigInteger.ONE);
ccc.getProlog().accept(new CreateContentVisitor(of, prolog.getContent(), null));
cc.getPROLOGOrCAPTIONOrVERS().add(prolog);
}
for (VirtualVerse vv : ccc.createVirtualVerses()) {
for (Headline h : vv.getHeadlines()) {
CAPTION caption = of.createCAPTION();
caption.setVref(BigInteger.valueOf(vv.getNumber()));
h.accept(new CreateContentVisitor(of, caption.getContent(), null));
EnumCaptionType[] types = new EnumCaptionType[] { null, EnumCaptionType.X_H_1, EnumCaptionType.X_H_2, EnumCaptionType.X_H_3, EnumCaptionType.X_H_4, EnumCaptionType.X_H_5, EnumCaptionType.X_H_6, null, null, null };
caption.setType(types[h.getDepth()]);
cc.getPROLOGOrCAPTIONOrVERS().add(caption);
}
VERS vers = of.createVERS();
vers.setVnumber(BigInteger.valueOf(vv.getNumber()));
for (Verse v : vv.getVerses()) {
if (!v.getNumber().equals("" + vv.getNumber())) {
STYLE verseNum = of.createSTYLE();
verseNum.setCss("font-weight: bold");
verseNum.getContent().add("(" + v.getNumber() + ")");
vers.getContent().add(new JAXBElement<STYLE>(new QName("STYLE"), STYLE.class, verseNum));
vers.getContent().add(" ");
}
v.accept(new CreateContentVisitor(of, vers.getContent(), vers));
}
cc.getPROLOGOrCAPTIONOrVERS().add(vers);
}
}
doc.getBIBLEBOOK().add(bb);
}
return doc;
}
use of biblemulticonverter.schema.zef2005.ObjectFactory in project onebusaway-application-modules by camsys.
the class SpringContainer method register.
@Override
public void register(ContainerBuilder builder, LocatableProperties props) throws ConfigurationException {
// Since we're about to override...
builder.setAllowDuplicates(true);
builder.factory(ObjectFactory.class, new Factory<ObjectFactory>() {
public ObjectFactory create(Context xworkContext) throws Exception {
SpringObjectFactory f = new SpringObjectFactory();
xworkContext.getContainer().inject(f);
f.setApplicationContext(_applicationContext);
f.setAutowireStrategy(_autoWireStrategy);
return f;
}
});
}
Aggregations