1.1 --- a/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java Mon Sep 29 11:50:34 2014 -0700 1.2 +++ b/src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/unmarshaller/UnmarshallingContext.java Sun Aug 31 16:14:36 2014 +0400 1.3 @@ -1,5 +1,5 @@ 1.4 /* 1.5 - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. 1.6 + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. 1.7 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.8 * 1.9 * This code is free software; you can redistribute it and/or modify it 1.10 @@ -35,8 +35,6 @@ 1.11 import java.util.List; 1.12 import java.util.Map; 1.13 import java.util.concurrent.Callable; 1.14 -import java.util.logging.Level; 1.15 -import java.util.logging.Logger; 1.16 1.17 import javax.xml.XMLConstants; 1.18 import javax.xml.bind.JAXBElement; 1.19 @@ -198,20 +196,19 @@ 1.20 /** 1.21 * Loader that owns this element. 1.22 */ 1.23 - public Loader loader; 1.24 + private Loader loader; 1.25 /** 1.26 * Once {@link #loader} is completed, this receiver 1.27 * receives the result. 1.28 */ 1.29 - public Receiver receiver; 1.30 + private Receiver receiver; 1.31 1.32 - public Intercepter intercepter; 1.33 - 1.34 + private Intercepter intercepter; 1.35 1.36 /** 1.37 * Object being unmarshalled by this {@link #loader}. 1.38 */ 1.39 - public Object target; 1.40 + private Object target; 1.41 1.42 /** 1.43 * Hack for making JAXBElement unmarshalling work. 1.44 @@ -240,7 +237,7 @@ 1.45 * @see ElementBeanInfoImpl.IntercepterLoader#startElement(State, TagName) 1.46 * @see ElementBeanInfoImpl.IntercepterLoader#intercept(State, Object) 1.47 */ 1.48 - public Object backup; 1.49 + private Object backup; 1.50 1.51 /** 1.52 * Number of {@link UnmarshallingContext#nsBind}s declared thus far. 1.53 @@ -256,17 +253,22 @@ 1.54 * or by a child {@link Loader} when 1.55 * {@link Loader#startElement(State, TagName)} is called. 1.56 */ 1.57 - public String elementDefaultValue; 1.58 + private String elementDefaultValue; 1.59 1.60 /** 1.61 * {@link State} for the parent element 1.62 * 1.63 * {@link State} objects form a doubly linked list. 1.64 */ 1.65 - public State prev; 1.66 + private State prev; 1.67 private State next; 1.68 1.69 - public boolean nil = false; 1.70 + private boolean nil = false; 1.71 + 1.72 + /** 1.73 + * specifies that we are working with mixed content 1.74 + */ 1.75 + private boolean mixed = false; 1.76 1.77 /** 1.78 * Gets the context. 1.79 @@ -280,6 +282,8 @@ 1.80 this.prev = prev; 1.81 if (prev!=null) { 1.82 prev.next = this; 1.83 + if (prev.mixed) // parent is in mixed mode 1.84 + this.mixed = true; 1.85 } 1.86 } 1.87 1.88 @@ -289,7 +293,7 @@ 1.89 } 1.90 if (next==null) { 1.91 assert current == this; 1.92 - allocateMoreStates(); 1.93 + next = new State(this); 1.94 } 1.95 nil = false; 1.96 State n = next; 1.97 @@ -304,11 +308,71 @@ 1.98 assert prev!=null; 1.99 loader = null; 1.100 nil = false; 1.101 + mixed = false; 1.102 receiver = null; 1.103 intercepter = null; 1.104 elementDefaultValue = null; 1.105 target = null; 1.106 current = prev; 1.107 + next = null; 1.108 + } 1.109 + 1.110 + public boolean isMixed() { 1.111 + return mixed; 1.112 + } 1.113 + 1.114 + public Object getTarget() { 1.115 + return target; 1.116 + } 1.117 + 1.118 + public void setLoader(Loader loader) { 1.119 + if (loader instanceof StructureLoader) // set mixed mode 1.120 + mixed = !((StructureLoader)loader).getBeanInfo().hasElementOnlyContentModel(); 1.121 + this.loader = loader; 1.122 + } 1.123 + 1.124 + public void setReceiver(Receiver receiver) { 1.125 + this.receiver = receiver; 1.126 + } 1.127 + 1.128 + public State getPrev() { 1.129 + return prev; 1.130 + } 1.131 + 1.132 + public void setIntercepter(Intercepter intercepter) { 1.133 + this.intercepter = intercepter; 1.134 + } 1.135 + 1.136 + public void setBackup(Object backup) { 1.137 + this.backup = backup; 1.138 + } 1.139 + 1.140 + public void setTarget(Object target) { 1.141 + this.target = target; 1.142 + } 1.143 + 1.144 + public Object getBackup() { 1.145 + return backup; 1.146 + } 1.147 + 1.148 + public boolean isNil() { 1.149 + return nil; 1.150 + } 1.151 + 1.152 + public void setNil(boolean nil) { 1.153 + this.nil = nil; 1.154 + } 1.155 + 1.156 + public Loader getLoader() { 1.157 + return loader; 1.158 + } 1.159 + 1.160 + public String getElementDefaultValue() { 1.161 + return elementDefaultValue; 1.162 + } 1.163 + 1.164 + public void setElementDefaultValue(String elementDefaultValue) { 1.165 + this.elementDefaultValue = elementDefaultValue; 1.166 } 1.167 } 1.168 1.169 @@ -348,7 +412,6 @@ 1.170 this.parent = _parent; 1.171 this.assoc = assoc; 1.172 this.root = this.current = new State(null); 1.173 - allocateMoreStates(); 1.174 } 1.175 1.176 public void reset(InfosetScanner scanner,boolean isInplaceMode, JaxBeanInfo expectedType, IDResolver idResolver) { 1.177 @@ -395,23 +458,6 @@ 1.178 return null; 1.179 } 1.180 1.181 - /** 1.182 - * Allocates a few more {@link State}s. 1.183 - * 1.184 - * Allocating multiple {@link State}s at once allows those objects 1.185 - * to be allocated near each other, which reduces the working set 1.186 - * of CPU. It improves the chance the relevant data is in the cache. 1.187 - */ 1.188 - private void allocateMoreStates() { 1.189 - // this method should be used only when we run out of a state. 1.190 - assert current.next==null; 1.191 - 1.192 - State s = current; 1.193 - for (int i=0; i<8; i++) { 1.194 - s = new State(s); 1.195 - } 1.196 - } 1.197 - 1.198 public void clearStates() { 1.199 State last = current; 1.200 while (last.next != null) last = last.next; 1.201 @@ -515,16 +561,15 @@ 1.202 1.203 @Override 1.204 public void text(CharSequence pcdata) throws SAXException { 1.205 - State cur = current; 1.206 pushCoordinator(); 1.207 try { 1.208 - if(cur.elementDefaultValue!=null) { 1.209 - if(pcdata.length()==0) { 1.210 + if (current.elementDefaultValue != null) { 1.211 + if (pcdata.length() == 0) { 1.212 // send the default value into the unmarshaller instead 1.213 - pcdata = cur.elementDefaultValue; 1.214 + pcdata = current.elementDefaultValue; 1.215 } 1.216 } 1.217 - cur.loader.text(cur,pcdata); 1.218 + current.loader.text(current, pcdata); 1.219 } finally { 1.220 popCoordinator(); 1.221 }