Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kew.routeheader;
 
 
 
Standard implementation of DocumentContent which nows hows to parse a String that it's constructed with into content with the application, attribute, and searchable content sections.

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class StandardDocumentContent implements DocumentContentSerializable {
 
 	private static final long serialVersionUID = -3189330007364191220L;
 	
 	private static final String LEGACY_FLEXDOC_ELEMENT = "flexdoc";
 
 	private String docContent;
 
 	private transient Document document;
 
 	private transient Element applicationContent;
 
 	private transient Element attributeContent;
 
 	private transient Element searchableContent;
 
 
 	public StandardDocumentContent(String docContent) {
 		this(docContentnull);
 	}
 
 	public StandardDocumentContent(String docContentRouteContext routeContext) {
 		this. = routeContext;
 		initialize(docContentrouteContext);
 	}
 
 	private void initialize(String docContentRouteContext routeContext) {
 		if (org.apache.commons.lang.StringUtils.isEmpty(docContent)) {
 			this. = "";
 			this. = null;
 		} else {
 			try {
 				this. = docContent;
 				this. = parseDocContent(docContent);
 			} catch (IOException e) {
 				throw new InvalidDocumentContentException("I/O Error when attempting to parse document content."e);
 			} catch (SAXException e) {
 				throw new InvalidDocumentContentException("XML parse error when attempting to parse document content."e);
 			} catch (ParserConfigurationException e) {
 				throw new RiceRuntimeException("XML parser configuration error when attempting to parse document content."e);
 			}
 		}
 	}
 
 		DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
 		return documentBuilder.parse(new InputSource(new BufferedReader(new StringReader(docContent))));
 	}
 
 	private void extractElements(Document document) {
 		// this handles backward compatibility in document content
			// if the root element is the flexdoc element (pre Workflow 2.0)
			// then designate that as attribute content
else {
			}
else {
			NodeList nodes = document.getDocumentElement().getChildNodes();
			for (int index = 0; index < nodes.getLength(); index++) {
				Node node = nodes.item(index);
					int numChildElements = 0;
					for (int childIndex = 0; childIndex < node.getChildNodes().getLength(); childIndex++) {
						Node child = (Nodenode.getChildNodes().item(childIndex);
						if (child.getNodeType() == .) {
							numChildElements++;
						}
					}
					// TODO can we have application content without a root node?
					if (numChildElements > 1) {
					}
				}
			}
		}
	}
	}
	}
	public String getDocContent() {
		return ;
	}
	public Document getDocument() {
		return ;
	}
	}
		return this.;
	}
	}
New to GrepCode? Check out our FAQ X