1 28 29 package org.jibx.binding.model; 30 31 import org.jibx.binding.util.StringArray; 32 import org.jibx.runtime.EnumSet; 33 34 40 41 public class NestingAttributes extends AttributeBase 42 { 43 44 public static final StringArray s_allowedAttributes = 45 new StringArray(new String [] { "value-style" }); 46 47 50 public static final int ATTRIBUTE_STYLE = 0; 51 public static final int ELEMENT_STYLE = 1; 52 53 static final EnumSet s_styleEnum = new EnumSet(ATTRIBUTE_STYLE, 54 new String [] { "attribute", "element" }); 55 56 59 60 private String m_styleName; 61 62 63 private int m_styleIndex; 64 65 70 public String getStyleName() { 71 return m_styleName; 72 } 73 74 80 public int getStyle() { 81 return m_styleIndex; 82 } 83 84 90 public void setStyleName(String name) { 91 m_styleName = name; 92 } 93 94 97 100 public void prevalidate(ValidationContext vctx) { 101 if (m_styleName == null) { 102 NestingElementBase parent = vctx.getParentElement(); 103 if (parent == null) { 104 m_styleIndex = ELEMENT_STYLE; 105 } else { 106 m_styleIndex = parent.getDefaultStyle(); 107 } 108 } else { 109 int style = s_styleEnum.getValue(m_styleName); 110 if (style < 0) { 111 vctx.addError("Value \"" + m_styleName + 112 "\" is not a valid style"); 113 } else { 114 m_styleIndex = style; 115 } 116 } 117 super.prevalidate(vctx); 118 } 119 } | Popular Tags |