Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*     */ package org.dom4j.jaxb;
 /*     */ 
 /*     */ import java.io.StringReader;
 /*     */ import javax.xml.bind.JAXBContext;
 /*     */ import javax.xml.bind.JAXBException;
 /*     */ import javax.xml.bind.Marshaller;
 /*     */ import javax.xml.bind.Unmarshaller;
 /*     */ import javax.xml.transform.Source;
 /*     */ import javax.xml.transform.stream.StreamSource;
/*     */ import org.dom4j.dom.DOMDocument;
/*     */ 
/*     */ abstract class JAXBSupport
/*     */ {
/*     */   private String contextPath;
/*     */   private ClassLoader classloader;
/*     */   private JAXBContext jaxbContext;
/*     */   private Marshaller marshaller;
/*     */   private Unmarshaller unmarshaller;
/*     */ 
/*     */   public JAXBSupport(String contextPath)
/*     */   {
/*  38 */     this. = contextPath;
/*     */   }
/*     */ 
/*     */   public JAXBSupport(String contextPathClassLoader classloader) {
/*  42 */     this. = contextPath;
/*  43 */     this. = classloader;
/*     */   }
/*     */ 
/*     */   protected org.dom4j.Element marshal(javax.xml.bind.Element element)
/*     */     throws JAXBException
/*     */   {
/*  60 */     DOMDocument doc = new DOMDocument();
/*  61 */     getMarshaller().marshal(elementdoc);
/*     */ 
/*  63 */     return doc.getRootElement();
/*     */   }
/*     */ 
/*     */   protected javax.xml.bind.Element unmarshal(org.dom4j.Element element)
/*     */     throws JAXBException
/*     */   {
/*  80 */     Source source = new StreamSource(new StringReader(element.asXML()));
/*     */ 
/*  82 */     return (javax.xml.bind.Element)getUnmarshaller().unmarshal(source);
/*     */   }
/*     */ 
/*     */   private Marshaller getMarshaller() throws JAXBException {
/*  86 */     if (this. == null) {
/*  87 */       this. = getContext().createMarshaller();
/*     */     }
/*     */ 
/*  90 */     return this.;
/*     */   }
/*     */ 
/*     */   private Unmarshaller getUnmarshaller() throws JAXBException {
/*  94 */     if (this. == null) {
/*  95 */       this. = getContext().createUnmarshaller();
/*     */     }
/*     */ 
/*  98 */     return this.;
/*     */   }
/*     */ 
/*     */   private JAXBContext getContext() throws JAXBException {
/* 102 */     if (this. == null) {
/* 103 */       if (this. == null)
/* 104 */         this. = JAXBContext.newInstance(this.);
/*     */       else {
/* 106 */         this. = JAXBContext.newInstance(this.this.);
/*     */       }
/*     */     }
/*     */ 
/* 110 */     return this.;
/*     */   }
/*     */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/thirdparty-all.jar
 * Qualified Name:     org.dom4j.jaxb.JAXBSupport
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X