Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER Copyright 2011 IBM. All rights reserved. Use is subject to license terms. 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. You can also obtain a copy of the License at http://odftoolkit.org/docs/license.txt 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.odftoolkit.simple.text.list;
 
 
AbstractListContainer is an abstract implementation of the ListContainer interface, with a default implementation for every method defined in ListContainer , except getListContainerElement(). A subclass must implement the abstract method getListContainerElement().

Since:
0.4
 
 public abstract class AbstractListContainer implements ListContainer {
 
 	public List addList() {
 		return new List(this);
 	}
 
 	public List addList(ListDecorator decorator) {
 		return new List(thisdecorator);
 	}
 
 	public void clearList() {
 		OdfElement containerElement = getListContainerElement();
 		while (child != null) {
 			if (child instanceof TextListElement) {
 				Node tmp = child;
 				child = child.getNextSibling();
 				containerElement.removeChild(tmp);
 			} else {
 				child = child.getNextSibling();
 			}
 		}
 	}
 
 	public Iterator<ListgetListIterator() {
 		return new SimpleListIterator(this);
 	}
 
 	public boolean removeList(List list) {
 		OdfElement containerElement = getListContainerElement();
 		Node child = containerElement.getFirstChild();
 		OdfFileDom ownerDocument = (OdfFileDomcontainerElement.getOwnerDocument();
 		Document doc = (DocumentownerDocument.getDocument();
 		while (child != null) {
 			if (child instanceof TextListElement) {
 				TextListElement listElement1 = (TextListElementchild;
 				String id1 = listElement1.getXmlIdAttribute();
 				TextListElement listElement2 = list.getOdfElement();
 				String id2 = listElement2.getXmlIdAttribute();
 				if ((listElement1 == listElement2) || ((id1 != null) && (id2 != null) && (id1.equals(id2)))) {
 					doc.removeElementLinkedResource(listElement1);
 					containerElement.removeChild(child);
 					return true;
 				}
 			}
 			child = child.getNextSibling();
 		}
 		return false;
 	}
 
 	// default iterator to iterate list item.
 	private class SimpleListIterator implements Iterator<List> {
 
 
 		private SimpleListIterator(ListContainer container) {
 		}
		public boolean hasNext() {
			return ( != null);
		}
		public List next() {
			if ( != null) {
else {
			}
			if ( == null) {
				return null;
else {
				return new List();
			}
		}
		public void remove() {
			if ( == null) {
				throw new IllegalStateException("please call next() first.");
			}
		}
		private TextListElement findNext(TextListElement nextListElement) {
			Node child = null;
			if (nextListElement == null) {
else {
				child = nextListElement.getNextSibling();
			}
			while (child != null) {
				if (child instanceof TextListElement) {
					return (TextListElementchild;
				}
				child = child.getNextSibling();
			}
			return null;
		}
	}
New to GrepCode? Check out our FAQ X