Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   *  Copyright 2007-2013, Plutext Pty Ltd.
   *   
   *  This file is part of docx4j.
  
      docx4j is licensed under the Apache 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.apache.org/licenses/LICENSE-2.0 
 
     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.docx4j.wml; 
 
 
 import java.util.List;

Java class for anonymous complex type.

The following schema fragment specifies the expected content contained within this class.

 <complexType>
   <complexContent>
     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
       <sequence>
         <element name="pPr" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}CT_PPr" minOccurs="0"/>
         <group ref="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}EG_PContent" maxOccurs="unbounded" minOccurs="0"/>
       </sequence>
       <attGroup ref="{http://schemas.microsoft.com/office/word/2010/wordml}AG_Parids"/>
       <attribute name="rsidRPr" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
       <attribute name="rsidR" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
       <attribute name="rsidDel" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
       <attribute name="rsidP" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
       <attribute name="rsidRDefault" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_LongHexNumber" />
     </restriction>
   </complexContent>
 </complexType>
 
 
 @XmlType(name = "", propOrder = {
     "pPr",
     "content"
 })
 @XmlRootElement(name = "p")
 public class P implements ChildContentAccessor
 {
 	private static Logger log = LoggerFactory.getLogger(P.class);	
 
     protected PPr pPr;
     @XmlElementRefs({
         @XmlElementRef(name = "customXmlMoveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "ins", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunIns.class),
         @XmlElementRef(name = "customXmlInsRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "subDoc", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "moveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "customXmlMoveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "moveFrom", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "customXmlMoveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "customXmlMoveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "fldSimple", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "permStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "moveTo", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "moveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "customXmlInsRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
         @XmlElementRef(name = "proofErr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = ProofErr.class),
         @XmlElementRef(name = "commentRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeEnd.class),
         @XmlElementRef(name = "moveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "r", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = R.class),
        @XmlElementRef(name = "del", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunDel.class),
        @XmlElementRef(name = "bookmarkEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "smartTag", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "oMathPara", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
        @XmlElementRef(name = "permEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "commentRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeStart.class),
        @XmlElementRef(name = "moveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "oMath", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
        @XmlElementRef(name = "customXml", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "customXmlDelRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "customXmlDelRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "hyperlink", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "sdt", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
        @XmlElementRef(name = "bookmarkStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class)
    })
    protected List<Objectcontent;
    @XmlAttribute(name = "rsidRPr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
    protected String rsidRPr;
    @XmlAttribute(name = "rsidR", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
    protected String rsidR;
    @XmlAttribute(name = "rsidDel", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
    protected String rsidDel;
    @XmlAttribute(name = "rsidP", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
    protected String rsidP;
    @XmlAttribute(name = "rsidRDefault", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
    protected String rsidRDefault;
    @XmlAttribute(name = "paraId", namespace = "http://schemas.microsoft.com/office/word/2010/wordml")
    protected String paraId;
    @XmlAttribute(name = "textId", namespace = "http://schemas.microsoft.com/office/word/2010/wordml")
    protected String textId;
    private Object parent;

    
Gets the value of the pPr property.

Returns:
possible object is
    public PPr getPPr() {
        return ;
    }

    
Sets the value of the pPr property.

Parameters:
value allowed object is
    public void setPPr(PPr value) {
        this. = value;
    }

    
Gets the value of the content property.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is not a set method for the content property.

For example, to add a new item, do as follows:

    getContent().add(newItem);
 

Objects of the following type(s) are allowed in the list <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <>

    public List<ObjectgetContent() {
        if ( == null) {
             = new ArrayList<Object>();
        }
        return this.;
    }
    @Deprecated
    public List<ObjectgetParagraphContent() {
    	return getContent();
    }
    
Gets the value of the rsidRPr property.

Returns:
possible object is
    public String getRsidRPr() {
        return ;
    }

    
Sets the value of the rsidRPr property.

Parameters:
value allowed object is
    public void setRsidRPr(String value) {
        this. = value;
    }

    
Gets the value of the rsidR property.

Returns:
possible object is
    public String getRsidR() {
        return ;
    }

    
Sets the value of the rsidR property.

Parameters:
value allowed object is
    public void setRsidR(String value) {
        this. = value;
    }

    
Gets the value of the rsidDel property.

Returns:
possible object is
    public String getRsidDel() {
        return ;
    }

    
Sets the value of the rsidDel property.

Parameters:
value allowed object is
    public void setRsidDel(String value) {
        this. = value;
    }

    
Gets the value of the rsidP property.

Returns:
possible object is
    public String getRsidP() {
        return ;
    }

    
Sets the value of the rsidP property.

Parameters:
value allowed object is
    public void setRsidP(String value) {
        this. = value;
    }

    
Gets the value of the rsidRDefault property.

Returns:
possible object is
    public String getRsidRDefault() {
        return ;
    }

    
Sets the value of the rsidRDefault property.

Parameters:
value allowed object is
    public void setRsidRDefault(String value) {
        this. = value;
    }

    
Gets the value of the paraId property. From [MS-DOCX], "an identifier for a paragraph that is unique within the document part (as specified by [ISO/IEC29500-1:2011] section 11.3), with the exception that it need not be unique across the choices or fallback of an Alternate Content block (as specified by [ISO/IEC29500-1:2011] section 17.17.3). Values MUST be greater than 0 and less than 0x80000000. Any element having this attribute MUST also have the textId attribute"

Returns:
possible object is
    public String getParaId() {
        return ;
    }

    
Sets the value of the paraId property.

Parameters:
value allowed object is
    public void setParaId(String value) {
        this. = value;
    }

    
Gets the value of the textId property. From [MS-DOCX], "a version identifier for a paragraph. Values MUST be greater than 0 and less than 0x80000000. Any element having this attribute MUST also have the paraId attribute. If two documents have the same docId, then if two paragraphs within the same respective document part (as specified by [ISO/IEC29500-1:2011] section 11.3) that have the same paraId and textId SHOULD contain identical text, although formatting could differ."

Returns:
possible object is
    public String getTextId() {
        return ;
    }

    
Sets the value of the textId property.

Parameters:
value allowed object is
    public void setTextId(String value) {
        this. = value;
    }

    
Gets the parent object in the object tree representing the unmarshalled xml document.

Returns:
The parent object.
    public Object getParent() {
        return this.;
    }
    public void setParent(Object parent) {
        this. = parent;
    }

    
This method is invoked by the JAXB implementation on each instance when unmarshalling completes.

Parameters:
parent The parent object in the object tree.
unmarshaller The unmarshaller that generated the instance.
    public void afterUnmarshal(Unmarshaller unmarshallerObject parent) {
        setParent(parent);
    }


    
Hyperlink

Java class for anonymous complex type.

The following schema fragment specifies the expected content contained within this class.

 <complexType>
   <complexContent>
     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
       <group ref="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}EG_PContent" maxOccurs="unbounded" minOccurs="0"/>
       <attribute name="tgtFrame" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
       <attribute name="tooltip" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
       <attribute name="docLocation" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
       <attribute name="history" type="{http://www.w3.org/2001/XMLSchema}boolean" default="true" />
       <attribute name="anchor" type="{http://schemas.openxmlformats.org/wordprocessingml/2006/main}ST_String" />
       <attribute ref="{http://schemas.openxmlformats.org/officeDocument/2006/relationships}id"/>
     </restriction>
   </complexContent>
 </complexType>
 
    @XmlType(name = "", propOrder = {
        "content"
    })
    @XmlRootElement(name = "hyperlink")    
    public static class Hyperlink
        implements ChildContentAccessor
    {
        @XmlElementRefs({
            @XmlElementRef(name = "moveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "subDoc", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "moveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "sdt", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXml", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "ins", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunIns.class),
            @XmlElementRef(name = "hyperlink", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "bookmarkEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlInsRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "moveFrom", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "proofErr", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = ProofErr.class),
            @XmlElementRef(name = "customXmlDelRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "commentRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeEnd.class),
            @XmlElementRef(name = "r", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = R.class),
            @XmlElementRef(name = "del", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = RunDel.class),
            @XmlElementRef(name = "customXmlMoveToRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "oMathPara", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
            @XmlElementRef(name = "permEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "moveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "moveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlDelRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlMoveFromRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlMoveFromRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "bookmarkStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "smartTag", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "commentRangeStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = CommentRangeStart.class),
            @XmlElementRef(name = "moveTo", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlMoveToRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "permStart", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "oMath", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/math", type = JAXBElement.class),
            @XmlElementRef(name = "customXmlInsRangeEnd", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class),
            @XmlElementRef(name = "fldSimple", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", type = JAXBElement.class)
        })
        protected List<Objectcontent;
        @XmlAttribute(name = "tgtFrame", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
        protected String tgtFrame;
        @XmlAttribute(name = "tooltip", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
        protected String tooltip;
        @XmlAttribute(name = "docLocation", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
        protected String docLocation;
        @XmlAttribute(name = "history", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
        protected Boolean history;
        @XmlAttribute(name = "anchor", namespace = "http://schemas.openxmlformats.org/wordprocessingml/2006/main")
        protected String anchor;
        @XmlAttribute(name = "id", namespace = "http://schemas.openxmlformats.org/officeDocument/2006/relationships")
        protected String id;
        @XmlTransient
        private Object parent;

        
Gets the value of the content property.

This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is not a set method for the content property.

For example, to add a new item, do as follows:

    getContent().add(newItem);
 

Objects of the following type(s) are allowed in the list <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <> <>

Since:
2.7
        public List<ObjectgetContent() {
            if ( == null) {
                 = new ArrayList<Object>();
            }
            return this.;
        }
        
        @Deprecated
        public List<ObjectgetParagraphContent() {
        	return getContent();
        }        

        
Gets the value of the tgtFrame property.

Returns:
possible object is
        public String getTgtFrame() {
            return ;
        }

        
Sets the value of the tgtFrame property.

Parameters:
value allowed object is
        public void setTgtFrame(String value) {
            this. = value;
        }

        
Gets the value of the tooltip property.

Returns:
possible object is
        public String getTooltip() {
            return ;
        }

        
Sets the value of the tooltip property.

Parameters:
value allowed object is
        public void setTooltip(String value) {
            this. = value;
        }

        
Gets the value of the docLocation property.

Returns:
possible object is
        public String getDocLocation() {
            return ;
        }

        
Sets the value of the docLocation property.

Parameters:
value allowed object is
        public void setDocLocation(String value) {
            this. = value;
        }

        
Gets the value of the history property.

Returns:
possible object is
        public boolean isHistory() {
            if ( == null) {
                return true;
            } else {
                return ;
            }
        }

        
Sets the value of the history property.

Parameters:
value allowed object is
        public void setHistory(Boolean value) {
            this. = value;
        }

        
Gets the value of the anchor property.

Returns:
possible object is
        public String getAnchor() {
            return ;
        }

        
Sets the value of the anchor property.

Parameters:
value allowed object is
        public void setAnchor(String value) {
            this. = value;
        }

        
Hyperlink Target

Returns:
possible object is
        public String getId() {
            return ;
        }

        
Sets the value of the id property.

Parameters:
value allowed object is
        public void setId(String value) {
            this. = value;
        }

        
Gets the parent object in the object tree representing the unmarshalled xml document.

Returns:
The parent object.
        public Object getParent() {
            return this.;
        }
        public void setParent(Object parent) {
            this. = parent;
        }

        
This method is invoked by the JAXB implementation on each instance when unmarshalling completes.

Parameters:
parent The parent object in the object tree.
unmarshaller The unmarshaller that generated the instance.
        public void afterUnmarshal(Unmarshaller unmarshallerObject parent) {
            setParent(parent);
        }
    }
    // Not generated
    
Get the text content of all runs in the P. WARNING: this only gets ./w:r/w:t. That is incomplete. Try org.docx4j.TextUtils.extractText instead.
    @Deprecated
    public String toString() {
    	StringBuilder result = new StringBuilder();
    	
    	List<Objectchildren = getParagraphContent();
    	
//    	System.out.println("p.toString");
    	
		for (Object o : children ) {					
//			System.out.println("  " + o.getClass().getName() );
			if ( o instanceof org.docx4j.wml.R) {
//		    	System.out.println("Hit R");
				org.docx4j.wml.R  run = (org.docx4j.wml.R)o;
		    	List runContent = run.getContent();
				for (Object o2 : runContent ) {					
					if ( o2 instanceof javax.xml.bind.JAXBElement) {
						// TODO - unmarshall directly to Text.
						if ( ((JAXBElement)o2).getDeclaredType().getName().equals("org.docx4j.wml.Text") ) {
//					    	System.out.println("Found Text");
							result.appendt.getValue() );					
						}
else {
//				    	System.out.println(o2.getClass().getName());						
					}
				}
		}
		return result.toString();
    	
    }
    public void replaceElement(Object currentList insertions) {
    	int index = .indexOf(current);    	
    	if (index > -1 ) {    		
    		.addAll(index+1, insertions);  
    		Object removed = .remove(index);
    		// sanity check
    		if (!current.equals(removed)) {
    			.error("removed wrong object?");
    		}    		
    	} else {
    		// Not found
    		.error("Couldn't find replacement target.");
    	}
    }    
    
New to GrepCode? Check out our FAQ X