Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 /*     */ package com.sun.xml.bind.v2.runtime.property;
 /*     */ 
 /*     */ import com.sun.xml.bind.api.AccessorException;
 /*     */ import com.sun.xml.bind.v2.runtime.Name;
 /*     */ import com.sun.xml.bind.v2.runtime.NameBuilder;
/*     */ import com.sun.xml.bind.v2.util.QNameMap;
/*     */ import java.io.IOException;
/*     */ import java.util.List;
/*     */ import javax.xml.stream.XMLStreamException;
/*     */ import org.xml.sax.SAXException;
/*     */ 
/*     */ final class SingleElementLeafProperty<BeanT> extends PropertyImpl<BeanT>
/*     */ {
/*     */   private final Name tagName;
/*     */   private final boolean nillable;
/*     */   private final Accessor acc;
/*     */   private final String defaultValue;
/*     */   private final TransducedAccessor<BeanT> xacc;
/*     */ 
/*     */   public SingleElementLeafProperty(JAXBContextImpl contextRuntimeElementPropertyInfo prop)
/*     */   {
/*  75 */     super(context, prop);
/*  76 */     RuntimeTypeRef ref = (RuntimeTypeRef)prop.getTypes().get(0);
/*  77 */     this.tagName = context.nameBuilder.createElementName(ref.getTagName());
/*  78 */     assert (this.tagName != null);
/*  79 */     this.nillable = ref.isNillable();
/*  80 */     this.defaultValue = ref.getDefaultValue();
/*  81 */     this.acc = prop.getAccessor().optimize(context);
/*     */ 
/*  83 */     this.xacc = TransducedAccessor.get(context, ref);
/*  84 */     assert (this.xacc != null);
/*     */   }
/*     */ 
/*     */   public void reset(BeanT othrows AccessorException {
/*  88 */     this.acc.set(o, null);
/*     */   }
/*     */ 
/*     */   public String getIdValue(BeanT beanthrows AccessorExceptionSAXException {
/*  92 */     return this.xacc.print(bean).toString();
/*     */   }
/*     */ 
/*     */   public void serializeBody(BeanT oXMLSerializer wObject outerPeerthrows SAXExceptionAccessorExceptionIOExceptionXMLStreamException {
/*  96 */     boolean hasValue = this.xacc.hasValue(o);
/*  97 */     if (hasValue) {
/*  98 */       this.xacc.writeLeafElement(w, this.tagName, o, this.fieldName);
/*     */     }
/* 100 */     else if (this.nillable) {
/* 101 */       w.startElement(this.tagName, null);
/* 102 */       w.writeXsiNilTrue();
/* 103 */       w.endElement();
/*     */     }
/*     */   }
/*     */ 
/*     */   public void buildChildElementUnmarshallers(UnmarshallerChain chainQNameMap<ChildLoaderhandlers) {
/* 108 */     Loader l = new LeafPropertyLoader(this.xacc);
/* 109 */     if (this.defaultValue != null)
/* 110 */       l = new DefaultValueLoaderDecorator(l, this.defaultValue);
/* 111 */     if ((this.nillable) || (chain.context.allNillable))
/* 112 */       l = new XsiNilLoader.Single(l, this.acc);
/* 113 */     handlers.put(this.tagName, new ChildLoader(l, null));
/*     */   }
/*     */ 
/*     */   public PropertyKind getKind()
/*     */   {
/* 118 */     return PropertyKind.ELEMENT;
/*     */   }
/*     */ 
/*     */   public Accessor getElementPropertyAccessor(String nsUriString localName)
/*     */   {
/* 123 */     if (this.tagName.equals(nsUri, localName)) {
/* 124 */       return this.acc;
/*     */     }
/* 126 */     return null;
/*     */   }
/*     */ }
/* Location:           /home/mnovotny/projects/EMBEDDED_JBOSS_BETA3_COMMUNITY/embedded/output/lib/embedded-jboss/lib/thirdparty-all.jar
 * Qualified Name:     com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty
 * JD-Core Version:    0.6.0
 */
New to GrepCode? Check out our FAQ X