JBoss Rich Faces SVN: r14988 - in root/framework/trunk/impl/src: main/java/org/richfaces/model and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 13:02:30 -0400 (Thu, 23 Jul 2009)
New Revision: 14988
Removed:
root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java
root/framework/trunk/impl/src/main/java/org/richfaces/model/impl/
root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/
root/framework/trunk/impl/src/test/java/org/richfaces/model/impl/expressive/
Log:
Moving component APIs into ui-sandbox
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces 3.0 - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component.util;
-
-import javax.el.ValueExpression;
-import javax.faces.component.UIComponent;
-
-import org.richfaces.component.Column;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ColumnUtil {
-
- /**
- * Extract sort expression from the column
- *
- * @param column
- * @return logical representation of sort field assigned to column component given
- * In case of EL-expression, an expression string is returned instead of value - so that EL-expression can be evaluated later;
- * If there's literal value of dedicated attribute is specified, return it;
- * If attribute is not set, fall aback to component id
- */
-
- public static String getColumnSorting(UIComponent column) {
-
- UIComponent component = (UIComponent) column;
-
- ValueExpression binding = component.getValueExpression("sortExpression");
-
- if (binding != null) {
- return binding.getExpressionString();
- }
-
- if (component instanceof Column) {
- Column col = (Column) component;
- String sorting = col.getSortExpression();
-
- if (sorting != null) {
- return sorting;
- }
- }
-
-
- return component.getId();
- }
-
-
- public static boolean isSortable(UIComponent component) {
- if (component instanceof Column) {
- return ((Column) component).isSortable();
- }
- return Boolean.valueOf(String.valueOf(component.getAttributes().get("sortable")));
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,209 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Implementation stores last loaded data, so no additional requests to db will be performed
- * Acts as a proxy between the component and original data model
- * @author Maksim Kaszynski
- *
- */
-public class DataModelCache extends ScrollableTableDataModel {
-
- private static Log log = LogFactory.getLog(DataModelCache.class);
-
- private static class DataRange {
- private int startRow;
- private int endRow;
- private SortOrder sortOrder;
- private List loadedData;
-
- public DataRange(int startRow, int endRow, SortOrder sortOrder,
- List loadedData) {
- super();
- this.startRow = startRow;
- this.endRow = endRow;
- this.sortOrder = sortOrder;
- this.loadedData = loadedData;
- }
-
- public boolean match(int s, int e, SortOrder sortOrder) {
- return s == startRow
- && e == endRow
- && sortOrdersMatch(sortOrder, this.sortOrder);
- }
-
- private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
- boolean result = sortOrder1 == sortOrder2;
-
- if (sortOrder1 != null && sortOrder2 != null) {
- result = sortOrder1.equals(sortOrder2);
- }
-
- return result;
- }
-
- }
-
- private Map secondaryMapping = new HashMap();
-
- private DataRange dataRange;
-
- private ScrollableTableDataModel scrollableTableDataModel;
-
- private int rowCount = Integer.MIN_VALUE;
-
- public DataModelCache(ScrollableTableDataModel scrollableTableDataModel) {
- super();
- this.scrollableTableDataModel = scrollableTableDataModel;
-
- if (log.isTraceEnabled()) {
- log.trace("initializing with " + scrollableTableDataModel);
- }
- }
-
- public void addDataModelListener(DataModelListener listener) {
- scrollableTableDataModel.addDataModelListener(listener);
- }
-
- public DataModelListener[] getDataModelListeners() {
- return scrollableTableDataModel.getDataModelListeners();
- }
-
- public Object getObjectById(Object id) {
-
- if (log.isDebugEnabled()) {
- log.debug("Trying to get object by id" + id);
- }
- //First try to find data in inner cache
- //If not found - get it from original model
- Object cached = secondaryMapping.get(id);
-
- if (cached == null) {
-
- if (log.isDebugEnabled()) {
- log.debug("Cache miss " + id + " falling back to original model");
- }
-
- cached = scrollableTableDataModel.getObjectById(id);
- secondaryMapping.put(id, cached);
-
- }
-
- if (log.isDebugEnabled()) {
- log.debug("At last found element " + cached);
- }
-
- return cached;
- }
-
- public int getRowCount() {
- if (rowCount == Integer.MIN_VALUE) {
- rowCount = scrollableTableDataModel.getRowCount();
- }
- return rowCount;
- }
-
- public Object getRowData() {
- Object secondaryMapped = secondaryMapping.get(getRowKey());
-
- if (secondaryMapped == null) {
- secondaryMapped = super.getRowData();
- }
- return secondaryMapped;
- }
-
- public int getRowIndex() {
- return scrollableTableDataModel.getRowIndex();
- }
-
- public Object getRowKey() {
- return scrollableTableDataModel.getRowKey();
- }
-
- public SerializableDataModel getSerializableModel(Range range) {
- return scrollableTableDataModel.getSerializableModel(range);
- }
-
- public Object getWrappedData() {
- return scrollableTableDataModel.getWrappedData();
- }
-
- public boolean isRowAvailable() {
- return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
- }
-
- public List loadData(int startRow, int endRow, SortOrder sortOrder) {
- if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
- List data = scrollableTableDataModel.loadData(startRow, endRow, sortOrder);
- dataRange = new DataRange(startRow, endRow, sortOrder, data);
- }
- return dataRange.loadedData;
- }
-
- public void removeDataModelListener(DataModelListener listener) {
- scrollableTableDataModel.removeDataModelListener(listener);
- }
-
- public void setRowIndex(int arg0) {
- scrollableTableDataModel.setRowIndex(arg0);
- }
-
- public void setRowKey(Object key) {
- scrollableTableDataModel.setRowKey(key);
- super.setRowKey(key);
- }
-
- public void setWrappedData(Object arg0) {
- scrollableTableDataModel.setWrappedData(arg0);
- }
-
- public Object getId(Object o) {
- return scrollableTableDataModel.getId(o);
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- // TODO Auto-generated method stub
- super.walk(context, visitor, range, argument);
- }
- /*
- * FIXME: see superclass
- @Override
- public void setSortOrder(SortOrder sortOrder) {
- scrollableTableDataModel.setSortOrder(sortOrder);
- }
- */
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,284 +0,0 @@
-/**
-* License Agreement.
-*
-* JBoss RichFaces - Ajax4jsf Component Library
-*
-* Copyright (C) 2008 CompuGROUP Holding AG
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License version 2.1 as published by the Free Software Foundation.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Data model class for table components.<br>
- * Usage:
- * <pre>
- * ExtendedTableDataModel<SomeDataType> dataModel = new ExtendedTableDataModel<SomeDataType>(new DataProvider <SomeDataType>());
- * </pre>
- * @author pawelgo
- *
- */
-public class ExtendedTableDataModel<T> extends ExtendedDataModel implements Serializable{
-
- private static final long serialVersionUID = 7374505108088114161L;
-
- private static final Log log = LogFactory.getLog(ExtendedTableDataModel.class);
-
- private DataProvider<T> dataProvider;
- private Object rowKey;
- private List<Object> wrappedKeys = null;
- //private boolean detached = false;
- private Map<Object, T> wrappedData = new HashMap<Object, T>();
-
- public ExtendedTableDataModel(DataProvider<T> dataProvider) {
- this.dataProvider = dataProvider;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.SerializableDataModel#update()
- */
-// public void update() {
-// ;
-// }
-
- /**
- * This method never called from framework.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /**
- * This method normally called by Visitor before request Data Row.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- rowKey = key;
- }
-
- /**
- * This is main part of Visitor pattern. Method called by framework many times during request processing.
- * (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- int rowC = getRowCount();
- int firstRow = ((SequenceRange) range).getFirstRow();
- int numberOfRows = ((SequenceRange) range).getRows();
- if (numberOfRows <= 0) {
- numberOfRows = rowC;
- }
- if (wrappedKeys != null) { // Is this serialized model
- // Here we just ignore current Rage and use whatever data was saved in serialized model.
- // Such approach uses much more getByPk() operations, instead of just one request by range.
- // Concrete case may be different from that, so you can just load data from data provider by range.
- // We are using wrappedKeys list only to preserve actual order of items.
- for (Object key : wrappedKeys) {
- setRowKey(key);
- visitor.process(context, key, argument);
- }
- } else { // if not serialized, than we request data from data provider
- wrappedKeys = new ArrayList<Object>();
- int endRow = firstRow + numberOfRows;
- if (endRow > rowC){
- endRow = rowC;
- }
- for (T item : loadData(firstRow, endRow)) {
- Object key = getKey(item);
- wrappedKeys.add(key);
- wrappedData.put(key, item);
- visitor.process(context, key, argument);
- }
- }
- }//walk
-
- /**
- * Load range of data items from the source.
- * Starting from startRow, and up to but excluding endRow
- * @param startRow
- * @param endRow
- * @return list of ordered data
- */
- protected List<T> loadData(int startRow, int endRow) {
- if (log.isDebugEnabled())
- log.debug("load data from range: " + startRow + " - " + endRow);
- if (startRow < 0){
- startRow = 0;
- throw new IllegalArgumentException("Illegal start index value: " + startRow);
- }
- int rowCount = getRowCount();
- if (endRow > rowCount){
- endRow = rowCount;
- throw new IllegalArgumentException("Illegal end index value: " + endRow);
- }
- //load all from provider and get sublist
- return dataProvider.getItemsByRange(startRow, endRow);
- //return dataProvider.getItemsByRange(0, rowCount).subList(startRow, endRow);
- }//loadData
-
- /**
- * This method must return actual data rows count from the Data Provider. It is used by pagination control
- * to determine total number of data items.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- private Integer rowCount; // better to buffer row count locally
-
- public int getRowCount() {
- if (rowCount == null) {
- rowCount = new Integer(dataProvider.getRowCount());
- } else {
- return rowCount.intValue();
- }
- return rowCount.intValue();
- //return dataProvider.getRowCount();
- }
-
- /**
- * This is main way to obtain data row. It is intensively used by framework.
- * We strongly recommend use of local cache in that method.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public T getRowData() {
- if (rowKey == null) {
- return null;
- } else {
- return getObjectByKey(rowKey);
- }
- }
-
- @SuppressWarnings("unchecked")
- public Object getKey(T o) {
- return dataProvider.getKey(o);
- }
-
- public T getObjectByKey(Object key) {
- T t = wrappedData.get(key);
- if (t == null){
- t = dataProvider.getItemByKey(key);
- wrappedData.put(key, t);
- }
- return t;
- }
-
- private Integer rowIndex;
-
- /**
- * Unused rudiment from old JSF staff. (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- //throw new UnsupportedOperationException();
- return rowIndex.intValue();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- //throw new UnsupportedOperationException();
- this.rowIndex = rowIndex;
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Unused rudiment from old JSF staff.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Never called by framework.
- * (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return getRowData() != null;
- }
-
- /**
- * This method suppose to produce SerializableDataModel that will be
- * serialized into View State and used on a post-back. In current
- * implementation we just mark current model as serialized. In more
- * complicated cases we may need to transform data to actually serialized
- * form.
- */
-// public SerializableDataModel getSerializableModel(Range range) {
-// if (wrappedKeys != null) {
-// detached = true;
-// // Some activity to detach persistent data from wrappedData map may be taken here.
-// // In that specific case we are doing nothing.
-// return this;
-// } else {
-// return null;
-// }
-// }
-
- /**
- * Resets internal cached data. Call this method to reload data from data
- * provider on first access for data.
- */
- public void reset(){
- wrappedKeys = null;
- wrappedData.clear();
- rowCount = null;
- rowIndex = -1;
- rowKey = null;
- }
-
- public DataProvider<T> getDataProvider() {
- return dataProvider;
- }
-
- public void setDataProvider(DataProvider<T> dataProvider) {
- this.dataProvider = dataProvider;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,131 +0,0 @@
-/**
-* License Agreement.
-*
-* JBoss RichFaces - Ajax4jsf Component Library
-*
-* Copyright (C) 2008 CompuGROUP Holding AG
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License version 2.1 as published by the Free Software Foundation.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author pawelgo
- *
- */
-public class ExtendedTableDataModifiableModel<T> extends ModifiableModel {
-
- //private static final Log log = LogFactory.getLog(ExtendedTableDataModifiableModel.class);
-
- private ExtendedTableDataModel<T> orgModel;
- private boolean sortNeeded = true;
- private boolean filterNeeded = true;
-
- @SuppressWarnings("unchecked")
- public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider, String var) {
- super(new ExtendedTableDataModel<T>(dataProvider), var);
- this.orgModel = (ExtendedTableDataModel<T>)this.originalModel;
- }
-
- public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider) {
- this(dataProvider, null);
- }
-
- @SuppressWarnings("unchecked")
- public ExtendedTableDataModifiableModel(ExtendedTableDataModel<T> dataModel, String var) {
- super(dataModel, var);
- this.orgModel = dataModel;
- }
-
- @Override
- public Object getRowKey() {
- return originalModel.getRowKey();
- }
-
- @Override
- public void setRowKey(Object key) {
- originalModel.setRowKey(key);
- }
-
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, rowKeys.get(currentRow), argument);
- }
- }
-
- /**
- * Resets internal cached data. Call this method to reload data from data
- * provider on first access for data.
- */
- public void reset(){
- orgModel.reset();
- rowKeys = null;
- sortNeeded = true;
- filterNeeded = true;
- }
-
- public Object getKey(T o) {
- return orgModel.getKey(o);
- }
-
- public T getObjectByKey(Object key) {
- return orgModel.getObjectByKey(key);
- }
-
- @Override
- public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
- if (sortNeeded || filterNeeded){
- if (var == null){
- throw new IllegalStateException("\"var\" model attribute can not be null.");
- }
- super.modify(filterFields, sortFields);
- sortNeeded = false;
- filterNeeded = false;
- }
- }
-
- public void resetSort(){
- sortNeeded = true;
- }
-
- public void resetFilter(){
- filterNeeded = true;
- }
-
- public void setVar(String var){
- this.var = var;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,162 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ListSequenceDataModel extends ExtendedDataModel {
-
- private List<?> list;
- private int index;
-
- public ListSequenceDataModel(List<?> list) {
- setWrappedData(list);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- @Override
- public Object getRowKey() {
- if(index<0){
- return null;
- }
- return new Integer(index);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- @Override
- public void setRowKey(Object key) {
- if(null == key){
- index = -1;
- } else {
- setRowIndex(((Integer) key).intValue());
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = list !=null ? list.size() : -1;
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- setRowIndex(currentRow);
- visitor.process(context, new Integer(currentRow), argument);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- @Override
- public int getRowCount() {
- if (list == null) {
- return (-1);
- }
- return list.size();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- @Override
- public Object getRowData() {
- if (!isRowAvailable()) {
- throw new IllegalArgumentException();
- } else {
- return list.get(index);
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- @Override
- public int getRowIndex() {
- return index;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- @Override
- public Object getWrappedData() {
- return list;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- @Override
- public boolean isRowAvailable() {
- return list != null && 0 <= index && index < list.size();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- @Override
- public void setRowIndex(int rowIndex) {
- if (rowIndex < -1) {
- throw new IllegalArgumentException();
- }
- index = rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- @Override
- public void setWrappedData(Object data) {
- if (data == null) {
- list = null;
- setRowIndex(-1);
- } else {
- list = (List<?>) data;
- setRowIndex(0);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,277 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-import org.ajax4jsf.model.SerializableDataModel;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.richfaces.model.impl.expressive.JavaBeanWrapper;
-import org.richfaces.model.impl.expressive.ObjectWrapperFactory;
-import org.richfaces.model.impl.expressive.WrappedBeanComparator2;
-import org.richfaces.model.impl.expressive.WrappedBeanFilter;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableModel extends ExtendedDataModel implements Modifiable, LocaleAware {
-
- protected class RowKeyWrapperFactory extends ObjectWrapperFactory {
-
- private class ExtendedJavaBeanWrapper extends JavaBeanWrapper {
-
- private Object key;
-
- public ExtendedJavaBeanWrapper(Object key, Object o, Map<Object, Object> props) {
- super(o, props);
- this.key = key;
- }
-
- public Object getKey() {
- return key;
- }
- }
-
- public RowKeyWrapperFactory(FacesContext context, String var,
- List<? extends Field> sortOrder) {
- super(context, var, sortOrder);
- }
-
- @Override
- public JavaBeanWrapper wrapObject(Object key) {
- originalModel.setRowKey(key);
- JavaBeanWrapper wrapObject = super.wrapObject(originalModel.getRowData());
- return new ExtendedJavaBeanWrapper(key, wrapObject.getWrappedObject(), wrapObject.getProperties());
- }
-
- @Override
- public Object unwrapObject(Object wrapper) {
- return ((ExtendedJavaBeanWrapper) wrapper).getKey();
- }
- }
-
- private static final Log log = LogFactory.getLog(ModifiableModel.class);
-
- protected List<Object> rowKeys;
-
- protected ExtendedDataModel originalModel;
-
- protected String var;
-
- protected Locale locale = null;
-
- public ModifiableModel(ExtendedDataModel originalModel, String var) {
- this.originalModel = originalModel;
- this.var = var;
- }
-
- @Override
- public void addDataModelListener(DataModelListener listener) {
- originalModel.addDataModelListener(listener);
- }
-
- @Override
- public DataModelListener[] getDataModelListeners() {
- return originalModel.getDataModelListeners();
- }
-
- public Locale getLocale() {
- return locale;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-
- @Override
- public Object getRowKey() {
- Object originalModelKey = originalModel.getRowKey();
- int idx = rowKeys.indexOf(originalModelKey);
-
- if (originalModelKey != null || idx >= 0) {
- return idx;
- } else {
- return null;
- }
- }
-
- @Override
- public void setRowKey(Object key) {
- Object originalKey = null;
- if(key != null){
- int i = (Integer)key;
- if (i >= 0 && i < rowKeys.size()) {
- originalKey = rowKeys.get(i);
- }
- }
- originalModel.setRowKey(originalKey);
- }
-
- @Override
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- final SequenceRange seqRange = (SequenceRange) range;
- int rows = seqRange.getRows();
- int rowCount = getRowCount();
- int currentRow = seqRange.getFirstRow();
- if(rows > 0){
- rows += currentRow;
- rows = Math.min(rows, rowCount);
- } else {
- rows = rowCount;
- }
- for (; currentRow < rows; currentRow++) {
- visitor.process(context, currentRow, argument);
- }
- }
-
- @Override
- public int getRowCount() {
- if (rowKeys == null) {
- return -1;
- } else {
- return rowKeys.size();
- }
- }
-
- @Override
- public Object getRowData() {
- return originalModel.getRowData();
- }
-
- @Override
- public int getRowIndex() {
- return rowKeys.indexOf(originalModel.getRowKey());
- }
-
- @Override
- public Object getWrappedData() {
- return originalModel.getWrappedData();
- }
-
- @Override
- public boolean isRowAvailable() {
- return originalModel.isRowAvailable();
- }
-
- @Override
- public void setRowIndex(int rowIndex) {
- Object originalKey = null;
- if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
- originalKey = rowKeys.get(rowIndex);
- }
- originalModel.setRowKey(originalKey);
- }
-
- @Override
- public void setWrappedData(Object data) {
- originalModel.setWrappedData(data);
- }
-
- @Override
- public SerializableDataModel getSerializableModel(Range range) {
- return originalModel.getSerializableModel(range);
- }
-
- @Override
- public void removeDataModelListener(DataModelListener listener) {
- originalModel.removeDataModelListener(listener);
- }
-
-
- public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
- int rowCount = originalModel.getRowCount();
-
- if (rowCount > 0) {
- rowKeys = new ArrayList<Object>(rowCount);
- } else {
- rowKeys = new ArrayList<Object>();
- }
-
- FacesContext context = FacesContext.getCurrentInstance();
- try {
-
- originalModel.walk(context, new DataVisitor() {
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- originalModel.setRowKey(rowKey);
- if (originalModel.isRowAvailable()) {
- rowKeys.add(rowKey);
- }
- }
- }, new SequenceRange(0, -1),
- null);
- } catch (IOException e) {
- log.error(e.getMessage(), e);
- }
-
- filter(filterFields);
- sort(sortFields);
-
- }
-
- protected List<Object> filter(List<FilterField> filterFields) {
- if (filterFields != null && !filterFields.isEmpty()) {
- FacesContext context = FacesContext.getCurrentInstance();
- List <Object> filteredCollection = new ArrayList<Object>();
- ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(context, var, filterFields);
-
- WrappedBeanFilter wrappedBeanFilter = new WrappedBeanFilter(filterFields, locale);
- wrapperFactory.wrapList(rowKeys);
- for (Object object : rowKeys) {
- if(wrappedBeanFilter.accept((JavaBeanWrapper)object)) {
- filteredCollection.add(object);
- }
- }
- rowKeys = filteredCollection;
- wrapperFactory.unwrapList(rowKeys);
- }
- return rowKeys;
- }
-
- protected void sort(List<SortField2> sortFields) {
- if (sortFields != null && !sortFields.isEmpty()) {
- FacesContext context = FacesContext.getCurrentInstance();
- ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(
- context, var, sortFields);
-
- WrappedBeanComparator2 wrappedBeanComparator = new WrappedBeanComparator2(
- sortFields, locale);
- wrapperFactory.wrapList(rowKeys);
- Collections.sort(rowKeys, wrappedBeanComparator);
- wrapperFactory.unwrapList(rowKeys);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,4 +0,0 @@
-/**
- * Models implementation classes
- */
-package org.richfaces.model;
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,87 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-import junit.framework.TestCase;
-
-import org.easymock.classextension.EasyMock;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FilterFieldTest extends TestCase {
-
- private Field field;
- private ValueExpression expression;
-
- /**
- * @param name
- */
- public FilterFieldTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- expression = EasyMock.createNiceMock(ValueExpression.class);
- field = new FilterField(expression);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- field = null;
- expression = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.richfaces.model.FilterField#FilterField(javax.el.ValueExpression)}.
- */
- public final void testFilterField() {
- Field filterField = new FilterField(expression);
- assertEquals(filterField, field);
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#hashCode()}.
- */
- public final void testHashCode() {
- Field filterField = new FilterField(expression);
- assertEquals(filterField.hashCode(), field.hashCode());
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#equals(java.lang.Object)}.
- */
- public final void testEqualsObject() {
- Field filterField = new FilterField(null);
- assertFalse(filterField.equals(field));
- filterField.setExpression(expression);
- assertTrue(filterField.equals(field));
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#getExpression()}.
- */
- public final void testGetExpression() {
- assertSame(field.getExpression(), expression);
- }
-
- /**
- * Test method for {@link org.richfaces.model.Field#setExpression(javax.el.ValueExpression)}.
- */
- public final void testSetExpression() {
- field.setExpression(null);
- assertNull(field.getExpression());
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,133 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.SequenceRange;
-
-import junit.framework.TestCase;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ListSequenceDataModelTest extends TestCase {
-
- private List<Integer> list;
- private ListSequenceDataModel model;
- private ListSequenceDataModel nullModel;
-
- /**
- * @param name
- */
- public ListSequenceDataModelTest(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- list = new ArrayList<Integer>();
- for (int i = 0; i < 10; i++) {
- list.add(new Integer(i));
- }
- model = new ListSequenceDataModel(list);
- nullModel = new ListSequenceDataModel(null);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- nullModel = null;
- model = null;
- list = null;
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#isRowAvailable()}.
- */
- public final void testIsRowAvailable() {
- assertFalse(nullModel.isRowAvailable());
- assertTrue(model.isRowAvailable());
- model.setRowIndex(-1);
- assertFalse(model.isRowAvailable());
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#getRowCount()}.
- */
- public final void testGetRowCount() {
- assertEquals(model.getRowCount(), list.size());
- assertEquals(nullModel.getRowCount(), -1);
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#setRowIndex()}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowIndex()}.
- */
- public final void testRowIndex() {
- int i = 3;
- model.setRowIndex(i);
- assertEquals(model.getRowIndex(), i);
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#setRowKey(java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowKey(java.lang.Object)}.
- */
- public final void testRowKey() {
- Integer i = 3;
- model.setRowKey(i);
- assertEquals(model.getRowKey(), i);
- model.setRowKey(null);
- assertNull(model.getRowKey());
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getRowData()}.
- */
- public final void testWalk() {
- DataVisitor visitor = new DataVisitor(){
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- Object key = model.getRowKey();
- model.setRowKey(rowKey);
- assertEquals(model.getRowData(), list.get(((Integer)rowKey).intValue()));
- model.setRowKey(key);
- }
- };
- try {
- SequenceRange range = new SequenceRange(0, -1);
- model.walk(null, visitor, range, null);
- range = new SequenceRange(0, 5);
- model.walk(null, visitor, range, null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test method for {@link org.richfaces.model.ListSequenceDataModel#ListSequenceDataModel(java.util.List)},
- * {@link org.richfaces.model.ListSequenceDataModel#setWrappedData(java.lang.Object)}
- * and {@link org.richfaces.model.ListSequenceDataModel#getWrappedData()} .
- */
- public final void testListSequenceDataModel() {
- assertNull(nullModel.getWrappedData());
- ListSequenceDataModel dataModel = new ListSequenceDataModel(list);
- assertSame(dataModel.getWrappedData(), model.getWrappedData());
-
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,170 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * @author shura
- *
- */
-public class MockDataModel extends ExtendedDataModel {
-
- public static final int ROWS = 10;
-
- private int rowIndex = 0;
-
- private int minRow = 0;
-
- private int maxRow = ROWS;
-
- private Object wrappedData;
- /**
- * @return the maxRow
- */
- public int getMaxRow() {
- return maxRow;
- }
-
- /**
- * @param maxRow the maxRow to set
- */
- public void setMaxRow(int maxRow) {
- this.maxRow = maxRow;
- }
-
- /**
- * @return the minRow
- */
- public int getMinRow() {
- return minRow;
- }
-
- /**
- * @param minRow the minRow to set
- */
- public void setMinRow(int minRow) {
- this.minRow = minRow;
- }
-
-
- public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
- int first=0;
- int count=ROWS;
- if (range instanceof MockRange) {
- MockRange mockRange = (MockRange) range;
- count = mockRange.getCount();
- } else if (range instanceof SequenceRange) {
- SequenceRange seqRange = (SequenceRange) range;
- first = seqRange.getFirstRow();
- int rows = seqRange.getRows();
- if(rows>0){
- count = rows+first;
- }
- }
- for(int row = first; row < count && row < ROWS;row++){
- visitor.process(context, new Integer(row), argument);
- }
-
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- // TODO Auto-generated method stub
- return rowIndex<0?null:new Integer(rowIndex);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- if(null == key){
- rowIndex = -1;
- } else {
- rowIndex = ((Integer) key).intValue();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- // TODO Auto-generated method stub
- return getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- // TODO Auto-generated method stub
- return isRowAvailable()?String.valueOf(rowIndex):null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- // TODO Auto-generated method stub
- return wrappedData;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- // TODO Auto-generated method stub
- return rowIndex>=getMinRow() && rowIndex<getMaxRow();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- this.rowIndex = rowIndex;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- wrappedData = data;
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import org.ajax4jsf.model.Range;
-
-/**
- * @author shura
- *
- */
-public class MockRange implements Range {
-
- private int count;
-
- public MockRange(int count) {
- this.count = count;
- }
-
- public int getCount(){
- return count;
- }
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,107 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.el.ValueExpression;
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModelListener;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.SequenceRange;
-import org.easymock.classextension.EasyMock;
-import org.richfaces.test.AbstractFacesTest;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ModifiableModelTest extends AbstractFacesTest {
-
- private ModifiableModel model;
- private ExtendedDataModel originalModel;
- private String var;
- private List<FilterField> filterFields;
- private List<SortField2> sortFields;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- var = "var";
- originalModel = new MockDataModel();
- filterFields = new LinkedList<FilterField>();
- sortFields = new LinkedList<SortField2>();
- model = new ModifiableModel(originalModel, var);
- model.modify(filterFields, sortFields);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- public void tearDown() throws Exception {
- model = null;
- var = null;
- filterFields = null;
- sortFields = null;
- originalModel = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.richfaces.model.ModifiableModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}.
- */
- public final void testWalk() {
- SequenceRange range = new SequenceRange(0, -1);
- DataVisitor visitor = new DataVisitor(){
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
- Object key = model.getRowKey();
- model.setRowKey(rowKey);
- Object key2 = originalModel.getRowKey();
- originalModel.setRowKey(rowKey);
- assertEquals(model.getRowData(), originalModel.getRowData());
- model.setRowKey(key);
- originalModel.setRowKey(key2);
- }
- };
- try {
- model.walk(null, visitor, range, null);
- ValueExpression expression =
- facesContext.getApplication().getExpressionFactory().createValueExpression(Boolean.TRUE, Boolean.class);
- filterFields.add(new FilterField(expression));
- sortFields.add(new SortField2(expression, Ordering.ASCENDING));
- model.walk(null, visitor, range, null);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- }
-
- /**
- * Test method for {@link org.richfaces.model.ModifiableModel#addDataModelListener(javax.faces.model.DataModelListener)}.
- */
- public final void testAddDataModelListenerDataModelListener() {
- DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
- model.addDataModelListener(mockedListener);
- assertEquals(model.getDataModelListeners()[0], mockedListener);
- }
-
- /**
- * Test method for {@link org.richfaces.model.ModifiableModel#removeDataModelListener(javax.faces.model.DataModelListener)}.
- */
- public final void testRemoveDataModelListenerDataModelListener() {
- DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
- model.addDataModelListener(mockedListener);
- assertSame(model.getDataModelListeners()[0], mockedListener);
- model.removeDataModelListener(mockedListener);
- assertEquals(model.getDataModelListeners().length, 0);
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,99 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import javax.el.ValueExpression;
-
-import junit.framework.TestCase;
-
-import org.easymock.classextension.EasyMock;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class SortField2Test extends TestCase {
-
- private SortField2 field;
- private ValueExpression expression;
- private Ordering ordering;
- /**
- * @param name
- */
- public SortField2Test(String name) {
- super(name);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- expression = EasyMock.createNiceMock(ValueExpression.class);
- ordering = Ordering.ASCENDING;
- field = new SortField2(expression, ordering);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- field = null;
- ordering = null;
- expression = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#hashCode()}.
- */
- public final void testHashCode() {
- Field sortField = new SortField2(expression, ordering);
- assertEquals(sortField.hashCode(), field.hashCode());
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#equals(java.lang.Object)}.
- */
- public final void testEqualsObject() {
- SortField2 sortField = new SortField2(null);
- assertFalse(sortField.equals(field));
- sortField.setExpression(expression);
- sortField.setOrdering(ordering);
- assertTrue(sortField.equals(field));
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression)}.
- */
- public final void testSortField2ValueExpression() {
- SortField2 sortField2 = new SortField2(expression);
- field.setOrdering(null);
- assertEquals(sortField2, field);
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression, org.richfaces.model.Ordering)}.
- */
- public final void testSortField2ValueExpressionOrdering() {
- SortField2 sortField2 = new SortField2(expression, ordering);
- assertEquals(sortField2, field);
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#getOrdering()}.
- */
- public final void testGetOrdering() {
- assertEquals(field.getOrdering(), ordering);
- }
-
- /**
- * Test method for {@link org.richfaces.model.SortField2#setOrdering(org.richfaces.model.Ordering)}.
- */
- public final void testSetOrdering() {
- field.setOrdering(null);
- assertNull(field.getOrdering());
- }
-
-}
Deleted: root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-07-23 17:00:43 UTC (rev 14987)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-07-23 17:02:30 UTC (rev 14988)
@@ -1,450 +0,0 @@
-/**
- *
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.richfaces.model.entity.Directory;
-import org.richfaces.model.entity.File;
-import org.richfaces.model.entity.Named;
-import org.richfaces.model.entity.Project;
-import org.richfaces.test.AbstractFacesTest;
-
-
-/**
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 30.07.2007
- *
- */
-public class StackingTreeDataModelTest extends AbstractFacesTest {
-
- private StackingTreeModel stackingTreeModel;
- private StackingTreeModel projectsModel;
- private StackingTreeModel directoriesModel;
- private StackingTreeModel filesModel;
-
- private Object projectRequestObject;
- private Object directoryRequestObject;
- private Object fileRequestObject;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
- */
- public void setUp() throws Exception {
- super.setUp();
- setupFacesRequest();
- this.stackingTreeModel = new StackingTreeModel();
- projectsModel = new StackingTreeModel("project", "project", new StackingTreeModelDataProvider() {
-
- private Map<String, Project> data = null;
-
- public Object getData() {
- if (data == null) {
- data = new LinkedHashMap<String, Project>();
- Project projectA = new Project("projectA", 10);
-
- Directory adir1 = new Directory("ADir1", 50);
-
- adir1.addFile(new File("AFile1", 60));
- adir1.addFile(new File("AFile2", 61));
-
- Directory adir2 = new Directory("ADir2", 101);
-
- projectA.addDirectory(adir1);
- projectA.addDirectory(adir2);
-
- data.put(projectA.getName(), projectA);
-
- Project projectB = new Project("projectB", 501);
-
- Directory bdir1 = new Directory("BDir1", 600);
- Directory bdir2 = new Directory("BDir2", 700);
- Directory bdir3 = new Directory("BDir3", 801);
-
- projectB.addDirectory(bdir1);
- projectB.addDirectory(bdir2);
- projectB.addDirectory(bdir3);
-
- data.put(projectB.getName(), projectB);
- }
- return data;
- }
- });
- final ValueBinding dirVB = application.createValueBinding("#{project.directories}");
- directoriesModel = new StackingTreeModel("directory", "directory", new StackingTreeModelDataProvider() {
- public Object getData() {
- return dirVB.getValue(facesContext);
- }
- });
- final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
- filesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
- public Object getData() {
- return fileVB.getValue(facesContext);
- }
- });
- directoriesModel.addStackingModel(filesModel);
- projectsModel.addStackingModel(directoriesModel);
- this.stackingTreeModel.addStackingModel(projectsModel);
-
- projectRequestObject = new Object();
- directoryRequestObject = new Object();
- fileRequestObject = new Object();
-
- Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
- requestMap.put("project", projectRequestObject);
- requestMap.put("directory", directoryRequestObject);
- requestMap.put("file", fileRequestObject);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
- */
- public void tearDown() throws Exception {
- super.tearDown();
- this.stackingTreeModel = null;
- this.projectsModel = null;
- this.directoriesModel = null;
- this.filesModel = null;
-
- this.projectRequestObject = null;
- this.directoryRequestObject = null;
- this.fileRequestObject = null;
- }
-
- public void testWalk() throws Exception {
- StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
- this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- assertEquals(9, visitor1.getCounter());
- this.stackingTreeModel.setRowKey(null);
- assertFalse(this.stackingTreeModel.isRowAvailable());
-
- Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
- assertSame(this.projectRequestObject, requestMap.get("project"));
- assertSame(this.directoryRequestObject, requestMap.get("directory"));
- assertSame(this.fileRequestObject, requestMap.get("file"));
- }
-
- public void testBadKey() throws Exception {
- StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
- this.stackingTreeModel.walk(facesContext, visitor1, null, null);
- this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModelKey("project", "projectA")));
- assertTrue(this.stackingTreeModel.isRowAvailable());
- assertNotNull(this.stackingTreeModel.getRowData());
-
- assertNull(this.stackingTreeModel.getTreeNode());
- assertFalse(this.stackingTreeModel.isLeaf());
-
- this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModelKey("project", "projectAAAAA")));
- assertFalse(this.stackingTreeModel.isRowAvailable());
- try {
- Object rowData = this.stackingTreeModel.getRowData();
- assertNull(rowData);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
-
- try {
- boolean leaf = this.stackingTreeModel.isLeaf();
- assertTrue(leaf);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
-
- try {
- TreeNode node = this.stackingTreeModel.getTreeNode();
- assertNull(node);
- //FIXME: Maksim - bad keys happen for a reason
- //fail();
- } catch (Exception e) {
-
- }
- }
-
- public void testActiveData() throws Exception {
- final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
- StackingTreeModel localFilesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
- public Object getData() {
- return fileVB.getValue(facesContext);
- }
-
- }) {
- protected boolean isActiveData() {
- Map requestMap = facesContext.getExternalContext().getRequestMap();
- Object object = requestMap.get("file");
- assertNotNull(object);
- File file = (File) object;
- if (file.getTag() == 61) {
- return false;
- }
-
- return super.isActiveData();
- }
- };
- directoriesModel.removeStackingModel(filesModel);
- directoriesModel.addStackingModel(localFilesModel);
-
- stackingTreeModel.walk(facesContext, new StackingTreeDataModelTestVisitor3(), null, null);
- }
-
- public void testKey() throws Exception {
- StackingTreeModelKey key = new StackingTreeModelKey("aaa", new Integer(10));
- StackingTreeModelKey key2 = new StackingTreeModelKey("aaa", new Integer(11));
- StackingTreeModelKey key3 = new StackingTreeModelKey("aaa", new Integer(10));
- StackingTreeModelKey key4 = new StackingTreeModelKey("bbb", new Integer(10));
-
- assertFalse(key.equals(new StackingTreeModelKey("aaa", new Integer(0)) {} ));
-
- assertTrue(key.equals(key3));
- assertTrue(key3.equals(key));
- assertTrue(key2.equals(key2));
- assertTrue(key4.equals(key4));
-
- assertTrue(key.hashCode() == key3.hashCode());
- assertTrue(key3.hashCode() == key.hashCode());
- assertTrue(key2.hashCode() == key2.hashCode());
- assertTrue(key4.hashCode() == key4.hashCode());
-
- assertFalse(key.equals(key2));
- assertFalse(key3.equals(key2));
- assertFalse(key2.equals(key));
- assertFalse(key2.equals(key3));
-
- assertFalse(key.hashCode() == key2.hashCode());
- assertFalse(key3.hashCode() == key2.hashCode());
- assertFalse(key2.hashCode() == key.hashCode());
- assertFalse(key2.hashCode() == key3.hashCode());
-
- assertFalse(key4.equals(key));
- assertFalse(key4.equals(key2));
- assertFalse(key4.equals(key3));
-
- assertFalse(key4.hashCode() == key.hashCode());
- assertFalse(key4.hashCode() == key2.hashCode());
- assertFalse(key4.hashCode() == key3.hashCode());
-
- assertFalse(key.equals(key4));
- assertFalse(key2.equals(key4));
- assertFalse(key3.equals(key4));
-
- assertFalse(new StackingTreeModelKey("aaa", new Integer(10)).equals(null));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(null));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(null));
- assertFalse(new StackingTreeModelKey(null, null).equals(null));
-
- assertFalse(key.hashCode() == key4.hashCode());
- assertFalse(key2.hashCode() == key4.hashCode());
- assertFalse(key3.hashCode() == key4.hashCode());
-
- assertFalse(key.hashCode() == 0);
- assertFalse(key2.hashCode() == 0);
- assertFalse(key3.hashCode() == 0);
- assertFalse(key4.hashCode() == 0);
-
- assertTrue(new StackingTreeModelKey(null, new Integer(11)).equals(new StackingTreeModelKey(null, new Integer(11))));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey(null, new Integer(11))));
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey("aaa", new Integer(10))));
-
- assertTrue(new StackingTreeModelKey(null, new Integer(11)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
- assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
-
- assertTrue(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", null)));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("bbb", null)));
- assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", new Integer(10))));
-
- assertTrue(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", null).hashCode());
- assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("bbb", null).hashCode());
- assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
- }
-
- class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
-
- private boolean last;
- private int tag = 0;
- private int counter = 0;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
- argument, false);
-
- assertEquals(5, visitor2.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor20 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor20, new TreeRange() {
-
- public boolean processChildren(TreeRowKey rowKey) {
- return false;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return false;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
- argument, false);
-
- assertEquals(0, visitor20.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor21 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor21, new TreeRange() {
-
- public boolean processChildren(TreeRowKey rowKey) {
- return false;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return true;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
- argument, false);
-
- assertEquals(1, visitor21.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor22 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new StackingTreeModelKey("project", "projectB")),
- argument, false);
-
- assertEquals(4, visitor22.getCounter());
-
- StackingTreeDataModelTestVisitor2 visitor23 = new StackingTreeDataModelTestVisitor2();
-
- stackingTreeModel.walk(context, visitor23, new TreeRange() {
-
- private boolean rootProcessed = false;
-
- public boolean processChildren(TreeRowKey rowKey) {
- boolean result = rootProcessed;
- rootProcessed = true;
- return !result;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return true;
- }
-
- }, new ListRowKey(new StackingTreeModelKey("project", "projectB")),
- argument, false);
-
- assertEquals(4, visitor23.getCounter());
-
- stackingTreeModel.setRowKey(rowKey);
-
- assertSame(rowKey, stackingTreeModel.getRowKey());
-
- assertNull(stackingTreeModel.getTreeNode());
- Object rowData = stackingTreeModel.getRowData();
- assertNotNull(rowData);
- assertTrue(rowData instanceof Named);
-
- Named named = (Named) rowData;
-
- int currentTag = named.getTag();
- assertTrue(currentTag > tag);
- this.tag = currentTag;
-
- if (this.tag % 10 == 1) {
- assertTrue(last);
- } else {
- assertFalse(last);
- }
-
- if (named instanceof Directory) {
- if ("ADir1".equals(named.getName())) {
- assertFalse(stackingTreeModel.isLeaf());
- } else {
- assertTrue(stackingTreeModel.isLeaf());
- }
- } else if (named instanceof Project) {
- assertFalse(stackingTreeModel.isLeaf());
- } else if (named instanceof File) {
- assertTrue(stackingTreeModel.isLeaf());
- } else {
- fail();
- }
-
- counter++;
- }
-
- public void resetLastElement() {
- this.last = false;
- }
-
- public void setLastElement() {
- this.last = true;
- }
-
- public int getCounter() {
- return counter;
- }
- }
-
- class StackingTreeDataModelTestVisitor2 implements DataVisitor {
- private int counter = 0;
- private int tag = 0;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- stackingTreeModel.setRowKey(rowKey);
- Object rowData = stackingTreeModel.getRowData();
- assertNotNull(rowData);
- Named named = (Named) rowData;
-
- int currentTag = named.getTag();
- assertTrue(currentTag > tag);
- tag = currentTag;
- counter++;
- }
-
- public int getCounter() {
- return counter;
- }
- }
-
- class StackingTreeDataModelTestVisitor3 implements DataVisitor, LastElementAware {
-
- private boolean last;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- stackingTreeModel.setRowKey(rowKey);
- Named named = (Named) stackingTreeModel.getRowData();
- int tag = named.getTag();
-
- if (tag == 60) {
- assertTrue(last);
- }
- assertFalse(tag == 61);
- }
-
- public void resetLastElement() {
- this.last = false;
- }
-
- public void setLastElement() {
- this.last = true;
- }
- }
-}
-
15 years, 5 months
JBoss Rich Faces SVN: r14987 - in root/framework/trunk/api/src: main/java/org/richfaces/event and 3 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 13:00:43 -0400 (Thu, 23 Jul 2009)
New Revision: 14987
Removed:
root/framework/trunk/api/src/main/java/org/richfaces/component/Column.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Draggable.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Dropzone.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Filterable.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Row.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Selectable.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable.java
root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable2.java
root/framework/trunk/api/src/main/java/org/richfaces/component/xml/
root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerSource.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DnDEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DragEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DragListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DropEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DropListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/DropSource.java
root/framework/trunk/api/src/main/java/org/richfaces/event/FileUploadListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedListener.java
root/framework/trunk/api/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java
root/framework/trunk/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java
root/framework/trunk/api/src/main/java/org/richfaces/event/UploadEvent.java
root/framework/trunk/api/src/main/java/org/richfaces/event/extdt/
root/framework/trunk/api/src/main/java/org/richfaces/event/scroll/
root/framework/trunk/api/src/main/java/org/richfaces/event/sort/
root/framework/trunk/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/DataProvider.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ExtendedFilterField.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
root/framework/trunk/api/src/main/java/org/richfaces/model/LastElementAware.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ListRowKey.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
root/framework/trunk/api/src/main/java/org/richfaces/model/MapDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
root/framework/trunk/api/src/main/java/org/richfaces/model/Ordering.java
root/framework/trunk/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SelectionMode.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SequenceDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SortField2.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SortOrder.java
root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java
root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNode.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNodeImpl.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRange.java
root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRowKey.java
root/framework/trunk/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java
root/framework/trunk/api/src/main/java/org/richfaces/model/filter/
root/framework/trunk/api/src/main/java/org/richfaces/model/package-info.java
root/framework/trunk/api/src/main/java/org/richfaces/model/selection/
root/framework/trunk/api/src/test/java/org/ajax4jsf/framework/util/javascript/
root/framework/trunk/api/src/test/java/org/richfaces/model/
Log:
Moving component APIs into ui-sandbox
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Column.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Column.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Column.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,82 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.el.MethodExpression;
-
-import org.richfaces.model.Ordering;
-
-/**
- * Marker interface for all components used as column in UIDataTable
- * @author shura
- *
- */
-public interface Column {
-
-
- /**
- * Out this column on new row
- * @parameter
- * @return the acceptClass
- */
- public abstract boolean isBreakBefore();
-
- /**
- * @param newBreakBefore the value to set
- */
- public abstract void setBreakBefore(boolean newBreakBefore);
-
-
- /**
- * The column allows data sorting
- * @return
- */
- public abstract boolean isSortable();
-
- public abstract void setSortable(boolean sortable);
-
- /**
- * expression used for column sorting.
- * literal value is treated as property of data object
- * EL-expression is evaluated on every data row
- * @param sortExpression
- */
- public abstract void setSortExpression(String sortExpression);
- public abstract String getSortExpression();
-
- /**
- * SortOrder is an enumeration of the possible sort orderings.
- *
- * @param sortOrder
- */
- public abstract void setSortOrder(Ordering sortOrder);
- public abstract Ordering getSortOrder();
-
- public abstract void setFilterMethod(MethodExpression methodExpression);
- public abstract MethodExpression getFilterMethod();
-
- public abstract void setFilterValue(String filterValue);
- public abstract String getFilterValue();
-
- public abstract boolean isSelfSorted();
- public abstract void setSelfSorted(boolean selfSorted);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Draggable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Draggable.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Draggable.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,135 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.faces.context.FacesContext;
-import javax.faces.el.MethodBinding;
-
-import org.richfaces.event.DragListener;
-
-
-/**
- * Interface for all draggable components. Describe bean properties, implemented by component.
- * @author shura
- *
- */
-public interface Draggable {
-
- /**
- * Getter for value parameter, used as key for draggable component.
- * @return
- */
- public Object getDragValue();
-
- public void setDragValue(Object value);
-
- /**
- * Getter for id of component ( instance of {@link UIDragIndicator} ) used for create drag cursor.
- * @return
- */
- public String getDragIndicator();
-
- /**
- * @param dragIndicator - id of cursor component
- */
- public void setDragIndicator(String dragIndicator);
-
- /**
- * Draggable implementation may wish to resolve drag indicator id to clientId itself
- * @param facesContext {@link FacesContext} instance
- * @return resolved indicator client id or null
- * @since 3.1
- */
- public String getResolvedDragIndicator(FacesContext facesContext);
-
- /**
- * Getter for type of this draggable ( file, mail etc ).
- * @return
- */
- public String getDragType();
-
- /**
- * @param dragType
- */
- public void setDragType(String dragType);
-
- /**
- * Getter for JavaScript event handler, called before start drag operation.
- * If this handler return false, drag operation is cancelled.
- * @return javaScript code of event handler.
- */
- public String getOndragstart();
-
- /**
- * @param dragType
- */
- public void setOndragstart(String ondrag);
-
- /**
- * Getter for JavaScript event handler; Called when drag operation end.
- * @return javaScript code of event handler.
- */
- public String getOndragend();
- public void setOndragend(String ondrag);
-
- /**
- * Getter for JavaScript event handler; Called when dragged element over the dropzone.
- * @return javaScript code of event handler.
- */
- public String getOndropover();
- public void setOndropover(String ondropover);
-
- /**
- * Getter for JavaScript event handler; Called when dragged element out the dropzone.
- * @return javaScript code of event handler.
- */
- public String getOndropout();
- public void setOndropout(String ondropout);
-
- /**
- * Append drag listener to component listeners collection
- * @param listener
- */
- public void addDragListener(DragListener listener);
-
- /**
- * Get array of all Drop Listeners
- * @return
- */
- public DragListener[] getDragListeners();
-
- /**
- * Remove drop listener from component listeners array.
- * @param listener
- */
- public void removeDragListener(DragListener listener);
-
- public void setDragListener(MethodBinding binding);
- public MethodBinding getDragListener();
-
- public String getGrabCursors();
- public void setGrabCursors(String grabCursors);
-
- public String getGrabbingCursors();
- public void setGrabbingCursors(String grabbingCursors);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Dropzone.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Dropzone.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Dropzone.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,122 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import org.richfaces.event.DropSource;
-
-/**
- * Base interface for all components, accesible as drop zone.
- * @author shura
- *
- */
-public interface Dropzone extends DropSource {
-
- /**
- * Getter for dropType's , accepted by this zone.
- * @return
- */
- public Object getAcceptedTypes();
-
- public void setAcceptedTypes(Object types);
-
- /**
- * Getter for mapping between drop types and indicator states.
- * @return
- */
- public Object getTypeMapping();
-
- public void setTypeMapping(Object types);
-
-
- /**
- * Getter for mapping between drop types and acceptable cursors
- * @return
- */
- public Object getCursorTypeMapping();
- public void setCursorTypeMapping(Object types);
-
- /**
- * Getter for JavaScript event handler, called then drag curcor enter in component area.
- * If this handler return false, or "declined", drop operation on this component not allowed.
- * If handler return true or "allowed" , or any other supported indicator states, drop operation
- * is allowed and corresponding indicator state will be displayed.
- * @return javaScript code of event handler.
- */
- public String getOndragenter();
-
- /**
- * @param dragType
- */
- public void setOndragenter(String ondrag);
-
- /**
- * Getter for JavaScript event handler, called before drag cursor leave component area.
- * @return javaScript code of event handler.
- */
- public String getOndragexit();
-
- /**
- * @param dragType
- */
- public void setOndragexit(String ondrag);
-
- public Object getDropValue();
-
- public void setDropValue(Object o);
-
- /**
- * Javascript code called before drop event.
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndrop();
-
- /**
- * @param newOndrop the value to set
- */
- public abstract void setOndrop(String newOndrop);
-
- /**
- * Javascript handler for event fired on drop even the drop for given type is not available
- * @parameter
- * @return the acceptClass
- */
- public abstract String getOndropend();
-
- /**
- * @param newname the value to set
- */
- public abstract void setOndropend(String ondropend);
-
- /**
- * Getter for the list of comma separated cursors that indicates when acceptable draggable over dropzone
- */
- public String getAcceptCursors();
- public void setAcceptCursors(String acceptCursors);
-
- /**
- * Getter for the list of comma separated cursors that indicates when rejectable draggable over dropzone
- */
- public String getRejectCursors();
- public void setRejectCursors(String rejectCursors);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Filterable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Filterable.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Filterable.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.component;
-
-import java.util.List;
-
-import org.richfaces.model.FilterField;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface Filterable {
-
- public List<FilterField> getFilterFields();
-
- public void setFilterFields(List<FilterField> filterFields);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Row.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Row.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Row.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,41 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import java.util.Iterator;
-
-import javax.faces.component.UIComponent;
-
-/**
- * Marker interface for table columns, rendered as entire row.
- * @author shura
- *
- */
-public interface Row extends Column {
-
- /**
- * Get iterator for all columns contained in this row.
- * @return
- */
- public Iterator<UIComponent> columns();
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Selectable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Selectable.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Selectable.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,32 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.component;
-
-import org.richfaces.model.selection.Selection;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Selectable {
- public Selection getSelection();
- public void setSelection (Selection selection);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,23 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v $
- * $Revision: 1.1 $
- */
-
-package org.richfaces.component;
-
-import org.richfaces.model.SortOrder;
-
-
-/**
- * @author Maksim Kaszynski
- * Base interface for sort capable components
- */
-public interface Sortable {
- public SortOrder getSortOrder();
- public void setSortOrder(SortOrder sortOrder);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable2.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable2.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable2.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.component;
-
-import java.util.List;
-
-import org.richfaces.model.SortField2;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface Sortable2 {
-
- public List<SortField2> getSortFields();
-
- public void setSortFields(List<SortField2> sortFields);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-
-/**
- *
- * <br /><br />
- *
- * Created 27.08.2007
- * @author mikalaj
- * @since 3.1
- */
-
-public class AjaxExpandedEvent extends NodeExpandedEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 5191468583939051390L;
-
- public AjaxExpandedEvent(UIComponent component) {
- super(component);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-
-import org.richfaces.model.TreeRowKey;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class AjaxSelectedEvent extends NodeSelectedEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 1156974665865521208L;
-
- public AjaxSelectedEvent(UIComponent component, TreeRowKey oldSelection) {
- super(component, oldSelection);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.event;
-
-import java.util.Date;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-public class CurrentDateChangeEvent extends FacesEvent {
-
-
- private static final long serialVersionUID = -8169207286087810907L;
- private Date currentDate = null;
- private String currentDateString = null;
-
- @Deprecated
- public CurrentDateChangeEvent(UIComponent component, Date curentDate) {
- super(component);
- this.currentDate = curentDate;
-
- }
-
- public CurrentDateChangeEvent(UIComponent component, String curentDateString) {
- super(component);
- this.currentDateString = curentDateString;
- }
-
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
- public void processListener(FacesListener listener) {
- // TODO Auto-generated method stub
- throw new UnsupportedOperationException();
- }
-
- public Date getCurrentDate() {
- return currentDate;
- }
-
- public void setCurrentDate(Date currentDate) {
- this.currentDate = currentDate;
- }
-
- public String getCurrentDateString() {
- return currentDateString;
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Alexej Kushunin - akushunin(a)exadel.com
- * created 28.08.2007
- *
- * Base calendar events interface
- */
-public interface CurrentDateChangeListener extends FacesListener {
-
- public void processCurrentDateChange(CurrentDateChangeEvent event);
-
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,76 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesListener;
-import javax.faces.event.PhaseId;
-
-import org.ajax4jsf.event.AjaxEvent;
-
-/**
- * @author Wesley Hales
- */
-public class DataFilterSliderEvent extends AjaxEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private Integer oldSliderVal;
- private Integer newSliderVal;
-
- /**
- * Creates a new SliderEvent.
- *
- * @param component the source of the event
- * @param thisOldSliderVal the previously showing item identifier
- * @param thisNewSliderVal the currently showing item identifier
- */
- public DataFilterSliderEvent(UIComponent component, Integer thisOldSliderVal, Integer thisNewSliderVal) {
- super(component);
- setPhaseId(PhaseId.INVOKE_APPLICATION);
- oldSliderVal = thisOldSliderVal;
- newSliderVal = thisNewSliderVal;
- }
-
- public Integer getOldSliderVal() {
- return oldSliderVal;
- }
-
- public Integer getNewSliderVal() {
- return newSliderVal;
- }
-
- public boolean isAppropriateListener(FacesListener listener){
- return (listener instanceof DataFilterSliderListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener){
- ((DataFilterSliderListener) listener).processSlider(this);
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderListener extends FacesListener {
-
- public void processSlider(org.richfaces.event.DataFilterSliderEvent event);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-/**
- * @author Wesley Hales
- */
-public interface DataFilterSliderSource {
-
- /**
- * Adds a DataFilterSliderListener to this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be added
- */
- public void addSliderListener(org.richfaces.event.DataFilterSliderListener listener);
-
- /**
- * Removes a DataFilterSliderListener from this DataFilterSliderSource.
- *
- * @param listener the Slider listener to be removed
- */
- public void removeSliderListener(DataFilterSliderListener listener);
-
- /**
- * Returns all SliderListeners for this DataFilterSliderSource.
- *
- * @return the Slider listener array
- */
- public DataFilterSliderListener[] getSliderListeners();
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,90 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Wesley Hales
- */
-public class DataScrollerEvent extends ActionEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 2657353903701932561L;
- private String oldScrolVal;
- private String newScrolVal;
- private int page;
-
- /**
- * Creates a new ScrollerEvent.
- *
- * @param component the source of the event
- * @param thisOldScrolVal the previously showing item identifier
- * @param thisNewScrolVal the currently showing item identifier
- */
- public DataScrollerEvent(UIComponent component, String thisOldScrolVal, String thisNewScrolVal, int page) {
- super(component);
- oldScrolVal = thisOldScrolVal;
- newScrolVal = thisNewScrolVal;
- this.page = page;
- }
-
- public String getOldScrolVal() {
- return oldScrolVal;
- }
-
- public String getNewScrolVal() {
- return newScrolVal;
- }
-
- /**
- * @since 3.2
- * @return new page or <code>-1</code> if not applicable
- */
- public int getPage() {
- return page;
- }
-
- public boolean isAppropriateListener(FacesListener listener){
- return super.isAppropriateListener(listener) || (listener instanceof DataScrollerListener);
- }
-
- /**
- * Delivers this event to the SliderListener.
- *
- * @param listener the slider listener
- */
- public void processListener(FacesListener listener){
- if (listener instanceof DataScrollerListener) {
- DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
- dataScrollerListener.processScroller(this);
- }
-
- if (super.isAppropriateListener(listener)) {
- super.processListener(listener);
- }
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-
-public interface DataScrollerListener extends FacesListener {
-
- public void processScroller(org.richfaces.event.DataScrollerEvent event);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerSource.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerSource.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerSource.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,47 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-public interface DataScrollerSource {
-
- /**
- * Adds a DataScrollerListener to this DataScrollerSource.
- *
- * @param listener the Scroler listener to be added
- */
- public void addScrollerListener(org.richfaces.event.DataScrollerListener listener);
-
- /**
- * Removes a DataFilterSliderListener from this DataScrollerSourceSource.
- *
- * @param listener the Scroler listener to be removed
- */
- public void removeScrollerListener(DataScrollerListener listener);
-
- /**
- * Returns all ScrollerListeners for this DataScrollerSource.
- *
- * @return the Scroler listener array
- */
- public DataScrollerListener[] getScrollerListeners();
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DnDEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DnDEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DnDEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,46 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-
-/**
- *
- * <br /><br />
- *
- * Created 12.11.2007
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public abstract class DnDEvent extends FacesEvent {
- /**
- *
- */
- private static final long serialVersionUID = -2455016405742082110L;
-
- public DnDEvent(UIComponent component) {
- super(component);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DragEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DragEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DragEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,102 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.component.Draggable;
-import org.richfaces.component.Dropzone;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.12.2006
- *
- */
-public class DragEvent extends DnDEvent {
-
- private Dropzone dropTarget;
- private Object acceptedTypes;
- private Object dropValue;
- /**
- *
- */
- private static final long serialVersionUID = 6179268394391836905L;
-
- public DragEvent(UIComponent uiComponent) {
- super(uiComponent);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener faceslistener) {
- return faceslistener instanceof DragListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener faceslistener) {
- ((DragListener) faceslistener).processDrag(this);
- }
-
- public Object getDragValue() {
- return ((Draggable) this.getSource()).getDragValue();
- }
-
- public Dropzone getDropTarget() {
- return dropTarget;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
-/* public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
- append("component", getComponent()).append("source", getSource()).append("phaseId", getPhaseId()).
- append("dragValue", getDragValue()).
- append("dropTarget", getDropTarget()).
- append("dropValue", getDropValue()).
- toString();
- }
-*/
- public void setDropTarget(Dropzone dropTarget) {
- this.dropTarget = dropTarget;
- }
-
- public Object getAcceptedTypes() {
- return acceptedTypes;
- }
-
- public void setAcceptedTypes(Object acceptedTypes) {
- this.acceptedTypes = acceptedTypes;
- }
-
- public Object getDropValue() {
- return dropValue;
- }
-
- public void setDropValue(Object dropValue) {
- this.dropValue = dropValue;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DragListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DragListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DragListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.12.2006
- *
- */
-public interface DragListener extends FacesListener {
- public void processDrag(DragEvent event);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DropEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DropEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DropEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,107 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.component.Draggable;
-import org.richfaces.component.Dropzone;
-
-/**
- * @author shura
- *
- */
-public class DropEvent extends DnDEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = 1660545054556302746L;
-
- private Draggable draggableSource;
- private String dragType;
- private Object dragValue;
-
- public DropEvent(UIComponent component) {
- super(component);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof DropListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((DropListener) listener).processDrop(this);
- }
-
- /**
- * @return the dropValue
- */
- public Object getDropValue() {
- return ((Dropzone) this.getSource()).getDropValue();
- }
-
- public Draggable getDraggableSource() {
- return draggableSource;
- }
-
- /**
- * @see java.util.EventObject#toString()
- */
-/* public String toString() {
- return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
- append("component", getComponent()).
- append("source", getSource()).
- append("phaseId", getPhaseId()).
- append("dropValue", getDropValue()).
- append("draggableSource", getDraggableSource()).
- append("dragValue", getDragValue()).
- toString();
- }
-*/
- public void setDraggableSource(Draggable draggableSource) {
- this.draggableSource = draggableSource;
- }
-
- public String getDragType() {
- return dragType;
- }
-
- public void setDragType(String dragType) {
- this.dragType = dragType;
- }
-
- public Object getDragValue() {
- return dragValue;
- }
-
- public void setDragValue(Object dragValue) {
- this.dragValue = dragValue;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DropListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DropListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DropListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,39 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * Listener for process Drop events
- * @author shura
- *
- */
-public interface DropListener extends FacesListener {
-
- /**
- * Process event on Drop for this component.
- * @param event
- */
- public void processDrop(DropEvent event);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/DropSource.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/DropSource.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/DropSource.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,54 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.el.MethodBinding;
-
-/**
- * Interface for component applicable to process drag/drop events.
- * @author shura
- *
- */
-public interface DropSource {
-
- /**
- * Append drop listener to component listeners collection
- * @param listener
- */
- public void addDropListener(DropListener listener);
-
- /**
- * Get array of all Drop Listeners
- * @return
- */
- public DropListener[] getDropListeners();
-
- /**
- * Remove drop listener from component listeners array.
- * @param listener
- */
- public void removeDropListener(DropListener listener);
-
- public void setDropListener(MethodBinding binding);
- public MethodBinding getDropListener();
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/FileUploadListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/FileUploadListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/FileUploadListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,29 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-public interface FileUploadListener extends FacesListener {
-
- public void processUpload(UploadEvent event);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-
-//TODO by nick - denis - add addToggleListener method to component
-public interface ISimpleToggleListener extends FacesListener {
-
- public void processToggle(SimpleToggleEvent event);
-
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,58 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public class NodeExpandedEvent extends FacesEvent {
-
- public NodeExpandedEvent(UIComponent component) {
- super(component);
- }
-
- /**
- *
- */
- private static final long serialVersionUID = 2620359072575831666L;
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof NodeExpandedListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- ((NodeExpandedListener) listener).processExpansion(this);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public interface NodeExpandedListener extends FacesListener {
- public void processExpansion(NodeExpandedEvent nodeExpandedEvent) throws AbortProcessingException;
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,69 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.model.TreeRowKey;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public class NodeSelectedEvent extends FacesEvent {
-
- private TreeRowKey oldSelection;
-
- public NodeSelectedEvent(UIComponent component, TreeRowKey oldSelection) {
- super(component);
-
- this.oldSelection = oldSelection;
- }
-
- /**
- *
- */
- private static final long serialVersionUID = -1292268859927735863L;
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
-
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof NodeSelectedListener;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
-
- public void processListener(FacesListener listener) {
- ((NodeSelectedListener) listener).processSelection(this);
- }
-
- public TreeRowKey getOldSelection() {
- return oldSelection;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedListener.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedListener.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedListener.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,34 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.FacesListener;
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 27.11.2006
- *
- */
-public interface NodeSelectedListener extends FacesListener {
- public void processSelection(NodeSelectedEvent nodeSelectedEvent) throws AbortProcessingException;
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,70 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public abstract class ScrollableGridViewEvent extends AttributedEvent {
-
-
- /**
- *
- */
- private static final long serialVersionUID = -7417387605074667926L;
- /**
- * number of rows to update
- */
- protected int rows;
- /**
- * start position of update
- */
- protected int first;
-
-
- public ScrollableGridViewEvent(UIComponent component, int rows, int first) {
- super(component);
- this.rows = rows;
- this.first = first;
- }
-
- public int getFirst() {
- return first;
- }
-
- public int getRows() {
- return rows;
- }
-
- public void setFirst(int first) {
- this.first = first;
- }
-
- public void setRows(int rows) {
- this.rows = rows;
- }
-
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,81 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * Created on 11.07.2006
- */
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.ActionEvent;
-import javax.faces.event.FacesListener;
-
-/**
- * @author igels
- */
-public class SimpleToggleEvent extends ActionEvent {
-
- private static final long serialVersionUID = 5582624805941635421L;
- private boolean _opened;
-
- /**
- * @param source
- * @param opened
- */
- public SimpleToggleEvent(UIComponent source, boolean opened) {
- super(source);
- this._opened = opened;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
- */
- public boolean isAppropriateListener(FacesListener listener) {
- return listener instanceof ISimpleToggleListener || super.isAppropriateListener(listener);
- }
-
- /* (non-Javadoc)
- * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
- */
- public void processListener(FacesListener listener) {
- if (listener instanceof ISimpleToggleListener) {
- ((ISimpleToggleListener) listener).processToggle(this);
- } else {
- super.processListener(listener);
- }
-
- }
-
- /**
- * @return Returns the _state.
- */
- public boolean isIsOpen() {
- return _opened;
- }
-
- /**
- *
- * @param opened The state to set
- */
- public void setIsOpen(boolean opened) {
- this._opened = opened;
- }
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,55 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.component.UIComponent;
-
-import org.ajax4jsf.event.AjaxEvent;
-
-/**
- * Event send by tree component in case of AJAX of action (node expansion/collapsion or selection).
- * Contains data to distinguish between different action types in order to support different re-rendering
- * behaviors for particular actions.
- *
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public class TreeAjaxEvent extends AjaxEvent {
-
- /**
- *
- */
- private static final long serialVersionUID = -2410803626536767706L;
-
- private TreeAjaxEventType eventType;
-
- public TreeAjaxEvent(UIComponent component, TreeAjaxEventType eventType) {
- super(component);
-
- this.eventType = eventType;
- }
-
- public TreeAjaxEventType getEventType() {
- return eventType;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-/**
- * Types enumeration for possible tree actions to be used in {@link TreeAjaxEvent}
- *
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public enum TreeAjaxEventType {
- EXPANSION, SELECTION
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,51 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.event;
-
-import javax.faces.el.MethodBinding;
-
-
-/**
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 29.11.2006
- *
- * Base tree events interface
- */
-public interface TreeListenerEventsProducer {
- public abstract void setChangeExpandListener(MethodBinding binding);
- public abstract MethodBinding getChangeExpandListener();
-
- public abstract void setNodeSelectListener(MethodBinding binding);
- public abstract MethodBinding getNodeSelectListener();
-
- public abstract void setDropListener(MethodBinding binding);
- public abstract MethodBinding getDropListener();
-
- public abstract void setDragListener(MethodBinding binding);
- public abstract MethodBinding getDragListener();
-
- public void addNodeSelectListener(NodeSelectedListener listener);
- public void addChangeExpandListener(NodeExpandedListener listener);
-
- //TODO - rename this
- public boolean hasAjaxSubmitSelection();
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/event/UploadEvent.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/event/UploadEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/event/UploadEvent.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,78 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.event;
-
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.event.FacesEvent;
-import javax.faces.event.FacesListener;
-
-import org.richfaces.model.UploadItem;
-
-public class UploadEvent extends FacesEvent{
-
- private static final long serialVersionUID = -7645197191376210068L;
- private List<UploadItem> uploadItems = null;
-
- public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
- super(component);
- this.uploadItems = uploadItems;
- }
-
-
- public boolean isAppropriateListener(FacesListener listener) {
- return false;
- }
-
-
- public void processListener(FacesListener listener) {
-
- }
-
- /**Returns UploadItem instance.
- * Returns first element of list of UploadItems in case of multiple upload.
- * @return the uploadItem
- */
- public UploadItem getUploadItem() {
- if (uploadItems != null && uploadItems.size() > 0) {
- return uploadItems.get(0);
- }
- return null;
- }
-
- /**
- * Return list of UploadItems
- * @return the uploadItem
- * @since 3.2.2
- */
- public List<UploadItem> getUploadItems() {
- return uploadItems;
- }
-
- /** Return true if multiple files were uploaded with form
- * @return boolean
- * @since 3.2.2
- */
- public boolean isMultiUpload() {
- return (uploadItems != null && uploadItems.size() > 1);
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,176 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-
-import javax.faces.component.NamingContainer;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-
-/**
- * Base class for all tree data models
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 07.12.2006
- */
-public abstract class AbstractTreeDataModel extends ExtendedDataModel {
- public final static char SEPARATOR = NamingContainer.SEPARATOR_CHAR;
-
- public final int getRowCount() {
- return -1;
- }
-
- public final int getRowIndex() {
- return -1;
- }
-
- public final void setRowIndex(int rowIndex) {
- if(rowIndex!=-1) {
- throw new IllegalArgumentException("In AbstractTreeDataModel rowIndex must be -1.");
- }
- }
-
- public final void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object argument) throws IOException {
- walk(context, dataVisitor, range, null, argument, false);
- }
-
- /**
- * walk sub-model having row key argument as its root
- * @param context faces context
- * @param dataVisitor {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor}
- * @param range {@link TreeRange} to constraint the walk
- * @param rowKey row key to treat as root of sub-model
- * @param argument implementation specific argument
- * @param last boolean flag indicating whether we started our walk from last element
- * @throws IOException
- *
- * @see {@link ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}
- */
- public abstract void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last) throws IOException;
-
- /**
- * returns whether this node is leaf
- * @return
- */
- public abstract boolean isLeaf();
-
- /**
- * Walk backing sub-model having row key argument as its root. If there is no backing model
- * configured, calling this method is equivalent to calling {@link #walk(FacesContext, DataVisitor, Range, Object, Object, boolean)}
- * @param facesContext faces context
- * @param visitor {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor} instance
- * @param range {@link Range} to constraint the walk
- * @param key row key to treat as root of sub-model
- * @param argument implementation-specific argument
- * @throws IOException
- *
- * @see {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
- */
- public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException;
-
- /**
- * Processes concrete tree node. Knows about {@link LastElementAware} interface and handles it
- * properly. Checks if argument is instance of {@link SubTreeChildrenAppender} and if it is so
- * does appending current element
- * @param context
- * @param dataVisitor
- * @param argument
- * @param treeRowKey
- * @param last
- * @throws IOException
- */
- protected void processElement(FacesContext context, DataVisitor dataVisitor, Object argument, TreeRowKey treeRowKey, boolean last) throws IOException {
- if (last && dataVisitor instanceof LastElementAware) {
- try {
- ((LastElementAware) dataVisitor).setLastElement();
- dataVisitor.process(context, treeRowKey, argument);
- } finally {
- ((LastElementAware) dataVisitor).resetLastElement();
- }
- } else {
- dataVisitor.process(context, treeRowKey, argument);
- }
- }
-
- /**
- * Get current tree node.
- * Note: valid only for classical TreeNode based tree data model implementation
- *
- * @return current tree node
- */
- public abstract TreeNode getTreeNode();
-
- /**
- * Get model node recursively with all sub nodes.
- * Note: valid only for classical TreeNode based tree data model implementation
- *
- * @return current tree node
- */
- public TreeNode getModelTreeNode() {
- return getTreeNode();
- }
-
- public abstract Object convertToKey(FacesContext context, String keyString,
- UIComponent component, Converter converter);
-
- /**
- * Get row key for certain tree node object
- *
- * @param node to get key for
- * @return node row key
- */
- public Object getTreeNodeRowKey(Object node) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Get node local id in it's parent childs collection
- *
- * @param childNode node to get identifier for
- * @return node local identifier
- */
- public Object getChildNodeId(Object childNode) {
- throw new UnsupportedOperationException();
- }
-
- public Object getParentRowKey(Object key) {
- return ((TreeRowKey) key).getParentKey();
- }
-
- public void addNode(Object parentRowKey, Object newNode, Object id) {
- throw new UnsupportedOperationException();
- }
-
- public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
- throw new UnsupportedOperationException();
- }
-
- public void removeNode(Object rowKey) {
- throw new UnsupportedOperationException();
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-/**
- * This class provides the solution for "false leaves" issue of cacheable trees
- *
- * @author Nick Belaevski
- * @since 3.3.1
- */
-
-public class CacheableSwingTreeNodeImpl extends SwingTreeNodeImpl {
-
- private boolean notLeaf = false;
-
- @Override
- public boolean isLeaf() {
- return !this.notLeaf && super.isLeaf();
- }
-
- public void setNotLeaf(boolean notLeaf) {
- this.notLeaf = notLeaf;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,226 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Extension of {@link TreeDataModel} supporting lazy data fetching for caching
- *
- * created 08.01.2007
- *
- * @author Nick - mailto:nbelaevski@exadel.com
- */
-public abstract class CacheableTreeDataModel<T> extends TreeDataModel<T> {
-
- private Log log = LogFactory.getLog(CacheableTreeDataModel.class);
-
- private final class CacheFillingVisitor implements DataVisitor {
-
- private CacheFillingVisitor() {
- }
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
- TreeRowKey treeRowKey = (TreeRowKey) rowKey;
- treeDataModel.setRowKey(treeRowKey);
- setDefaultNodeData(locateTreeNode(treeRowKey, true), treeDataModel.getRowData());
- }
-
- }
-
- private final static DataVisitor NULL_VISITOR = new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey, Object argument) throws IOException {
- //do nothing
- }
-
- };
-
- private TreeDataModel<T> treeDataModel;
-
- public boolean isLeaf() {
- TreeRowKey rowKey = (TreeRowKey) getRowKey();
- T treeNode = locateTreeNode(rowKey);
- if (treeNode != null && !nodeAdaptor.isLeaf(treeNode)) {
- return false;
- }
-
- treeNode = treeDataModel.locateTreeNode(rowKey);
- if (treeNode != null) {
- return nodeAdaptor.isLeaf(treeNode);
- }
-
- return false;
- }
-
- public CacheableTreeDataModel(TreeDataModel<T> model, MissingNodeHandler<T> missingNodeHandler) {
- super(model.getClazz(), model.getNodeAdaptor(), missingNodeHandler);
- setWrappedData(missingNodeHandler.handleMissingNode(null, null));
- setTreeDataModel(model);
- }
-
- public void walkModel(FacesContext context, DataVisitor visitor,
- Range range, Object key, Object argument, boolean last)
- throws IOException {
- treeDataModel.walkModel(context, visitor, range, key,
- argument, last);
- }
-
- public void setTreeDataModel(TreeDataModel<T> treeDataModel) {
- this.treeDataModel = treeDataModel;
- }
-
- public TreeDataModel<T> getTreeDataModel() {
- return treeDataModel;
- }
-
- public void walk(FacesContext context, final DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last)
- throws IOException {
-
- T cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
- T treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
-
- if (treeNode != null) {
- if (cachedTreeNode == null || (nodeAdaptor.isLeaf(cachedTreeNode) && !nodeAdaptor.isLeaf(treeNode))) {
- //fill cache
- treeDataModel.walk(context, new CacheFillingVisitor(), range,
- rowKey, argument, last);
- }
-
- super.walk(context, dataVisitor, range, rowKey, argument, last);
- }
- }
-
- public void setTransient(boolean newTransientValue) {
- if (!newTransientValue) {
- throw new IllegalArgumentException(
- "ReplaceableTreeDataModel shouldn't be transient!");
- }
- }
-
- protected abstract void setDefaultNodeData(T node, Object data);
-
- @Override
- public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
- Object convertedKey = treeDataModel.convertToKey(context, keyString, component, converter);
-
- if (convertedKey != null) {
- final TreeRowKey treeRowKey = (TreeRowKey) convertedKey;
- try {
- walk(context, NULL_VISITOR, new TreeRange() {
-
- public boolean processChildren(TreeRowKey rowKey) {
- return rowKey == null || rowKey.isSubKey(treeRowKey);
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return this.processChildren(rowKey) || rowKey.equals(treeRowKey);
- }
-
- }, null);
- } catch (IOException e) {
- context.getExternalContext().log(e.getLocalizedMessage(), e);
-
- return null;
- }
- }
-
- return convertedKey;
- }
-
- @Override
- public T locateTreeNode(TreeRowKey rowKey) {
- return locateTreeNode(rowKey, true);
- }
-
- @Override
- public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
- super.addNode(parentRowKey, newNode, id);
-
- if (treeDataModel != null) {
- Object savedRowKey = treeDataModel.getRowKey();
-
- try {
- treeDataModel.setRowKey(getRowKey());
- treeDataModel.addNode(parentRowKey, newNode, id);
- } finally {
- try {
- treeDataModel.setRowKey(savedRowKey);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- }
- }
-
- @Override
- public void removeNode(Object rowKey) {
- super.removeNode(rowKey);
-
- if (treeDataModel != null) {
- Object savedRowKey = treeDataModel.getRowKey();
-
- try {
- treeDataModel.setRowKey(getRowKey());
- treeDataModel.removeNode(rowKey);
- } finally {
- try {
- treeDataModel.setRowKey(savedRowKey);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- }
- }
-
- @Override
- public TreeNode getModelTreeNode() {
- TreeNode node = null;
- if (treeDataModel != null) {
- Object savedRowKey = treeDataModel.getRowKey();
-
- try {
- treeDataModel.setRowKey(getRowKey());
- node = treeDataModel.getModelTreeNode();
- } finally {
- try {
- treeDataModel.setRowKey(savedRowKey);
- } catch (Exception e) {
- log.error(e.getMessage(), e);
- }
- }
- }
-
- return node;
- }
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,48 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-/**
- * This class provides the solution for "false leaves" issue of cacheable trees
- *
- * @author Nick Belaevski
- * @since 3.3.1
- */
-
-public class CacheableTreeNodeImpl<T> extends TreeNodeImpl<T> {
-
- /**
- *
- */
- private static final long serialVersionUID = -5918388225735277820L;
-
- private boolean notLeaf = false;
-
- @Override
- public boolean isLeaf() {
- return !this.notLeaf && super.isLeaf();
- }
-
- public void setNotLeaf(boolean notLeaf) {
- this.notLeaf = notLeaf;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.util.Date;
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-public interface CalendarDataModel {
-
- /**
- * @return array of CalendarDataModelItems for selected dates.
- * This method will be called every time when components will need next block of CalendarDataItems.
- * That may happens when calendar rendered, or when user navigate to next(previous) month or in any other case when calendar renders.
- * This method will be called in Ajax mode when Calendar renders new page.
- * */
- public CalendarDataModelItem[] getData(Date[] dateArray);
-
- /**
- * @return tool tip when it's used in "single" mode
- * This method used when tool tips are displayed in "single" mode
- * */
- public Object getToolTip(Date date);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,68 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-
-
-/**
- * @author Alexej Kushunin
- * created 19.06.2007
- *
- */
-
-public interface CalendarDataModelItem {
-
- /**
- *@return true if date is �selectable� on calendar, default implementation return true
- **/
- public boolean isEnabled();
-
- /**
- * @return String that will be appended to style class for that date span.
- * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day relevant holyday�.
- * Default implementation return empty string.
- * */
- public String getStyleClass();
-
- /**
- * @return any additional payload that must be JSON-serialazable object.
- * May be used in custom date representation on calendar (inside custom facet).*/
- public Object getData();
-
- /**
- * @return true if given date has an associated with it tooltip data.
- * Default implementation return false.*/
- public boolean hasToolTip();
-
- /**
- *@return tool tip data that will be used in �batch� tooltip loading mode.
- **/
- public Object getToolTip();
-
- /**
- *@return day of the month on which data must be shown.
- **/
- public int getDay();
-
-}
-
-
-
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,73 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-/**
- * {@link CacheableTreeDataModel} implementation for classic {@link TreeNode} instances
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public class ClassicCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
-
- private static final MissingNodeHandler<TreeNode> missingNodeHandler = new MissingNodeHandler<TreeNode>() {
-
- public TreeNode handleMissingNode(TreeNode parentNode,
- Object pathSegment) {
-
- TreeNodeImpl childNode = new CacheableTreeNodeImpl();
-
- if (parentNode != null) {
- parentNode.addChild(pathSegment, childNode);
- }
-
- return childNode;
- }
-
- };
-
- public ClassicCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
- super(model, missingNodeHandler);
- }
-
- @Override
- protected void setDefaultNodeData(TreeNode node, Object data) {
- if (node != null) {
- CacheableTreeNodeImpl cacheableTreeNode = (CacheableTreeNodeImpl) node;
- cacheableTreeNode.setData(data);
- cacheableTreeNode.setNotLeaf(!isLeaf());
- }
- }
-
- @Override
- public TreeNode getTreeNode() {
- if (isRowAvailable()) {
- return locateTreeNode((TreeRowKey) getRowKey());
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,94 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-/**
- * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public class ClassicTreeDataModel extends TreeDataModel<TreeNode> {
-
- public ClassicTreeDataModel() {
- super(TreeNode.class, TreeDataModelNodeAdaptor.classicTreeNodeAdaptor, null);
- }
-
- @Override
- public TreeNode getTreeNode() {
- if (isRowAvailable()) {
- return locateTreeNode((TreeRowKey) getRowKey());
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- @Override
- public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
- //TODO optimize search for empty string
- String[] strings = ListRowKey.fromString(keyString);
- List<Object> list = new ArrayList<Object>(strings.length);
- TreeNode node = (TreeNode) getWrappedData();
-
- for (int i = 0; i < strings.length; i++) {
- String key = strings[i];
- TreeNode<?> child = node.getChild(key);
- if (child != null) {
- node = child;
- list.add(key);
- } else {
- boolean found = false;
- Iterator<Entry<Object, TreeNode>> children = node.getChildren();
-
- while (children.hasNext() && !found) {
- Entry<Object, TreeNode> entry = children.next();
- Object keyObject = entry.getKey();
- if (key.equals(keyObject.toString())) {
- node = entry.getValue();
- list.add(keyObject);
- found = true;
- }
- }
-
- if (!found) {
- return null;
- }
- }
- }
-
- return new ListRowKey<Object>(list);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-/**
- * Marks complex tree row keys containing several segments
- *
- * @author Nick Belaevski
- * @since 3.3.1
- */
-
-public interface ComplexTreeRowKey {
-
- public int getKeySegmentsCount();
-
- public Object getKeySegment(int i);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,51 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-/**
- * Models that can handle keys conversion should implement this interface
- *
- * For internal use only
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public interface ConvertableKeyModel {
-
- /**
- * Converts {@link String} to model object key
- *
- * @param context
- * @param key
- * @param component
- * @param converter
- * @return
- */
- public Object getKeyAsObject(FacesContext context, String key,
- UIComponent component, Converter converter);
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/DataProvider.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/DataProvider.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/DataProvider.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,68 +0,0 @@
-/**
-* License Agreement.
-*
-* JBoss RichFaces - Ajax4jsf Component Library
-*
-* Copyright (C) 2008 CompuGROUP Holding AG
-*
-* This library is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License version 2.1 as published by the Free Software Foundation.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-package org.richfaces.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * DataProvider is an interface that defines methods for manage loading data.<br>
- * Usage:
- * <pre>
- * DataProvider<SomeDataType> dataProvider = new DataProvider<SomeDataType>();
- * </pre>
- * @author pawelgo
- *
- */
-public interface DataProvider<T> extends Serializable {
-
- /**
- * Get number of all rows.
- * @return number of rows.
- */
- public int getRowCount();
-
- /**
- * Loads elements from given range.
- * Starting from startRow, and up to but excluding endRow.
- * @param firstRow first row to load
- * @param endRow end row to load
- * @return element list
- */
- public List<T> getItemsByRange(int firstRow, int endRow);
-
- /**
- * Load single element by given key.
- * @param key element key to be loaded.
- * @return element or null, if not found
- */
- public T getItemByKey(Object key);
-
- /**
- * Get element key.
- * If key is not instance of Integer or org.richfaces.model.ScrollableTableDataModel.SimpleRowKey,
- * it is necessary to implement javax.faces.convert.Converter for key type.
- * @param item element, which key to be get
- * @return element key
- */
- public Object getKey(T item);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ExtendedFilterField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ExtendedFilterField.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ExtendedFilterField.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import javax.el.Expression;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class ExtendedFilterField extends FilterField{
-
- /**
- *
- */
- private static final long serialVersionUID = 5443560922389498666L;
-
- private String filterValue;
-
- public ExtendedFilterField(Expression expression, String filterValue) {
- super(expression);
- this.filterValue = filterValue;
- }
-
- public ExtendedFilterField(Expression expression) {
- this(expression, "");
- }
-
- public String getFilterValue() {
- return filterValue;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,75 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-import javax.el.Expression;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public abstract class Field implements Serializable{
-
- private static final long serialVersionUID = 7576046308828980778L;
-
- private Expression expression;
-
- public Field(Expression expression) {
- this.expression = expression;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Field other = (Field) obj;
- if (expression == null) {
- if (other.expression != null)
- return false;
- } else {
- return expression.equals(other.expression);
- }
- return true;
- }
-
- public Expression getExpression() {
- return expression;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((expression == null) ? 0 : expression.hashCode());
- return result;
- }
-
- public void setExpression(Expression expression) {
- this.expression = expression;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import javax.el.Expression;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public class FilterField extends Field{
-
- private static final long serialVersionUID = -5453359866996963829L;
-
- public FilterField(Expression expression) {
- super(expression);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/LastElementAware.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/LastElementAware.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/LastElementAware.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,43 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-/**
- * {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor} instances can implement this interface in order to
- * be notified of last element occurence at the current tree level. {@link #setLastElement()}
- * method is invoked before visiting last element and {@link #resetLastElement()} is called after
- * visiting last element.
- *
- * @author Konstantin Mishin
- */
-public interface LastElementAware {
-
- /**
- * The method is invoked to notify that last element occured
- */
- public void setLastElement();
- /**
- * The method is invoked to notify that we're done with last element
- */
- public void resetLastElement();
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ListRowKey.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,265 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.NamingContainer;
-
-/**
- * Default {@link TreeRowKey} implementation based on {@link ArrayList}
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 17.11.2006
- */
-public class ListRowKey<T> extends TreeRowKey<T> {
-
- private ArrayList<T> path;
-
- /**
- *
- */
- private static final long serialVersionUID = 7718335783201397177L;
-
- public String toString() {
- return getPath();
- }
-
- /**
- * Default constructor
- */
- public ListRowKey() {
- super();
- this.path = new ArrayList<T>();
- }
-
- /**
- * Copy constructor
- * @param parentRowKey row key to clone
- */
-
- @SuppressWarnings("unchecked")
- public ListRowKey(ListRowKey<T> parentRowKey) {
- super();
- if (parentRowKey != null) {
- this.path = (ArrayList<T>) parentRowKey.path.clone();
- } else {
- this.path = new ArrayList<T>();
- }
- }
-
- /**
- * Appending constructor
- *
- * @param parentRowKey base row key
- * @param pathElement path segment to append to base row key
- */
- public ListRowKey(ListRowKey<T> parentRowKey, T pathElement) {
- this(parentRowKey);
- this.path.add(pathElement);
- }
-
- /**
- * Appending constructor
- * @param parentRowKey base row key
- * @param pathElement path segment to append to base row key
- */
- public ListRowKey(ListRowKey<T> parentRowKey, ListRowKey<T> childRowKey) {
- this(parentRowKey);
- this.path.addAll(childRowKey.path);
- }
-
- protected ListRowKey(ArrayList<T> list) {
- super();
-
- this.path = list;
- }
-
- /**
- * Path object constructor
- * @param path first path segment
- * @deprecated
- */
- public ListRowKey(T path) {
- super();
- this.path = new ArrayList<T>(1);
- this.path.add(path);
- }
-
- /**
- * List constructor
- * @param list List of strings to create corresponding row key from
- */
- public ListRowKey(List<T> list) {
- super();
-
- this.path = new ArrayList<T>(list);
- }
-
- public int depth() {
- return path.size();
- }
-
- public Iterator<T> iterator() {
- return path.iterator();
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final ListRowKey<?> other = (ListRowKey<?>) obj;
- if (path == null) {
- if (other.path != null)
- return false;
- } else if (!path.equals(other.path))
- return false;
- return true;
- }
-
- public Iterator<T> getSubPathIterator(int fromIndex) {
- return path.listIterator(fromIndex);
- }
-
- @Override
- public TreeRowKey<T> getSubKey(int fromIndex) {
- return new ListRowKey<T>(path.subList(fromIndex, path.size()));
- }
-
-
- @SuppressWarnings("unchecked")
- public boolean isSubKey(TreeRowKey<T> rowKey) {
- if (rowKey instanceof ListRowKey) {
- ListRowKey<T> listRowKey = (ListRowKey<T>) rowKey;
-
- return depth() == getCommonPathLength(listRowKey);
- } else {
- return super.isSubKey(rowKey);
- }
- }
-
- private void appendSegment(StringBuilder builder, String segment) {
- StringBuilder escapedSubPath = new StringBuilder();
- for (int i = 0; i < segment.length(); i++) {
- char ch = segment.charAt(i);
-
- //escape
- if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch) {
- escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
- }
-
- escapedSubPath.append(ch);
- }
-
- builder.append(escapedSubPath.toString());
- }
-
- public String getPath() {
- StringBuilder result = new StringBuilder();
- Iterator<T> iterator = path.iterator();
- boolean hasNext = iterator.hasNext();
-
- while (hasNext) {
- T segment = iterator.next();
-
- if (segment instanceof ComplexTreeRowKey) {
- ComplexTreeRowKey complexKey = (ComplexTreeRowKey) segment;
-
- int segmentsCount = complexKey.getKeySegmentsCount();
- for (int i = 0; i < segmentsCount; i++) {
- appendSegment(result, complexKey.getKeySegment(i).toString());
- if (i < segmentsCount - 1) {
- result.append(AbstractTreeDataModel.SEPARATOR);
- }
- }
-
- } else {
- appendSegment(result, segment.toString());
- }
-
- hasNext = iterator.hasNext();
-
- if (hasNext) {
- result.append(AbstractTreeDataModel.SEPARATOR);
- }
- }
-
- return result.toString();
- }
-
- public int getCommonPathLength(TreeRowKey<T> otherRowKey) {
- if (otherRowKey == null)
- return 0;
- Iterator<T> iterator = this.iterator();
- Iterator<T> otherIterator = otherRowKey.iterator();
- int length = 0;
- while (iterator.hasNext() && otherIterator.hasNext()
- && iterator.next().equals(otherIterator.next()))
- length++;
- return length;
- }
-
- public T get(int i) {
- return path.get(i);
- }
-
- private static final String SEPARATOR = "(?<!" + ListRowKey.SEPARATOR_ESCAPE_CHAR + ")\\"
- + NamingContainer.SEPARATOR_CHAR;
-
- public static String[] fromString(String keyString) {
- String[] split = keyString.split(SEPARATOR);
- for (int i = 0; i < split.length; i++) {
- //TODO exception if not escaped properly
- split[i] = split[i].replaceAll("_(:|_)", "$1");
- }
-
- return split;
- }
-
- public static void main(String[] args) {
- System.out.println(Arrays.toString(fromString("test_:abc:123:a__b")));
- }
-
- @Override
- public TreeRowKey<T> getParentKey() {
- int toIdx = path.size() - 1;
- TreeRowKey<T> result = null;
-
- if (toIdx >= 0) {
- result = new ListRowKey<T>(new ArrayList<T>(path.subList(0, toIdx)));
- }
-
- return result;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,168 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.DataModel;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.ajax4jsf.model.SequenceDataModel;
-
-/**
- * Dual map-based extended data model for model-translating components like list shuttle
- * @author Nick Belaevski
- *
- */
-public class ListShuttleDataModel extends ExtendedDataModel {
-
- private ListShuttleRowKey rowKey;
-
- private SequenceDataModel sourceModel;
- private SequenceDataModel targetModel;
-
- private Map<Object, Object> data;
-
- private Object wrappedData;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- this.rowKey = (ListShuttleRowKey) key;
- }
-
- public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
- final Object argument) throws IOException {
- if (data != null) {
- Iterator<Entry<Object, Object>> iterator = data.entrySet().iterator();
-
- while (iterator.hasNext()) {
- Entry<Object, Object> entry = iterator.next();
-
- visitor.process(context, entry.getKey(), argument);
- }
-
- } else {
- sourceModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
- visitor.process(context, key, argument);
- }
- }, range, argument);
-
- targetModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext context, Object rowKey,
- Object argument) throws IOException {
-
- ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
- visitor.process(context, key, argument);
- }
-
- }, range, argument);
- }
- }
-
- public int getRowCount() {
- if (data != null) {
- return data.size();
- } else {
- return sourceModel.getRowCount() + targetModel.getRowCount();
- }
- }
-
- public Object getRowData() {
- if (data != null) {
- return data.get(rowKey);
- } else {
- if (this.rowKey != null) {
- if (this.rowKey.isSource()) {
- return sourceModel.getRowData();
- } else {
- return targetModel.getRowData();
- }
- } else {
- return null;
- }
- }
- }
-
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getWrappedData() {
- return wrappedData;
- }
-
- public boolean isRowAvailable() {
- if (data != null) {
- return data.containsKey(rowKey);
- } else {
- if (rowKey != null) {
- if (rowKey.isSource()) {
- return sourceModel.isRowAvailable();
- } else {
- return targetModel.isRowAvailable();
- }
- } else {
- return false;
- }
- }
- }
-
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- public void setWrappedData(Object data) {
- this.rowKey = null;
- this.wrappedData = data;
-
- if (data instanceof Map) {
- this.data = (Map<Object, Object>) data;
- } else {
- DataModel[] models = (DataModel[]) data;
- this.sourceModel = new SequenceDataModel(models[0]);
- this.targetModel = new SequenceDataModel(models[1]);
- }
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,99 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * Special type of row key containing information on item origin and new placement
- *
- * @author Nick Belaevski
- *
- */
-public class ListShuttleRowKey implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = 3308741255288495879L;
-
- private boolean source;
-
- private boolean facadeSource;
-
- private Object rowKey;
-
- public boolean isSource() {
- return source;
- }
-
- public boolean isFacadeSource() {
- return facadeSource;
- }
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
- result = prime * result + (source ? 1231 : 1237);
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ListShuttleRowKey other = (ListShuttleRowKey) obj;
- if (rowKey == null) {
- if (other.rowKey != null)
- return false;
- } else if (!rowKey.equals(other.rowKey))
- return false;
- if (source != other.source)
- return false;
- return true;
- }
-
- public String toString() {
- return (source ? "" : "t") + rowKey.toString();
- }
-
- public ListShuttleRowKey(Object rowKey, boolean source) {
- super();
- this.rowKey = rowKey;
- this.source = source;
- this.facadeSource = source;
- }
-
- public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
- super();
- this.rowKey = rowKey;
- this.source = source;
- this.facadeSource = facadeSource;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,38 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.Locale;
-
-/**
- * Models that are based on locale-dependent operations should implement this interface
- *
- * @author Nick Belaevski
- * @since 3.3.0
- */
-
-public interface LocaleAware {
-
- public Locale getLocale();
-
- public void setLocale(Locale locale);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/MapDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/MapDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/MapDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,240 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski mailto:nbelaevski@exadel.com created 30.07.2007
- */
-public class MapDataModel extends ExtendedDataModel implements ConvertableKeyModel {
-
- private Map<Object, Object> map;
- private Object rowKey;
- private Object wrappedData;
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
-
- public void setRowKey(Object key) {
- this.rowKey = key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
- * org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range,
- * java.lang.Object)
- */
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
- if (map != null) {
- for (Iterator<Object> iterator = map.keySet().iterator(); iterator.hasNext();) {
- Object key = (Object) iterator.next();
-
- visitor.process(context, key, argument);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowCount()
- */
-
- public int getRowCount() {
- return map != null ? map.size() : 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowData()
- */
-
- public Object getRowData() {
- return map != null ? map.get(rowKey) : null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowIndex()
- */
-
- public int getRowIndex() {
- return 0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- return wrappedData;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return map != null && map.containsKey(rowKey);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- this.wrappedData = data;
- if (data instanceof NamedNodeMap) {
- this.map = new AbstractMap<Object, Object>() {
-
- private Set<Entry<Object, Object>> entrySet = new AbstractSet<Entry<Object, Object>>() {
-
- public Iterator<Entry<Object, Object>> iterator() {
- return new Iterator<Entry<Object, Object>>() {
- private int index = 0;
-
- public boolean hasNext() {
- return index < ((NamedNodeMap) getWrappedData()).getLength();
- }
-
- public Entry<Object, Object> next() {
- final Node node = ((NamedNodeMap) getWrappedData()).item(index++);
- if (node == null) {
- throw new NoSuchElementException();
- } else {
- return new Map.Entry<Object, Object>() {
-
- public Object getKey() {
- return node.getNodeName();
- }
-
- public Object getValue() {
- return node;
- }
-
- public Object setValue(Object arg0) {
- throw new UnsupportedOperationException();
- }
-
- };
- }
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public int size() {
- return ((NamedNodeMap) getWrappedData()).getLength();
- }
-
- };
-
- public boolean containsKey(Object key) {
- return ((NamedNodeMap) getWrappedData()).getNamedItem((String) key) != null;
- }
-
- public Object get(Object key) {
- return ((NamedNodeMap) getWrappedData()).getNamedItem((String) key);
- }
-
- public Set<Entry<Object, Object>> entrySet() {
- return entrySet;
- }
-
- };
- } else if (data != null) {
- this.map = (Map<Object, Object>) data;
- } else {
- this.map = null;
- }
- }
-
- public Object getKeyAsObject(FacesContext context, String key, UIComponent component, Converter converter) {
- if (this.map != null) {
- if (this.map.containsKey(key)) {
- return key;
- } else {
- Set<Entry<Object,Object>> set = this.map.entrySet();
- for (Entry<Object, Object> entry : set) {
- Object keyObject = entry.getKey();
- if (key.equals(keyObject.toString())) {
- return keyObject;
- }
- }
- }
- }
-
- return null;
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,32 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.util.List;
-
-/**
- * @author Konstantin Mishin
- *
- */
-public interface Modifiable{
-
- void modify(List<FilterField> filterFields, List<SortField2> sortFields);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/Ordering.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/Ordering.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/Ordering.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,31 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-/**
- *
- * @author Maksim Kaszynski
- *
- */
-public enum Ordering {
- ASCENDING,
- DESCENDING,
- UNSORTED
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/OrderingListDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/OrderingListDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,101 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Map.Entry;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-
-/**
- * Map-based extended data model for model-translating components like ordering list
- *
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 07.11.2007
- *
- */
-public class OrderingListDataModel extends ExtendedDataModel {
-
- private Map<Object, Object> data;
-
- private Object rowKey;
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public void setRowKey(Object rowKey) {
- this.rowKey = rowKey;
- }
-
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- Set<Entry<Object,Object>> entrySet = data.entrySet();
- Iterator<Entry<Object, Object>> iterator = entrySet.iterator();
-
- while (iterator.hasNext()) {
- Entry<Object, Object> entry = iterator.next();
-
- visitor.process(context, entry.getKey(), argument);
- }
- }
-
- public int getRowCount() {
- return data.size();
- }
-
- public Object getRowData() {
- return data.get(rowKey);
- }
-
- public int getRowIndex() {
- // TODO Auto-generated method stub
- return 0;
- }
-
- public Object getWrappedData() {
- return data;
- }
-
- public boolean isRowAvailable() {
- return data.containsKey(rowKey);
- }
-
- public void setRowIndex(int rowIndex) {
- // TODO Auto-generated method stub
-
- }
-
- public void setWrappedData(Object data) {
- this.rowKey = null;
- this.data = (Map<Object, Object>) data;
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,267 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Base class for data models
- * Subclasses must implement {@link #loadData(int, int, SortOrder)}
- * For certain features (like selection and sorting) to work correctly together,
- * both {@link #getId(Object)} and {@link #getObjectById(Object)}
- * methods need to be overriden
- *
- * @author Maksim Kaszynski
- *
- */
-public abstract class ScrollableTableDataModel<T> extends ExtendedDataModel {
-
- /**
- * Simple implementation - index-based row key
- * @author Maksim Kaszynski
- *
- */
- public static class SimpleRowKey extends Number implements Serializable{
-
- private static final long serialVersionUID = 1L;
-
- public static final String PREFIX = "srk";
- private int i;
-
- public SimpleRowKey(int i) {
- super();
- this.i = i;
- }
-
- public int intValue() {
- return i;
- }
-
- public String toString() {
- return PREFIX + String.valueOf(i);
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + i;
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final SimpleRowKey other = (SimpleRowKey) obj;
- if (i != other.i)
- return false;
- return true;
- }
- @Override
- public double doubleValue() {
- return i;
- }
- @Override
- public float floatValue() {
- return i;
- }
- @Override
- public long longValue() {
- return i;
- }
-
- }
-
-
- private static final Log log = LogFactory.getLog(ScrollableTableDataModel.class);
-
- private Object rowKey;
-
- private Map<Object, T> mapping;
-
- protected SortOrder lastSortOrder;
-
-
- /**
- * Load range of data items from the source.
- * Starting from startRow, and up to but excluding endRow
- * @param startRow
- * @param endRow
- * @param sortOrder
- * @return list of ordered data
- */
- public abstract List<T> loadData(int startRow, int endRow, SortOrder sortOrder);
-
-
- /**
- * Load data range, and iterate over it
- */
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- if (log.isTraceEnabled()) {
- log.trace("Starting walk");
- }
-
- ScrollableTableDataRange sequenceRange = (ScrollableTableDataRange) range;
-
- int startIndex = sequenceRange.getFirst();
- int last = sequenceRange.getLast();
-
- lastSortOrder = sequenceRange.getSortOrder();
-
- List<T> objects = loadData(startIndex, last, lastSortOrder);
-
- mapping = new HashMap<Object, T>();
-
- for (int i = 0; i < objects.size(); i++,startIndex++) {
- T data = objects.get(i);
- Object key = getId(data);
-
- if (key == null) {
- key = new SimpleRowKey(startIndex);
- }
-
- mapping.put(key, data);
-
- visitor.process(context, key, argument);
-
- }
-
- if (log.isTraceEnabled()) {
- log.trace("Ending walk");
- }
-
- }
-
-
- /**
- * This method is the reverse of {@link #getId(Object)}
- * If you override this method, you need to override {@link #getId(Object)} as well
- * @param id
- * @return
- */
- public T getObjectById(Object id) {
-
- if (id instanceof SimpleRowKey) {
- int i = ((SimpleRowKey) id).intValue();
-
- List<T> l = loadData(i, i + 1, lastSortOrder);
-
- return l.get(0);
-
- }
-
- return null;
- }
-
- /**
- * Implementations may override it to provide domain-specific searches
- * Id should be serializable
- * Default implementation returns <code>null</code> anyway
- * If you override this method, you need to override {@link #getObjectById(Object)} as well
- * @param o
- * @return
- */
- public Object getId(T o) {
- return null;
- }
-
-
- public Object getRowData() {
-
- if (mapping != null && mapping.containsKey(rowKey)) {
- return mapping.get(rowKey);
- } else {
- return loadAndMap(rowKey);
- }
-
- }
-
- /**
- * Row indexes navigation is no longer supported
- */
- public int getRowIndex() {
- return -1;
- }
-
- /**
- * Quite simple implementation - data will be cached, so the call will be cheap
- */
- public boolean isRowAvailable() {
- return getRowData() != null;
- }
-
- /**
- * Row indexes navigation is no longer supported
- */
- public void setRowIndex(int index) {
- //if(index != -1)
- //throw new UnsupportedOperationException("setRowIndex");
- //setRowKey(null);
- }
-
- public Object getRowKey() {
- return rowKey;
- }
-
- public void setRowKey(Object key) {
- rowKey = key;
- }
-
- private Object loadAndMap(Object id) {
-
- if (log.isTraceEnabled()) {
- log.trace("loadAndMap " + id);
- }
-
- T t = getObjectById(id);
- if (t != null) {
- if (mapping == null) {
- mapping = new HashMap<Object, T>();
- }
- mapping.put(id, t);
- }
- return t;
- }
- /*
- * FIXME: This method is most likely redundant
- public void setSortOrder(SortOrder sortOrder) {
- lastSortOrder = sortOrder;
- }
- */
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,121 +0,0 @@
-/*
- * Copyright
- * Copyright (c) Exadel,Inc. 2006
- * All rights reserved.
- *
- * History
- * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableTableDataRange.java,v $
- * $Revision: 1.7 $
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-import org.ajax4jsf.model.SequenceRange;
-
-/**
- * Iteration range for Scrollable Grid
- * @author Maksim Kaszynski
- * @modified by Anton Belevich
- */
-public class ScrollableTableDataRange extends SequenceRange implements Serializable{
-
- private static final long serialVersionUID = -6675002421400464892L;
-
- private SortOrder sortOrder;
-
- public ScrollableTableDataRange() {
- super();
- }
-
- public ScrollableTableDataRange(int first, int last, SortOrder sortOrder) {
- super(first, last > 0 ? last - first : -1);
- this.sortOrder = sortOrder;
- }
-
- /**
- * @return the bufferSize
- */
- public int getLast() {
- return getFirstRow() + getRows();
- }
- /**
- * @param bufferSize the bufferSize to set
- */
- public void setLast(int lastRow) {
- setRows(lastRow > 0 ? lastRow - getFirstRow() : -1);
- }
- /**
- * @return the first
- */
- public int getFirst() {
- return getFirstRow();
- }
- /**
- * @param first the first to set
- */
- public void setFirst(int first) {
- setFirstRow(first);
- }
-
- public SortOrder getSortOrder() {
- return sortOrder;
- }
-
- public void setSortOrder(SortOrder sortOrder) {
- this.sortOrder = sortOrder;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + getFirstRow();
- result = prime * result + getRows();
- result = prime * result
- + ((sortOrder == null) ? 0 : sortOrder.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ScrollableTableDataRange other = (ScrollableTableDataRange) obj;
- if (getFirstRow() != other.getFirstRow())
- return false;
- if (getRows() != other.getRows())
- return false;
- if (sortOrder == null) {
- if (other.sortOrder != null)
- return false;
- } else if (!sortOrder.equals(other.sortOrder))
- return false;
- return true;
- }
-
- private void writeObject(java.io.ObjectOutputStream out)
- throws IOException {
-
- out.defaultWriteObject();
-
- out.writeInt(getFirstRow());
- out.writeInt(getRows());
- }
-
- private void readObject(java.io.ObjectInputStream in)
- throws IOException, ClassNotFoundException {
-
- in.defaultReadObject();
-
- setFirstRow(in.readInt());
- setRows(in.readInt());
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SelectionMode.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SelectionMode.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SelectionMode.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,36 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-/**
- *
- * @author Konstantin Mishin
- *
- */
-public enum SelectionMode {
- none,
- single,
- multi;
-
- public boolean isSelectionEnabled() {
- return !equals(none);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SequenceDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SequenceDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SequenceDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,171 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.w3c.dom.NodeList;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 30.07.2007
- *
- */
-public class SequenceDataModel extends ExtendedDataModel implements ConvertableKeyModel {
-
- private Object wrappedData;
- private List list;
- private Integer key;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return key;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
- */
- public void setRowKey(Object key) {
- this.key = (Integer) key;
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
- */
- public void walk(FacesContext context, DataVisitor visitor, Range range,
- Object argument) throws IOException {
-
- if (list != null) {
- int i = 0;
- for (Iterator iterator = list.iterator(); iterator.hasNext();) {
- iterator.next();
-
- visitor.process(context, new Integer(i), argument);
-
- i++;
- }
- }
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowCount()
- */
- public int getRowCount() {
- return list != null ? list.size() : 0;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- return (list != null && key != null) ? list.get(key.intValue()) : null;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getRowIndex()
- */
- public int getRowIndex() {
- return 0;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#getWrappedData()
- */
- public Object getWrappedData() {
- return wrappedData;
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return list != null && key != null && list.size() > key.intValue();
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setRowIndex(int)
- */
- public void setRowIndex(int rowIndex) {
- }
-
- /* (non-Javadoc)
- * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
- */
- public void setWrappedData(Object data) {
- this.wrappedData = data;
- if (data instanceof List) {
- this.list = (List) data;
- } else if (data instanceof Collection) {
- this.list = new ArrayList((Collection) data);
- //copying all collection content into new collection here should prevent us
- //from possible issues caused by iteration tricks. e.g.: returning custom iterator
- //caching current element and comparing indices inside get()
- //
- //possible concurrent collection modifications and multithreading will break the magic
- } else if (data instanceof NodeList) {
- this.list = new AbstractList() {
-
- public Object get(int index) {
- return ((NodeList) getWrappedData()).item(index);
- }
-
- public int size() {
- return ((NodeList) getWrappedData()).getLength();
- }
-
- };
- } else if (data instanceof Object[]) {
- this.list = Arrays.asList((Object[]) data);
- } else if (data != null) {
- this.list = Collections.singletonList(data);
- } else {
- this.list = null;
- }
- }
-
- public Object getKeyAsObject(FacesContext context, String keyString, UIComponent component, Converter converter) {
- int key = Integer.parseInt(keyString);
- if (key >= 0 && this.list != null && key < this.list.size()) {
- return key;
- } else {
- return null;
- }
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,93 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * Sort field is the piece of {@link SortOrder}
- * @author Maksim Kaszynski
- *
- */
-public class SortField implements Serializable{
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private String name = null;
- private Boolean ascending = null;
-
-
-
- public SortField(String name, Boolean ascending) {
- super();
- this.name = name;
- this.ascending = ascending;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Boolean getAscending() {
- return ascending;
- }
-
- public void setAscending(Boolean ascending) {
- this.ascending = ascending;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((ascending == null) ? 0 : ascending.hashCode());
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- SortField other = (SortField) obj;
- if (ascending == null) {
- if (other.ascending != null)
- return false;
- } else if (!ascending.equals(other.ascending))
- return false;
- if (name == null) {
- if (other.name != null)
- return false;
- } else if (!name.equals(other.name))
- return false;
- return true;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SortField2.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SortField2.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SortField2.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,78 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import javax.el.Expression;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SortField2 extends Field{
-
- private static final long serialVersionUID = 4578290842517554179L;
-
- private Ordering ordering;
-
- public SortField2(Expression expression) {
- super(expression);
- }
-
- public SortField2(Expression expression, Ordering ordering) {
- super(expression);
- this.ordering = ordering;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result
- + ((ordering == null) ? 0 : ordering.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!super.equals(obj))
- return false;
- if (getClass() != obj.getClass())
- return false;
- SortField2 other = (SortField2) obj;
- if (ordering == null) {
- if (other.ordering != null)
- return false;
- } else if (!ordering.equals(other.ordering))
- return false;
- return true;
- }
-
- public Ordering getOrdering() {
- return ordering;
- }
-
- public void setOrdering(Ordering ordering) {
- this.ordering = ordering;
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SortOrder.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SortOrder.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SortOrder.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,91 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.Serializable;
-import java.util.Arrays;
-/**
- * Class representing grid sort order
- * Sort Order is the combination of {@link SortField}
- * Order of occurrence of sort fields must be maintained
- * to guarantee stable sorting
- * @author Maksim Kaszynski
- */
-public class SortOrder implements Serializable {
-
- private static final long serialVersionUID = 2423450561570551363L;
-
- private static int hashCode(Object[] array) {
- final int prime = 31;
- if (array == null)
- return 0;
- int result = 1;
- for (int index = 0; index < array.length; index++) {
- result = prime * result
- + (array[index] == null ? 0 : array[index].hashCode());
- }
- return result;
- }
-
- private SortField [] fields;
-
- public SortOrder() {
-
- }
-
- public SortOrder(SortField[] fields) {
- super();
- this.fields = fields;
- }
-
-
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final SortOrder other = (SortOrder) obj;
- if (!Arrays.equals(fields, other.fields))
- return false;
- return true;
- }
-
- public SortField[] getFields() {
- return fields;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + SortOrder.hashCode(fields);
- return result;
- }
-
- public void setFields(SortField[] fields) {
- this.fields = fields;
- }
-
-
-
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,615 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.ExtendedDataModel;
-import org.ajax4jsf.model.Range;
-import org.apache.commons.collections.Predicate;
-import org.apache.commons.collections.iterators.FilterIterator;
-import org.w3c.dom.NamedNodeMap;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski mailto:nbelaevski@exadel.com created 25.07.2007
- *
- */
-public class StackingTreeModel extends AbstractTreeDataModel {
-
- //ctor arguments
- private String id;
- private String var;
- private StackingTreeModelDataProvider dataProvider;
-
- //structural elements
- private StackingTreeModel parent;
- private Map<String, StackingTreeModel> models = new LinkedHashMap<String, StackingTreeModel>();
-
- private Object rowKey;
-
- private class StackEntry {
- private Object modelKey;
- private Object varObject;
- private StackingTreeModel model;
- private Object rowData;
-
- public StackEntry(Object varObject, Object modelKey, Object rowData, StackingTreeModel model) {
- super();
- this.varObject = varObject;
- this.modelKey = modelKey;
- this.rowData = rowData;
- this.model = model;
- }
- }
-
-// private StackingTreeModel stackingTreeModel;
- private LinkedList<StackEntry> stackEntries = new LinkedList<StackEntry>();
-
- public ExtendedDataModel getDataModel() {
- Object data = dataProvider.getData();
- ExtendedDataModel dataModel;
- if (data instanceof Map || data instanceof NamedNodeMap) {
- dataModel = new MapDataModel();
- } else {
- dataModel = new SequenceDataModel();
- }
-
- dataModel.setWrappedData(data);
- return dataModel;
- }
-
- protected StackingTreeModel getCurrentModel() {
- if (this.rowKey == null) {
- return this;
- }
-
- if (isRowAvailable()) {
- return ((StackEntry) stackEntries.getLast()).model;
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- public boolean isEmpty() {
- //TODO optimize that
- return getDataModel().getRowCount() == 0;
- }
-
- private void leaveModel(Iterator<StackEntry> iterator, StackEntry currentEntry, FacesContext context) {
- if (iterator == null) {
- return ;
- }
-
- LinkedList<StackEntry> stack = new LinkedList<StackEntry>();
-
- StackingTreeModel lastModel = null;
- if (currentEntry != null) {
- iterator.remove();
- stack.addFirst(currentEntry);
- lastModel = currentEntry.model;
- }
-
- while (iterator.hasNext()) {
- StackEntry entry = (StackEntry) iterator.next();
- if (entry.model != lastModel) {
- //always true for non-recursive models
- lastModel = entry.model;
- stack.addFirst(entry);
- }
-
- iterator.remove();
- }
-
- for (Iterator<StackEntry> iterator2 = stack.iterator(); iterator2.hasNext();) {
- StackEntry stackEntry = (StackEntry) iterator2.next();
- stackEntry.model.setupVariable(stackEntry.varObject, context);
- }
- }
-
- protected StackingTreeModel doSetupKey(Iterator<StackingTreeModelKey> keyIterator, Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
- if (modelKey != null) {
- if (!setupModel(modelKey, context)) {
- //no key is available
- leaveModel(getRoot().stackEntries.iterator(), null, context);
- return null;
- }
-
- //TODO what's here?
- }
-
- if (keyIterator != null && keyIterator.hasNext()) {
- StackingTreeModelKey key = keyIterator.next();
- StackingTreeModel stackingTreeModel = this.getInternalModelById(key.modelId);
- Iterator<StackEntry> nextEntriesIterator = null;
- Object nextModelKey = key.modelKey;
-
- if (entriesIterator != null && entriesIterator.hasNext()) {
- StackEntry entry = entriesIterator.next();
- if (!entry.model.equals(stackingTreeModel) || !entry.modelKey.equals(nextModelKey)) {
- leaveModel(entriesIterator, entry, context);
- } else {
- //continue iterating entries, they still lead us by key path
- nextEntriesIterator = entriesIterator;
- nextModelKey = null;
- }
- }
-
- //should not be called when nextEntriesIterator & nextModelKey are both valid
- return stackingTreeModel.doSetupKey(keyIterator, nextEntriesIterator, context, nextModelKey);
-
- } else {
- leaveModel(entriesIterator, null, context);
- return this;
- }
- }
-
- protected StackingTreeModel setupKey(Object key, FacesContext context) {
- if (key == this.rowKey) {
- if (stackEntries.isEmpty()) {
- return this;
- } else {
- return (stackEntries.getLast()).model;
- }
- } else {
- Iterator<StackingTreeModelKey> keyIterator = null;
- if (key != null) {
- keyIterator = ((ListRowKey<StackingTreeModelKey>) key).iterator();
- }
-
- StackingTreeModel model = doSetupKey(keyIterator, stackEntries.iterator(), context, null);
- this.rowKey = key;
-
- return model;
- }
- }
-
- public StackingTreeModel(String id, String var, StackingTreeModelDataProvider dataProvider) {
- super();
- this.id = id;
- this.var = var;
- this.dataProvider = dataProvider;
- }
-
- public StackingTreeModel() {
- this(null, null, null);
- }
-
- private Object setupVariable(Object variable, FacesContext context) {
- if (var != null) {
- Map<String, Object> map = context.getExternalContext().getRequestMap();
- return map.put(var, variable);
- }
-
- return null;
- }
-
- public boolean setupModel(Object key, FacesContext facesContext) {
- ExtendedDataModel dataModel = getDataModel();
- dataModel.setRowKey(key);
-
- if (dataModel.isRowAvailable()) {
- Object rowData = dataModel.getRowData();
- //System.out.println("StackingTreeModel.setupModel() " + rowData);
- Object varObject = setupVariable(rowData, facesContext);
-
- getRoot().stackEntries.add(new StackEntry(varObject, key, rowData, this));
-
- return true;
- }
-
- return false;
- }
-
- public void setParent(StackingTreeModel parent) {
- this.parent = parent;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.model.AbstractTreeDataModel#getTreeNode()
- */
- public TreeNode getTreeNode() {
- if (isRowAvailable()) {
- return null;
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.model.AbstractTreeDataModel#isLeaf()
- */
- public boolean isLeaf() {
- if (isRowAvailable()) {
- StackEntry lastEntry = (StackEntry) stackEntries.getLast();
- for (Iterator<StackingTreeModel> iterator = lastEntry.model.getInternalModelsIterator(); iterator.hasNext();) {
- StackingTreeModel stackingTreeModel = iterator.next();
-
- if (!stackingTreeModel.isEmpty()) {
- return false;
- }
- }
-
- return true;
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- protected StackingTreeModel getRoot() {
- if (parent != null) {
- return parent.getRoot();
- }
-
- return this;
- }
-
- protected void doWalk(FacesContext context, DataVisitor dataVisitor,
- Range range, ListRowKey argumentKey, Object argument,
- boolean last) throws IOException {
-
- TreeRange treeRange = (TreeRange) range;
-
- if (treeRange == null || treeRange.processNode(argumentKey)) {
- StackingTreeModel rootModel = getRoot();
-
- if (argumentKey != null) {
- processElement(context, dataVisitor, argument, argumentKey, last);
- }
-
- final ShiftingDataVisitor shiftingDataVisitor = new ShiftingDataVisitor(
- new Visitor1(dataVisitor));
-
- if (treeRange == null || treeRange.processChildren(argumentKey)) {
-
- Object savedRowKey = rootModel.getRowKey();
- //setup key in order for nested components to initialize data models
- rootModel.setRowKey(context, argumentKey);
- Iterator<StackingTreeModel> iterator = this.getInternalModelsIterator();
- rootModel.setRowKey(context, savedRowKey);
-
- while (iterator.hasNext()) {
- final StackingTreeModel model = iterator.next();
-
- savedRowKey = rootModel.getRowKey();
- rootModel.setRowKey(context, argumentKey);
- final ExtendedDataModel scalarModel = model.getDataModel();
- rootModel.setRowKey(context, savedRowKey);
-
- Argument argument2 = new Argument();
- argument2.listRowKey = argumentKey;
- argument2.argument = argument;
- // setup current model
- argument2.model = model;
- argument2.range = range;
-
- scalarModel.walk(context, new DataVisitor() {
-
- public void process(FacesContext context,
- Object rowKey, Object argument)
- throws IOException {
-
- Object key = scalarModel.getRowKey();
- scalarModel.setRowKey(rowKey);
- Object data = scalarModel.getRowData();
-
- Object variable = model.setupVariable(data, context);
- boolean activeData = model.isActiveData();
- model.setupVariable(variable, context);
- scalarModel.setRowKey(key);
-
- if (activeData) {
- shiftingDataVisitor.process(context, rowKey, argument);
- }
- }
-
- }, null, argument2);
-
- }
- }
-
- shiftingDataVisitor.end(context);
- }
- }
-
- private StackingTreeModel getInternalModelById(String id) {
- StackingTreeModel model = getModelById(id);
- if (model.isActive()) {
- return model;
- }
-
- throw new IllegalStateException();
- }
-
- public StackingTreeModel getModelById(String id) {
- return (StackingTreeModel) models.get(id);
- }
-
- private Iterator<StackingTreeModel> getInternalModelsIterator() {
- return new FilterIterator(getModelsIterator(), ACTIVE_MODEL_PREDICATE);
- }
-
- public Iterator<StackingTreeModel> getModelsIterator() {
- return models.values().iterator();
- }
-
- public void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument,
- boolean last) throws IOException {
- StackingTreeModel rootModel = getRoot();
-
- if (rowKey != null) {
- ListRowKey listRowKey = (ListRowKey) rowKey;
-
- StackingTreeModel treeModel = rootModel.setupKey(listRowKey, context);
-
- treeModel.doWalk(context, dataVisitor, range, listRowKey, argument,
- last);
-
- } else {
- doWalk(context, dataVisitor, range,
- (ListRowKey) rowKey, argument, last);
- }
- }
-
- private class Argument {
- private ListRowKey listRowKey;
- private StackingTreeModel model;
- private Range range;
- private Object argument;
- }
-
- private class Visitor1 implements DataVisitor, LastElementAware {
- private DataVisitor dataVisitor;
- private boolean theLast;
-
- public Visitor1(DataVisitor dataVisitor) {
- super();
- this.dataVisitor = dataVisitor;
- }
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- Argument a = (Argument) argument;
- ListRowKey listRowKey = new ListRowKey(a.listRowKey, new StackingTreeModelKey(
- a.model.id, rowKey));
- //System.out.println(".walk() " + (theLast ? " * " : "") + listRowKey);
-
- a.model.doWalk(context, dataVisitor, a.range, listRowKey, a.argument,
- theLast);
- }
-
- public void resetLastElement() {
- theLast = false;
- }
-
- public void setLastElement() {
- theLast = true;
- }
-
- }
-
- private static class ShiftingDataVisitor implements DataVisitor {
-
- private DataVisitor dataVisitor;
-
- public ShiftingDataVisitor(DataVisitor dataVisitor) {
- super();
- this.dataVisitor = dataVisitor;
- }
-
- private Object rowKey;
- private Object argument;
- private boolean shifted = false;
-
- public void process(FacesContext context, Object rowKey, Object argument)
- throws IOException {
-
- if (!shifted) {
- this.rowKey = rowKey;
- this.argument = argument;
- this.shifted = true;
- } else {
- dataVisitor.process(context, this.rowKey, this.argument);
- this.rowKey = rowKey;
- this.argument = argument;
- }
- }
-
- public void end(FacesContext context) throws IOException {
- if (shifted) {
- try {
- ((LastElementAware) dataVisitor).setLastElement();
- dataVisitor.process(context, this.rowKey, argument);
- } finally {
- ((LastElementAware) dataVisitor).resetLastElement();
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.model.AbstractTreeDataModel#walkModel(javax.faces.context.FacesContext,
- * org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range,
- * java.lang.Object, java.lang.Object, boolean)
- */
- public void walkModel(FacesContext facesContext, DataVisitor visitor,
- Range range, Object key, Object argument, boolean last)
- throws IOException {
-
- walk(facesContext, visitor, range, key, argument, last);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
- */
- public Object getRowKey() {
- return rowKey;
- }
-
- public void setRowKey(Object key) {
- setRowKey(FacesContext.getCurrentInstance(), key);
- }
-
- public void setRowKey(FacesContext context, Object key) {
- setupKey(key, context);
- }
-
- public void addStackingModel(StackingTreeModel model) {
- this.models.put(model.id, model);
- model.setParent(this);
- }
-
- public void removeStackingModel(StackingTreeModel model) {
- this.models.remove(model.id);
- model.setParent(null);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#getRowData()
- */
- public Object getRowData() {
- if (isRowAvailable()) {
- StackEntry lastEntry = (StackEntry) stackEntries.getLast();
- return lastEntry.rowData;
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.faces.model.DataModel#isRowAvailable()
- */
- public boolean isRowAvailable() {
- return !stackEntries.isEmpty();
- }
-
- public StackingTreeModel getParent() {
- return parent;
- }
-
- protected boolean isActiveData() {
- return true;
- }
-
- protected boolean isActive() {
- return true;
- }
-
- private final static Predicate ACTIVE_MODEL_PREDICATE = new Predicate() {
-
- public boolean evaluate(Object object) {
- StackingTreeModel model = (StackingTreeModel) object;
- if (model == null) {
- return false;
- }
-
- return model.isActive();
- }
-
- };
-
- @Override
- public Object getWrappedData() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public Object convertToKey(FacesContext context, String keyString,
- UIComponent component, Converter converter) {
-
- //force model leave
- setRowKey(context, null);
-
- String[] strings = ListRowKey.fromString(keyString);
- int l = strings.length / 2;
- List<Object> list = new ArrayList<Object>(l);
- StackingTreeModel model = getRoot();
-
- for (int i = 0; i < l; i++) {
- int idx = i*2;
-
- String modelId = strings[idx];
- model = model.getModelById(modelId);
- if (model.isActive()) {
- Object key = model.convert(context, strings[idx + 1], component, converter);
- if (key == null) {
- return null;
- }
-
- list.add(new StackingTreeModelKey(modelId, key));
-
- if (!model.setupModel(key, context) || !model.isActiveData()) {
- return null;
- }
- } else {
- return null;
- }
- }
-
- return new ListRowKey<Object>(list);
- }
-
- protected Object convert(FacesContext context, String string,
- UIComponent component, Converter converter) {
-
- ConvertableKeyModel convertable = (ConvertableKeyModel) getDataModel();
- return convertable.getKeyAsObject(context, string, component, converter);
- }
-
- public String getId() {
- return id;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,33 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 30.07.2007
- *
- */
-public interface StackingTreeModelDataProvider {
- public Object getData();
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,103 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- */
-public class StackingTreeModelKey<T> implements Serializable, ComplexTreeRowKey {
- /**
- *
- */
- private static final long serialVersionUID = -6821854350257816571L;
- protected T modelKey;
- protected String modelId;
-
- public StackingTreeModelKey(String modelId, T modelKey) {
- super();
- this.modelId = modelId;
- this.modelKey = modelKey;
- }
-
- public String toString() {
- return this.modelId + AbstractTreeDataModel.SEPARATOR + this.modelKey;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result
- + ((modelId == null) ? 0 : modelId.hashCode());
- result = prime * result
- + ((modelKey == null) ? 0 : modelKey.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- final StackingTreeModelKey other = (StackingTreeModelKey) obj;
- if (modelId == null) {
- if (other.modelId != null)
- return false;
- } else if (!modelId.equals(other.modelId))
- return false;
- if (modelKey == null) {
- if (other.modelKey != null)
- return false;
- } else if (!modelKey.equals(other.modelKey))
- return false;
- return true;
- }
-
- public String getModelId() {
- return modelId;
- }
-
- public Object getModelKey() {
- return modelKey;
- }
-
- public int getKeySegmentsCount() {
- return 2;
- }
-
- public Object getKeySegment(int i) {
- switch (i) {
- case 0:
- return modelId;
- case 1:
- return modelKey;
-
- default:
- throw new IllegalArgumentException(String.valueOf(i));
- }
- }
-}
\ No newline at end of file
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,78 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.component.UIComponentBase;
-
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski mailto:nbelaevski@exadel.com created 25.07.2007
- *
- */
-public abstract class StackingTreeModelProvider extends UIComponentBase {
-
- public abstract Object getNodes();
- public abstract void setNodes(Object nodes);
-
- public Object getData() {
- return getNodes();
- }
-
- protected abstract StackingTreeModel createStackingTreeModel();
-
- private List<StackingTreeModel> createChildModelsList() {
- List<StackingTreeModel> childModels = new ArrayList<StackingTreeModel>();
-
- if (getChildCount() > 0) {
- Iterator<UIComponent> children = getChildren().iterator();
- while (children.hasNext()) {
- UIComponent component = children.next();
- if (component instanceof StackingTreeModelProvider) {
- StackingTreeModelProvider provider = (StackingTreeModelProvider) component;
- childModels.add(provider.getStackingModel());
- }
- }
- }
-
- return childModels;
- }
-
- protected void addChildModels(StackingTreeModel model, List<StackingTreeModel> childModels) {
- for (StackingTreeModel childModel : childModels) {
- model.addStackingModel(childModel);
- }
- }
-
- public StackingTreeModel getStackingModel() {
- StackingTreeModel stackingTreeModel = createStackingTreeModel();
-
- addChildModels(stackingTreeModel, createChildModelsList());
-
- return stackingTreeModel;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,77 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import javax.swing.tree.TreeNode;
-
-/**
- * {@link CacheableTreeDataModel} implementation for Swing {@link TreeNode} instances
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public class SwingCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
-
- private static final MissingNodeHandler<TreeNode> missingNodeHandler = new MissingNodeHandler<TreeNode>() {
-
- public TreeNode handleMissingNode(TreeNode parent,
- Object pathSegment) {
-
- SwingTreeNodeImpl childNode = new CacheableSwingTreeNodeImpl();
-
- if (parent != null) {
- SwingTreeNodeImpl parentNode = (SwingTreeNodeImpl) parent;
-
- parentNode.addChild(pathSegment, childNode);
- childNode.setParent(parentNode);
- }
-
- return childNode;
- }
-
- };
-
- public SwingCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
- super(model, missingNodeHandler);
- }
-
- @Override
- public Object getRowData() {
- SwingTreeNodeImpl swingTreeNodeImpl = ((SwingTreeNodeImpl) super.getRowData());
- if (swingTreeNodeImpl != null) {
- return swingTreeNodeImpl.getData();
- } else {
- return null;
- }
- }
-
- @Override
- protected void setDefaultNodeData(TreeNode node, Object data) {
- CacheableSwingTreeNodeImpl cacheableTreeNode = (CacheableSwingTreeNodeImpl) node;
- cacheableTreeNode.setData(data);
- cacheableTreeNode.setNotLeaf(!isLeaf());
- }
-}
-
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,110 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.convert.Converter;
-import javax.swing.tree.TreeNode;
-
-/**
- * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public class SwingTreeDataModel extends TreeDataModel<TreeNode> {
-
- private TreeNode treeNode;
-
- public SwingTreeDataModel() {
- super(TreeNode.class, TreeDataModelNodeAdaptor.swingTreeNodeAdaptor, null);
- }
-
- @Override
- protected TreeNode getData() {
- return treeNode;
- }
-
- @Override
- public void setWrappedData(Object data) {
- if (data != null) {
- SwingTreeNodeImpl treeNodeImpl = new SwingTreeNodeImpl();
-
- if (data instanceof Collection<?>) {
- Collection<?> collection = (Collection<?>) data;
-
- for (Iterator<?> iterator = collection.iterator(); iterator
- .hasNext();) {
- treeNodeImpl.addChild((TreeNode) iterator.next());
- }
- } else if (data.getClass().isArray()) {
- Object[] nodes = (Object[]) data;
- for (int i = 0; i < nodes.length; i++) {
- treeNodeImpl.addChild((TreeNode) nodes[i]);
- }
- } else {
- treeNodeImpl.addChild((TreeNode) data);
- }
-
- this.treeNode = treeNodeImpl;
- } else {
- this.treeNode = null;
- }
-
- super.setWrappedData(data);
- }
-
-
- @Override
- public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
- String[] strings = ListRowKey.fromString(keyString);
- List<Integer> list = new ArrayList<Integer>(strings.length);
- TreeNode node = this.treeNode;
-
- if (node != null) {
- TreeDataModelNodeAdaptor<TreeNode> adaptor = getNodeAdaptor();
-
- for (int i = 0; i < strings.length; i++) {
- int key = Integer.parseInt(strings[i]);
-
- node = adaptor.getChild(node, key);
- if (node != null) {
- list.add(key);
- } else {
- return null;
- }
- }
- }
-
- return new ListRowKey<Integer>(list);
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,145 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.swing.tree.TreeNode;
-
-/**
- * Map-based Swing {@link TreeNode} implementation
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-@Deprecated
-public class SwingTreeNodeImpl implements TreeNode {
-
- private List<TreeNode> children = new ArrayList<TreeNode>();
-
- private TreeNode parent;
-
- private Object data;
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#children()
- */
- public Enumeration children() {
- return new Enumeration() {
- private Iterator<?> iterator = children.iterator();
-
- public boolean hasMoreElements() {
- return iterator.hasNext();
- }
-
- public Object nextElement() {
- return iterator.next();
- }
- };
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#getAllowsChildren()
- */
- public boolean getAllowsChildren() {
- return true;
- }
-
- public void setAllowsChildren(boolean allowsChildren) {
- if (!allowsChildren) {
- throw new IllegalArgumentException();
- }
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#getChildAt(int)
- */
- public TreeNode getChildAt(int childIndex) {
- return children.get(childIndex);
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#getChildCount()
- */
- public int getChildCount() {
- return children.size();
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
- */
- public int getIndex(TreeNode node) {
- return children.indexOf(node);
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#getParent()
- */
- public TreeNode getParent() {
- return parent;
- }
-
- public void setParent(TreeNode parent) {
- this.parent = parent;
- }
-
- /* (non-Javadoc)
- * @see javax.swing.tree.TreeNode#isLeaf()
- */
- public boolean isLeaf() {
- return children.isEmpty();
- }
-
- public void addChild(TreeNode node) {
- children.add(node);
- }
-
- public void addChild(Object key, TreeNode node) {
- if (Integer.valueOf(children.size()).equals(key)) {
- children.add(node);
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
- }
-
- public void removeChild(TreeNode node) {
- this.children.remove(node);
- }
-
- public void removeChildByKey(Object key) {
- this.children.remove(((Integer) key).intValue());
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,401 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.model.DataVisitor;
-import org.ajax4jsf.model.Range;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski - nbelaevski(a)exadel.com created 16.11.2006
- *
- */
-public abstract class TreeDataModel<T> extends AbstractTreeDataModel {
-
- private Object wrappedData;
- private Class<T> clazz;
-
- private TreeRowKey currentRowKey;
-
- private TreeRowKey oldRowKey;
-
- private Boolean rowAvailable = Boolean.FALSE;
- private T rowTreeData;
-
- protected final TreeDataModelNodeAdaptor<T> nodeAdaptor;
-
- private MissingNodeHandler<T> missingNodeHandler;
-
- /**
- * Interface aimed to handle missing nodes for externally-generated keys.
- * Typical usage for the interface is filling model cache
- * @param <T> generic tree node type
- *
- * @author Nick Belaevski
- * @since 3.2
- */
- public static interface MissingNodeHandler<T> {
- T handleMissingNode(T parentNode, Object pathSegment);
- };
-
- public TreeDataModel(Class<T> clazz, TreeDataModelNodeAdaptor<T> nodeAdaptor,
- MissingNodeHandler<T> missingNodeHandler) {
-
- this.clazz = clazz;
- this.nodeAdaptor = nodeAdaptor;
- this.missingNodeHandler = missingNodeHandler;
- }
-
- public final Class<T> getClazz() {
- return clazz;
- }
-
- public final TreeDataModelNodeAdaptor<T> getNodeAdaptor() {
- return nodeAdaptor;
- }
-
- public Object getRowKey() {
- return this.currentRowKey;
- }
-
- public void setRowKey(Object rowKey) {
- if (rowKey != null) {
- ListRowKey newRowKey = (ListRowKey) rowKey;
- this.currentRowKey = newRowKey;
- this.rowAvailable = null;
- } else {
- this.currentRowKey = null;
- this.oldRowKey = null;
- this.rowTreeData = null;
- this.rowAvailable = Boolean.FALSE;
- }
- }
-
- protected void doWalk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last) throws IOException {
- ListRowKey listRowKey = (ListRowKey) rowKey;
-
- T node = locateTreeNode(listRowKey);
-
- if (node != null) {
- TreeRange treeRange = (TreeRange) range;
-
- if (treeRange == null || treeRange.processNode(listRowKey)) {
-
- //root node is not processed, it is considered fake for this class of models
- if (listRowKey != null && listRowKey.depth() > 0) {
- processElement(context, dataVisitor, argument, listRowKey, last);
- }
-
- if (treeRange == null || treeRange.processChildren(listRowKey)) {
- if (!nodeAdaptor.isLeaf(node)) {
- Iterator<Map.Entry<Object, T>> children = nodeAdaptor.getChildren(node);
-
- if (children != null) {
- Map.Entry<Object, T> childEntry = children.hasNext() ? children.next() : null;
- T childNode;
- Object identifier;
-
- if (childEntry != null) {
- childNode = childEntry.getValue();
- identifier = childEntry.getKey();
- } else {
- childNode = null;
- identifier = null;
- }
-
- do {
- Map.Entry<Object, T> nextChildEntry = children.hasNext() ? children.next() : null;
- T nextChildNode;
- Object nextIdentifier;
-
- if (nextChildEntry != null) {
- //TODO consider lazy initialization of value
- nextChildNode = nextChildEntry.getValue();
- nextIdentifier = nextChildEntry.getKey();
- } else {
- nextChildNode = null;
- nextIdentifier = null;
- }
-
- if (childNode != null) {
-
- boolean isLast = nextChildNode == null;
-
- ListRowKey newRowKey = new ListRowKey(listRowKey, identifier);
- this.doWalk(context, dataVisitor, range, newRowKey, argument, isLast);
- }
-
- identifier = nextIdentifier;
- childNode = nextChildNode;
- } while (childNode != null);
- }
- }
- }
- }
- }
- }
-
- public void walk(FacesContext context, DataVisitor dataVisitor,
- Range range, Object rowKey, Object argument, boolean last) throws IOException {
-
- if (rowKey != null) {
- setRowKey(rowKey);
- if (!isRowAvailable()) {
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
- }
-
- doWalk(context, dataVisitor, range, rowKey, argument, last);
- }
-
- public T locateTreeNode(TreeRowKey rowKey) {
- return locateTreeNode(rowKey, false);
- }
-
- public T locateTreeNode(TreeRowKey rowKey, boolean allowCreate) {
- T tmpRowTreeData = this.rowTreeData;
- TreeRowKey tmpOldRowKey = this.oldRowKey;
-
- boolean useCached = (rowTreeData != null && rowKey != null && rowKey.equals(tmpOldRowKey));
- if (!useCached) {
- T rootNode = getData();
-
- if (rootNode != null) {
- if (rowKey != null) {
- int commonPathLength = rowKey.getCommonPathLength(tmpOldRowKey);
- if (tmpOldRowKey == null) {
- tmpRowTreeData = rootNode;
- } else {
- int rootOpsCount = rowKey.depth();
- int currentUpOpsCount = tmpOldRowKey.depth() - commonPathLength;
- int currentOpsCount = currentUpOpsCount + rootOpsCount - commonPathLength;
-
- if (rootOpsCount > currentOpsCount) {
- for (int i = 0; i < tmpOldRowKey.depth()
- - commonPathLength; i++) {
-
- tmpRowTreeData = nodeAdaptor.getParent(tmpRowTreeData);
- }
- } else {
- commonPathLength = 0;
- tmpRowTreeData = rootNode;
- tmpOldRowKey = null;
- }
- }
- tmpOldRowKey = rowKey;
- Iterator<?> iterator = rowKey.getSubPathIterator(commonPathLength);
- while (iterator.hasNext()) {
- //TODO nick - check rowTreeData for null
-
- Object pathSegment = iterator.next();
- T childRowTreeData = nodeAdaptor.getChild(tmpRowTreeData, pathSegment);
-
- if (childRowTreeData == null) {
- if (!allowCreate) {
- //TODO nick - reset rowTreeData
- return null;
- } else {
- if (missingNodeHandler != null) {
- childRowTreeData = missingNodeHandler.
- handleMissingNode(tmpRowTreeData, pathSegment);
-
- if (childRowTreeData == null) {
- return null;
- }
- } else {
- return null;
- }
- }
- }
-
- tmpRowTreeData = childRowTreeData;
- }
- } else {
- return rootNode;
- }
- } else {
- return null;
- }
- }
-
- // check whether we were found something and store it
- if (tmpRowTreeData != null) {
- rowTreeData = tmpRowTreeData;
- oldRowKey = tmpOldRowKey;
- }
- return rowTreeData;
- }
-
- public boolean isRowAvailable() {
- if (Boolean.FALSE.equals(rowAvailable)) {
- return false;
- }
-
- T data = locateTreeNode(this.currentRowKey);
-
- if (data != null) {
- return true;
- }
-
- return false;
- }
-
- public Object getRowData() {
- if (isRowAvailable()) {
- T treeNode = locateTreeNode(this.currentRowKey);
- if (treeNode != null) {
- return nodeAdaptor.getRowData(treeNode);
- }
-
- return null;
- }
-
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- public boolean isLeaf() {
- if (isRowAvailable()) {
- T treeNode = locateTreeNode(this.currentRowKey);
- if (treeNode != null) {
- return nodeAdaptor.isLeaf(treeNode);
- }
- }
-
- throw new IllegalStateException(
- "No tree element available or row key not set!");
- }
-
- public void walkModel(FacesContext context, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException {
- walk(context, visitor, range, key, argument, last);
- }
-
- @Override
- public Object getWrappedData() {
- return wrappedData;
- }
-
- @Override
- public void setWrappedData(Object data) {
- this.wrappedData = data;
- }
-
- protected T getData() {
- return clazz.cast(wrappedData);
- }
-
- public TreeNode<T> getTreeNode() {
- return null;
- }
-
- /**
- * Get row key for certain tree node object
- *
- * @param node to get key for
- * @return node row key
- */
- @Override
- @SuppressWarnings("unchecked")
- public Object getTreeNodeRowKey(Object node) {
- if (node == null) {
- throw new UnsupportedOperationException();
- }
-
- T childNode = (T) node;
- List<Object> path = new LinkedList<Object>();
- Object id = nodeAdaptor.getChildNodeId(childNode);
- if (id != null) {
- path.add(id);
- }
-
- T parentNode = childNode;
- while ((parentNode = nodeAdaptor.getParent(parentNode)) != null) {
- id = nodeAdaptor.getChildNodeId(parentNode);
- if (id != null) {
- path.add(0, id);
- } else if (nodeAdaptor.getParent(parentNode) != null) {
- throw new UnsupportedOperationException();
- }
- }
- return new ListRowKey(path);
- }
-
- /**
- * Get node local id in it's parent childs collection
- *
- * @param childNode node to get identifier for
- * @return node local identifier
- */
- @Override
- public Object getChildNodeId(Object childNode) {
- return getNodeAdaptor().getChildNodeId((T) childNode);
- }
-
- @Override
- public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
- addNode(parentRowKey, (Object) newNode, id);
- }
-
- public void addNode(Object parentRowKey, Object newNode, Object id) {
- Object initialRowKey = getRowKey();
- try {
- T parentTreeNode = locateTreeNode((TreeRowKey) parentRowKey);
-
- if (parentTreeNode == null) {
- throw new IllegalArgumentException("Parent node not found!");
- }
-
- getNodeAdaptor().appendChild(parentTreeNode, id, clazz.cast(newNode));
- } finally {
- setRowKey(initialRowKey);
- }
- }
-
- @Override
- public void removeNode(Object rowKey) {
- Object initialRowKey = getRowKey();
- try {
- T treeNode = locateTreeNode((TreeRowKey) rowKey);
-
- if (treeNode == null) {
- throw new IllegalArgumentException("Node not fond!");
- }
-
- getNodeAdaptor().removeFromParent(treeNode);
- } finally {
- setRowKey(initialRowKey);
- }
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,278 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.swing.tree.MutableTreeNode;
-import javax.swing.tree.TreeNode;
-
-/**
- * {@link TreeDataModel} adaptor for generic types. Contains adaptors for Swing & classic ({@link TreeNode})
- * tree node types embedded into this interface as static instances
- *
- * Created 01.11.2007
- *
- * @author Nick Belaevski
- * @since 3.2
- */
-
-public interface TreeDataModelNodeAdaptor<T> {
- public T getParent(T node);
-
- public boolean isLeaf(T node);
-
- public T getChild(T node, Object key);
-
- public Iterator<Map.Entry<Object, T>> getChildren(T node);
-
- public Object getRowData(T node);
-
- /**
- * Get node local id in it's parent childs collection
- *
- * @param childNode node to get identifier for
- * @return node local identifier
- */
- public Object getChildNodeId(T childNode);
-
- public void appendChild(T parentNode, Object key, T childNode);
-
- public void removeFromParent(T childNode);
-
- /**
- * Instance of {@link TreeDataModelNodeAdaptor} for {@link org.richfaces.model.TreeNode} nodes handling
- */
- @SuppressWarnings("unchecked")
- public static final TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode> classicTreeNodeAdaptor =
- new TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode>() {
-
- public org.richfaces.model.TreeNode getChild(org.richfaces.model.TreeNode node, Object key) {
- return node.getChild(key);
- }
-
- public Iterator<Entry<Object, org.richfaces.model.TreeNode>> getChildren(
- org.richfaces.model.TreeNode node) {
- return node.getChildren();
- }
-
- public org.richfaces.model.TreeNode getParent(org.richfaces.model.TreeNode node) {
- return node.getParent();
- }
-
- public Object getRowData(org.richfaces.model.TreeNode node) {
- return node.getData();
- }
-
- public boolean isLeaf(org.richfaces.model.TreeNode node) {
- return node.isLeaf();
- }
-
- /**
- * Get node local id in it's parent childs collection
- *
- * @param childNode node to get identifier for
- * @return node local identifier
- */
- public Object getChildNodeId(org.richfaces.model.TreeNode childNode) {
- org.richfaces.model.TreeNode parentNode = getParent(childNode);
- if (childNode != null && parentNode != null) {
- Iterator<Map.Entry<Object, TreeNode>> iter = parentNode.getChildren();
- while (iter != null && iter.hasNext()) {
- Map.Entry<Object, TreeNode> entry = iter.next();
- if (entry != null && childNode.equals(entry.getValue())) {
- return entry.getKey();
- }
- }
- }
- return null;
- }
-
- public void appendChild(org.richfaces.model.TreeNode parentNode,
- Object childKey, org.richfaces.model.TreeNode childNode) {
-
- parentNode.addChild(childKey, childNode);
- }
-
- public void removeFromParent(org.richfaces.model.TreeNode childNode) {
- org.richfaces.model.TreeNode parent = childNode.getParent();
- Object childNodeId = getChildNodeId(childNode);
- if (childNodeId != null) {
- parent.removeChild(childNodeId);
- }
- }
- };
-
- /**
- * Instance of {@link TreeDataModelNodeAdaptor} for {@link javax.swing.tree.TreeNode} nodes handling
- */
- public static final TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode> swingTreeNodeAdaptor =
- new TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode>() {
-
- final class SwingNodeMapEntry implements Map.Entry<Object, TreeNode> {
-
- private Object key;
- private TreeNode child;
-
- public SwingNodeMapEntry(int i, TreeNode child) {
- this.key = Integer.valueOf(i);
- this.child = child;
- }
-
- public Object getKey() {
- return this.key;
- }
-
- public TreeNode getValue() {
- return child;
- }
-
- public TreeNode setValue(TreeNode value) {
- TreeNode node = this.child;
- this.child = value;
-
- return node;
- }
-
- };
-
- public javax.swing.tree.TreeNode getChild(
- javax.swing.tree.TreeNode node, Object key) {
-
- int intKey = ((Integer) key).intValue();
- if (intKey < node.getChildCount() && intKey >= 0) {
- return node.getChildAt(intKey);
- }
-
- return null;
- }
-
- public Iterator<Entry<Object, javax.swing.tree.TreeNode>> getChildren(
- final javax.swing.tree.TreeNode node) {
-
- if (node.getAllowsChildren()) {
- return new Iterator<Entry<Object,javax.swing.tree.TreeNode>>() {
-
- private final Enumeration<?> e = node.children();
- private int counter = 0;
-
- public boolean hasNext() {
- return e.hasMoreElements();
- }
-
- public Entry<Object, javax.swing.tree.TreeNode> next() {
- javax.swing.tree.TreeNode child = (javax.swing.tree.TreeNode) e.nextElement();
- SwingNodeMapEntry entry = new SwingNodeMapEntry(counter++, child);
- return entry;
-
- }
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- };
- }
-
- return null;
- }
-
- public javax.swing.tree.TreeNode getParent(
- javax.swing.tree.TreeNode node) {
- return node.getParent();
- }
-
- public Object getRowData(javax.swing.tree.TreeNode node) {
- return node;
- }
-
- public boolean isLeaf(javax.swing.tree.TreeNode node) {
- return !node.getAllowsChildren() || node.isLeaf();
- }
-
- /**
- * Get node local id in it's parent childs collection
- *
- * @param childNode node to get identifier for
- * @return node local identifier
- */
- public Object getChildNodeId(javax.swing.tree.TreeNode childNode) {
- javax.swing.tree.TreeNode parentNode = getParent(childNode);
- if (childNode != null && parentNode != null) {
- int idx = parentNode.getIndex(childNode);
- if (idx != -1) {
- return idx;
- } else {
- return null;
- }
- } else {
- return null;
- }
- }
-
- @SuppressWarnings("deprecation")
- public void appendChild(javax.swing.tree.TreeNode parentNode, Object key,
- javax.swing.tree.TreeNode childNode) {
-
- if (childNode instanceof MutableTreeNode) {
- MutableTreeNode mutableChildNode = (MutableTreeNode) childNode;
- MutableTreeNode mutableParentNode = (MutableTreeNode) parentNode;
- int idx;
-
- if (key != null) {
- idx = (Integer) key;
- } else {
- idx = mutableParentNode.getChildCount();
- }
-
- mutableParentNode.insert(mutableChildNode, idx);
- } else {
- SwingTreeNodeImpl swingTreeNodeImpl = (SwingTreeNodeImpl) childNode;
- SwingTreeNodeImpl parent = (SwingTreeNodeImpl) parentNode;
-
- if (key != null) {
- parent.addChild(key, swingTreeNodeImpl);
- } else {
- parent.addChild(swingTreeNodeImpl);
- }
-
- swingTreeNodeImpl.setParent(parent);
- }
- }
-
- @SuppressWarnings("deprecation")
- public void removeFromParent(javax.swing.tree.TreeNode node) {
- if (node instanceof MutableTreeNode) {
- ((MutableTreeNode) node).removeFromParent();
- } else {
- SwingTreeNodeImpl swingTreeNodeImpl = (SwingTreeNodeImpl) node;
- SwingTreeNodeImpl parent = (SwingTreeNodeImpl) swingTreeNodeImpl.getParent();
-
- parent.removeChild(swingTreeNodeImpl);
- swingTreeNodeImpl.setParent(null);
- }
- }
- };
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,35 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import javax.faces.component.UIComponent;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 29.07.2007
- *
- */
-public interface TreeModelVisualComponentProvider {
- public UIComponent getComponent();
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNode.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNode.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNode.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,112 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.faces.component.NamingContainer;
-
-
-/**
- * Interface representing tree ADT nodes
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- */
-public interface TreeNode<T> extends Serializable{
-
- /**
- * getter for node attached data
- * @return node attached data
- */
- public T getData();
- /**
- * setter for node attached data
- * @param data data to set as attached node data
- */
- public void setData(T data);
-
- /**
- * Returns whether this node is leaf
- * @return <code>true</code> if this node is leaf else returns <code>false</code>
- */
- public boolean isLeaf();
-
- /**
- * Getter for children entries. Each children entry contains identifier (key) and child node (value).
- *
- * Identifiers are used to generate model keys representing paths to tree node. Model keys are used:
- * <ol>
- * <li>
- * For persisting tree state. That means that identifiers should be serializable when
- * some JSF features are used, e.g. client-side state saving.
- * </li>
- * <li>
- * For constructing client identifiers. Client identifier for tree nodes consists of
- * {@link Object#toString()} representations of identifier separated with
- * {@link NamingContainer#SEPARATOR_CHAR} chars. String representation of identifier
- * should be a valid XML ID, e.g. conform to this: <a href="http://www.w3.org/TR/xml11/#NT-Name">
- * XML Name Production</a>
- * production.
- * </li>
- * </ol>
- *
- * @return {@link Iterator} of {@link Map.Entry} instances containing {@link TreeNode} as values
- * and their identifiers as keys.
- *
- */
- public Iterator<Map.Entry<Object, TreeNode<T>>> getChildren();
- /**
- * find child by id
- * Please see {@link #getChildren()} for more information about identifier constraints.
- * @param id identifier of the child to find
- * @return designated {@link TreeNode} instance or <code>null</code>
- */
- public TreeNode<T> getChild(Object id);
-
- /**
- * adds child to children collection
- * @param identifier child identifier.
- * Please see {@link #getChildren()} for more information about identifier constraints.
- * @param child child
- */
- public void addChild(Object identifier, TreeNode<T> child);
-
- /**
- * Please see {@link #getChildren()} for more information about identifier constraints.
- * removes child from children collection by child id
- * @param id id of the child to remove
- */
- public void removeChild(Object id);
-
- /**
- * getter for parent {@link TreeNode}
- * @return parent {@link TreeNode} instance or <code>null</code> if this node is root
- */
- public TreeNode<T> getParent();
- /**
- * setter for parent {@link TreeNode}
- * @param parent {@link TreeNode} to set as parent
- */
- public void setParent(TreeNode<T> parent);
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNodeImpl.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNodeImpl.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNodeImpl.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,84 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Default {@link TreeNode} implementation based on {@link LinkedHashMap} to preserve
- * elements ordering
- *
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 16.11.2006
- */
-public class TreeNodeImpl<T> implements TreeNode<T> {
-
- private static final long serialVersionUID = -5498990493803705085L;
- private T data;
- private TreeNode<T> parent;
-
- private Map<Object, TreeNode<T>> childrenMap =
- new LinkedHashMap<Object, TreeNode<T>>();
-
- public T getData() {
- return data;
- }
-
- public TreeNode<T> getChild(Object identifier) {
- return (TreeNode<T>) childrenMap.get(identifier);
- }
-
- public void addChild(Object identifier, TreeNode<T> child) {
- child.setParent(this);
- childrenMap.put(identifier, child);
- }
-
- public void removeChild(Object identifier) {
- TreeNode<T> treeNode = childrenMap.remove(identifier);
- if (treeNode != null) {
- treeNode.setParent(null);
- }
- }
-
- public void setData(T data) {
- this.data = data;
- }
-
- public TreeNode<T> getParent() {
- return parent;
- }
-
- public void setParent(TreeNode<T> parent) {
- this.parent = parent;
- }
-
- public Iterator<Map.Entry<Object, TreeNode<T>>> getChildren() {
- return childrenMap.entrySet().iterator();
- }
-
- public boolean isLeaf() {
- return childrenMap.isEmpty();
- }
-
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRange.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRange.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRange.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,66 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import org.ajax4jsf.model.Range;
-
-/**
- * {@link Range} implmentation variant for {@link AbstractTreeDataModel}
- *
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 23.11.2006
- */
-public interface TreeRange extends Range {
-
- /**
- * Returns <code>true</code> if node with that rowKey should be processed.
- * If <code>false</code> is returned, then skips processing child nodes also.
- * @param rowKey {@link TreeRowKey} key instance
- * @return <code>true</code> or <code>false</code>
- */
- public boolean processNode(TreeRowKey rowKey);
-
- /**
- * Returns <code>true</code> if children of the node with that rowKey should be processed
- * @param rowKey {@link TreeRowKey} key instance
- * @return <code>true</code> or <code>false</code>
- */
- public boolean processChildren(TreeRowKey rowKey);
-
-
- /**
- * Unconstrained variant of {@link TreeRange}.
- * Is stateless and safe to use in multi-threaded environments.
- *
- * @since 3.2.2
- * @author Nick Belaevski
- */
- public final static TreeRange RANGE_UNCONSTRAINED = new TreeRange() {
- public boolean processChildren(TreeRowKey rowKey) {
- return true;
- }
-
- public boolean processNode(TreeRowKey rowKey) {
- return true;
- }
- };
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRowKey.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRowKey.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRowKey.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,103 +0,0 @@
-/**
- * License Agreement.
- *
- * JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.model;
-
-import java.io.Serializable;
-import java.util.Iterator;
-
-/**
- * Base abstract clas for all tree row keys
- * @author Nick Belaevski - nbelaevski(a)exadel.com
- * created 06.12.2006
- */
-public abstract class TreeRowKey<T> implements Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -7318192501938658798L;
-
- public static final char SEPARATOR_ESCAPE_CHAR = '_';
-
- /**
- * getter for key depth
- * @return key depth
- */
- public abstract int depth();
-
- /**
- * getter for subpath iterator
- * @param fromIndex
- * @return subpath segments iterator
- */
- public abstract Iterator<T> getSubPathIterator(int fromIndex);
-
- /**
- * getter for path string representation
- * @return path string
- */
- public abstract String getPath();
-
- public String toString() {
- return getPath();
- }
-
- /**
- * tests if specified rowKey is sub-key of this row key
- * @param rowKey
- * @return
- */
- public boolean isSubKey(TreeRowKey<T> rowKey) {
- if (rowKey == null) {
- return false;
- }
-
- String otherPath = rowKey.getPath();
- String path = getPath();
-
- if (otherPath.startsWith(path)) {
- return otherPath.length() == path.length() ||
- otherPath.charAt(path.length()) == AbstractTreeDataModel.SEPARATOR;
- } else {
- return false;
- }
- }
-
- /**
- * getter for path iterator
- * @return path segments iterator
- */
- public abstract Iterator<T> iterator();
-
- /**
- * returns this row key and otherRowKey argument row key common path segments count
- * @param otherRowKey {@link TreeRowKey} to count common path segments for
- * @return common path segmments count
- */
- public abstract int getCommonPathLength(TreeRowKey<T> otherRowKey);
-
- public abstract TreeRowKey<T> getParentKey();
-
- public TreeRowKey<T> getSubKey(int fromIndex) {
- throw new UnsupportedOperationException();
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,61 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.richfaces.model;
-
-import javax.faces.component.UIComponent;
-
-/**
- * That is intended for internal use
- *
- * @author Nick Belaevski
- * mailto:nbelaevski@exadel.com
- * created 15.08.2007
- *
- */
-public class VisualStackingTreeModel extends StackingTreeModel implements TreeModelVisualComponentProvider {
- private UIComponent component;
-
- public VisualStackingTreeModel(UIComponent component) {
- super();
-
- this.component = component;
- }
-
- public VisualStackingTreeModel(String id, String var,
- StackingTreeModelDataProvider dataProvider, UIComponent component) {
- super(id, var, dataProvider);
-
- this.component = component;
- }
-
- public UIComponent getComponent() {
- if (this.component != null) {
- return this.component;
- }
-
- StackingTreeModel currentModel = getCurrentModel();
- if (currentModel != null && currentModel != this) {
- return ((TreeModelVisualComponentProvider) currentModel).getComponent();
- }
-
- return null;
- }
-}
Deleted: root/framework/trunk/api/src/main/java/org/richfaces/model/package-info.java
===================================================================
--- root/framework/trunk/api/src/main/java/org/richfaces/model/package-info.java 2009-07-23 16:55:55 UTC (rev 14986)
+++ root/framework/trunk/api/src/main/java/org/richfaces/model/package-info.java 2009-07-23 17:00:43 UTC (rev 14987)
@@ -1,4 +0,0 @@
-/**
- * Model APIs of RichFaces components
- */
-package org.richfaces.model;
15 years, 5 months
JBoss Rich Faces SVN: r14986 - in root/ui-sandbox/trunk/components: datafilterslider and 38 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 12:55:55 -0400 (Thu, 23 Jul 2009)
New Revision: 14986
Added:
root/ui-sandbox/trunk/components/datafilterslider/
root/ui-sandbox/trunk/components/datafilterslider/src/
root/ui-sandbox/trunk/components/datafilterslider/src/main/
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderListener.java
root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderSource.java
root/ui-sandbox/trunk/components/datascroller/
root/ui-sandbox/trunk/components/datascroller/src/
root/ui-sandbox/trunk/components/datascroller/src/main/
root/ui-sandbox/trunk/components/datascroller/src/main/java/
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java
root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java
root/ui-sandbox/trunk/components/tables/api/
root/ui-sandbox/trunk/components/tables/api/src/
root/ui-sandbox/trunk/components/tables/impl/
root/ui-sandbox/trunk/components/tables/impl/src/
root/ui-sandbox/trunk/components/tables/impl/src/main/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/util/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/DataModelCache.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/impl/
root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/package-info.java
root/ui-sandbox/trunk/components/tables/impl/src/test/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/richfaces/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/richfaces/model/impl/
root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/richfaces/model/impl/expressive/
root/ui-sandbox/trunk/components/togglepanels/
root/ui-sandbox/trunk/components/togglepanels/src/
root/ui-sandbox/trunk/components/togglepanels/src/main/
root/ui-sandbox/trunk/components/togglepanels/src/main/java/
root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/
root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/ISimpleToggleListener.java
root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/SimpleToggleEvent.java
Removed:
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/framework-api/
root/ui-sandbox/trunk/components/framework-impl/
root/ui-sandbox/trunk/components/tables/src/
Log:
Moving component APIs into ui-sandbox
Copied: root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesListener;
+import javax.faces.event.PhaseId;
+
+import org.ajax4jsf.event.AjaxEvent;
+
+/**
+ * @author Wesley Hales
+ */
+public class DataFilterSliderEvent extends AjaxEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private Integer oldSliderVal;
+ private Integer newSliderVal;
+
+ /**
+ * Creates a new SliderEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldSliderVal the previously showing item identifier
+ * @param thisNewSliderVal the currently showing item identifier
+ */
+ public DataFilterSliderEvent(UIComponent component, Integer thisOldSliderVal, Integer thisNewSliderVal) {
+ super(component);
+ setPhaseId(PhaseId.INVOKE_APPLICATION);
+ oldSliderVal = thisOldSliderVal;
+ newSliderVal = thisNewSliderVal;
+ }
+
+ public Integer getOldSliderVal() {
+ return oldSliderVal;
+ }
+
+ public Integer getNewSliderVal() {
+ return newSliderVal;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener){
+ return (listener instanceof DataFilterSliderListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener){
+ ((DataFilterSliderListener) listener).processSlider(this);
+ }
+}
Copied: root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderListener.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Wesley Hales
+ */
+public interface DataFilterSliderListener extends FacesListener {
+
+ public void processSlider(org.richfaces.event.DataFilterSliderEvent event);
+
+}
Copied: root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderSource.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataFilterSliderSource.java)
===================================================================
--- root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderSource.java (rev 0)
+++ root/ui-sandbox/trunk/components/datafilterslider/src/main/java/org/richfaces/event/DataFilterSliderSource.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+/**
+ * @author Wesley Hales
+ */
+public interface DataFilterSliderSource {
+
+ /**
+ * Adds a DataFilterSliderListener to this DataFilterSliderSource.
+ *
+ * @param listener the Slider listener to be added
+ */
+ public void addSliderListener(org.richfaces.event.DataFilterSliderListener listener);
+
+ /**
+ * Removes a DataFilterSliderListener from this DataFilterSliderSource.
+ *
+ * @param listener the Slider listener to be removed
+ */
+ public void removeSliderListener(DataFilterSliderListener listener);
+
+ /**
+ * Returns all SliderListeners for this DataFilterSliderSource.
+ *
+ * @return the Slider listener array
+ */
+ public DataFilterSliderListener[] getSliderListeners();
+
+}
Copied: root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,90 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Wesley Hales
+ */
+public class DataScrollerEvent extends ActionEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2657353903701932561L;
+ private String oldScrolVal;
+ private String newScrolVal;
+ private int page;
+
+ /**
+ * Creates a new ScrollerEvent.
+ *
+ * @param component the source of the event
+ * @param thisOldScrolVal the previously showing item identifier
+ * @param thisNewScrolVal the currently showing item identifier
+ */
+ public DataScrollerEvent(UIComponent component, String thisOldScrolVal, String thisNewScrolVal, int page) {
+ super(component);
+ oldScrolVal = thisOldScrolVal;
+ newScrolVal = thisNewScrolVal;
+ this.page = page;
+ }
+
+ public String getOldScrolVal() {
+ return oldScrolVal;
+ }
+
+ public String getNewScrolVal() {
+ return newScrolVal;
+ }
+
+ /**
+ * @since 3.2
+ * @return new page or <code>-1</code> if not applicable
+ */
+ public int getPage() {
+ return page;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener){
+ return super.isAppropriateListener(listener) || (listener instanceof DataScrollerListener);
+ }
+
+ /**
+ * Delivers this event to the SliderListener.
+ *
+ * @param listener the slider listener
+ */
+ public void processListener(FacesListener listener){
+ if (listener instanceof DataScrollerListener) {
+ DataScrollerListener dataScrollerListener = (DataScrollerListener) listener;
+ dataScrollerListener.processScroller(this);
+ }
+
+ if (super.isAppropriateListener(listener)) {
+ super.processListener(listener);
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerListener.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,31 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+
+public interface DataScrollerListener extends FacesListener {
+
+ public void processScroller(org.richfaces.event.DataScrollerEvent event);
+
+}
Copied: root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DataScrollerSource.java)
===================================================================
--- root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java (rev 0)
+++ root/ui-sandbox/trunk/components/datascroller/src/main/java/org/richfaces/event/DataScrollerSource.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,47 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+public interface DataScrollerSource {
+
+ /**
+ * Adds a DataScrollerListener to this DataScrollerSource.
+ *
+ * @param listener the Scroler listener to be added
+ */
+ public void addScrollerListener(org.richfaces.event.DataScrollerListener listener);
+
+ /**
+ * Removes a DataFilterSliderListener from this DataScrollerSourceSource.
+ *
+ * @param listener the Scroler listener to be removed
+ */
+ public void removeScrollerListener(DataScrollerListener listener);
+
+ /**
+ * Returns all ScrollerListeners for this DataScrollerSource.
+ *
+ * @return the Scroler listener array
+ */
+ public DataScrollerListener[] getScrollerListeners();
+
+}
Copied: root/ui-sandbox/trunk/components/tables/api/src (from rev 14985, root/ui-sandbox/trunk/components/tables/src)
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/component/util/ColumnUtil.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,76 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces 3.0 - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.util;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+import org.richfaces.component.Column;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ColumnUtil {
+
+ /**
+ * Extract sort expression from the column
+ *
+ * @param column
+ * @return logical representation of sort field assigned to column component given
+ * In case of EL-expression, an expression string is returned instead of value - so that EL-expression can be evaluated later;
+ * If there's literal value of dedicated attribute is specified, return it;
+ * If attribute is not set, fall aback to component id
+ */
+
+ public static String getColumnSorting(UIComponent column) {
+
+ UIComponent component = (UIComponent) column;
+
+ ValueExpression binding = component.getValueExpression("sortExpression");
+
+ if (binding != null) {
+ return binding.getExpressionString();
+ }
+
+ if (component instanceof Column) {
+ Column col = (Column) component;
+ String sorting = col.getSortExpression();
+
+ if (sorting != null) {
+ return sorting;
+ }
+ }
+
+
+ return component.getId();
+ }
+
+
+ public static boolean isSortable(UIComponent component) {
+ if (component instanceof Column) {
+ return ((Column) component).isSortable();
+ }
+ return Boolean.valueOf(String.valueOf(component.getAttributes().get("sortable")));
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/DataModelCache.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/DataModelCache.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/DataModelCache.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/DataModelCache.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,209 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SerializableDataModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Implementation stores last loaded data, so no additional requests to db will be performed
+ * Acts as a proxy between the component and original data model
+ * @author Maksim Kaszynski
+ *
+ */
+public class DataModelCache extends ScrollableTableDataModel {
+
+ private static Log log = LogFactory.getLog(DataModelCache.class);
+
+ private static class DataRange {
+ private int startRow;
+ private int endRow;
+ private SortOrder sortOrder;
+ private List loadedData;
+
+ public DataRange(int startRow, int endRow, SortOrder sortOrder,
+ List loadedData) {
+ super();
+ this.startRow = startRow;
+ this.endRow = endRow;
+ this.sortOrder = sortOrder;
+ this.loadedData = loadedData;
+ }
+
+ public boolean match(int s, int e, SortOrder sortOrder) {
+ return s == startRow
+ && e == endRow
+ && sortOrdersMatch(sortOrder, this.sortOrder);
+ }
+
+ private boolean sortOrdersMatch(SortOrder sortOrder1, SortOrder sortOrder2) {
+ boolean result = sortOrder1 == sortOrder2;
+
+ if (sortOrder1 != null && sortOrder2 != null) {
+ result = sortOrder1.equals(sortOrder2);
+ }
+
+ return result;
+ }
+
+ }
+
+ private Map secondaryMapping = new HashMap();
+
+ private DataRange dataRange;
+
+ private ScrollableTableDataModel scrollableTableDataModel;
+
+ private int rowCount = Integer.MIN_VALUE;
+
+ public DataModelCache(ScrollableTableDataModel scrollableTableDataModel) {
+ super();
+ this.scrollableTableDataModel = scrollableTableDataModel;
+
+ if (log.isTraceEnabled()) {
+ log.trace("initializing with " + scrollableTableDataModel);
+ }
+ }
+
+ public void addDataModelListener(DataModelListener listener) {
+ scrollableTableDataModel.addDataModelListener(listener);
+ }
+
+ public DataModelListener[] getDataModelListeners() {
+ return scrollableTableDataModel.getDataModelListeners();
+ }
+
+ public Object getObjectById(Object id) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Trying to get object by id" + id);
+ }
+ //First try to find data in inner cache
+ //If not found - get it from original model
+ Object cached = secondaryMapping.get(id);
+
+ if (cached == null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Cache miss " + id + " falling back to original model");
+ }
+
+ cached = scrollableTableDataModel.getObjectById(id);
+ secondaryMapping.put(id, cached);
+
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("At last found element " + cached);
+ }
+
+ return cached;
+ }
+
+ public int getRowCount() {
+ if (rowCount == Integer.MIN_VALUE) {
+ rowCount = scrollableTableDataModel.getRowCount();
+ }
+ return rowCount;
+ }
+
+ public Object getRowData() {
+ Object secondaryMapped = secondaryMapping.get(getRowKey());
+
+ if (secondaryMapped == null) {
+ secondaryMapped = super.getRowData();
+ }
+ return secondaryMapped;
+ }
+
+ public int getRowIndex() {
+ return scrollableTableDataModel.getRowIndex();
+ }
+
+ public Object getRowKey() {
+ return scrollableTableDataModel.getRowKey();
+ }
+
+ public SerializableDataModel getSerializableModel(Range range) {
+ return scrollableTableDataModel.getSerializableModel(range);
+ }
+
+ public Object getWrappedData() {
+ return scrollableTableDataModel.getWrappedData();
+ }
+
+ public boolean isRowAvailable() {
+ return secondaryMapping.containsKey(getRowKey()) || super.isRowAvailable();
+ }
+
+ public List loadData(int startRow, int endRow, SortOrder sortOrder) {
+ if (dataRange == null || !dataRange.match(startRow, endRow, sortOrder)) {
+ List data = scrollableTableDataModel.loadData(startRow, endRow, sortOrder);
+ dataRange = new DataRange(startRow, endRow, sortOrder, data);
+ }
+ return dataRange.loadedData;
+ }
+
+ public void removeDataModelListener(DataModelListener listener) {
+ scrollableTableDataModel.removeDataModelListener(listener);
+ }
+
+ public void setRowIndex(int arg0) {
+ scrollableTableDataModel.setRowIndex(arg0);
+ }
+
+ public void setRowKey(Object key) {
+ scrollableTableDataModel.setRowKey(key);
+ super.setRowKey(key);
+ }
+
+ public void setWrappedData(Object arg0) {
+ scrollableTableDataModel.setWrappedData(arg0);
+ }
+
+ public Object getId(Object o) {
+ return scrollableTableDataModel.getId(o);
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ // TODO Auto-generated method stub
+ super.walk(context, visitor, range, argument);
+ }
+ /*
+ * FIXME: see superclass
+ @Override
+ public void setSortOrder(SortOrder sortOrder) {
+ scrollableTableDataModel.setSortOrder(sortOrder);
+ }
+ */
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,284 @@
+/**
+* License Agreement.
+*
+* JBoss RichFaces - Ajax4jsf Component Library
+*
+* Copyright (C) 2008 CompuGROUP Holding AG
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1 as published by the Free Software Foundation.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Data model class for table components.<br>
+ * Usage:
+ * <pre>
+ * ExtendedTableDataModel<SomeDataType> dataModel = new ExtendedTableDataModel<SomeDataType>(new DataProvider <SomeDataType>());
+ * </pre>
+ * @author pawelgo
+ *
+ */
+public class ExtendedTableDataModel<T> extends ExtendedDataModel implements Serializable{
+
+ private static final long serialVersionUID = 7374505108088114161L;
+
+ private static final Log log = LogFactory.getLog(ExtendedTableDataModel.class);
+
+ private DataProvider<T> dataProvider;
+ private Object rowKey;
+ private List<Object> wrappedKeys = null;
+ //private boolean detached = false;
+ private Map<Object, T> wrappedData = new HashMap<Object, T>();
+
+ public ExtendedTableDataModel(DataProvider<T> dataProvider) {
+ this.dataProvider = dataProvider;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.SerializableDataModel#update()
+ */
+// public void update() {
+// ;
+// }
+
+ /**
+ * This method never called from framework.
+ * (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /**
+ * This method normally called by Visitor before request Data Row.
+ * (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ /**
+ * This is main part of Visitor pattern. Method called by framework many times during request processing.
+ * (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ int rowC = getRowCount();
+ int firstRow = ((SequenceRange) range).getFirstRow();
+ int numberOfRows = ((SequenceRange) range).getRows();
+ if (numberOfRows <= 0) {
+ numberOfRows = rowC;
+ }
+ if (wrappedKeys != null) { // Is this serialized model
+ // Here we just ignore current Rage and use whatever data was saved in serialized model.
+ // Such approach uses much more getByPk() operations, instead of just one request by range.
+ // Concrete case may be different from that, so you can just load data from data provider by range.
+ // We are using wrappedKeys list only to preserve actual order of items.
+ for (Object key : wrappedKeys) {
+ setRowKey(key);
+ visitor.process(context, key, argument);
+ }
+ } else { // if not serialized, than we request data from data provider
+ wrappedKeys = new ArrayList<Object>();
+ int endRow = firstRow + numberOfRows;
+ if (endRow > rowC){
+ endRow = rowC;
+ }
+ for (T item : loadData(firstRow, endRow)) {
+ Object key = getKey(item);
+ wrappedKeys.add(key);
+ wrappedData.put(key, item);
+ visitor.process(context, key, argument);
+ }
+ }
+ }//walk
+
+ /**
+ * Load range of data items from the source.
+ * Starting from startRow, and up to but excluding endRow
+ * @param startRow
+ * @param endRow
+ * @return list of ordered data
+ */
+ protected List<T> loadData(int startRow, int endRow) {
+ if (log.isDebugEnabled())
+ log.debug("load data from range: " + startRow + " - " + endRow);
+ if (startRow < 0){
+ startRow = 0;
+ throw new IllegalArgumentException("Illegal start index value: " + startRow);
+ }
+ int rowCount = getRowCount();
+ if (endRow > rowCount){
+ endRow = rowCount;
+ throw new IllegalArgumentException("Illegal end index value: " + endRow);
+ }
+ //load all from provider and get sublist
+ return dataProvider.getItemsByRange(startRow, endRow);
+ //return dataProvider.getItemsByRange(0, rowCount).subList(startRow, endRow);
+ }//loadData
+
+ /**
+ * This method must return actual data rows count from the Data Provider. It is used by pagination control
+ * to determine total number of data items.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ private Integer rowCount; // better to buffer row count locally
+
+ public int getRowCount() {
+ if (rowCount == null) {
+ rowCount = new Integer(dataProvider.getRowCount());
+ } else {
+ return rowCount.intValue();
+ }
+ return rowCount.intValue();
+ //return dataProvider.getRowCount();
+ }
+
+ /**
+ * This is main way to obtain data row. It is intensively used by framework.
+ * We strongly recommend use of local cache in that method.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public T getRowData() {
+ if (rowKey == null) {
+ return null;
+ } else {
+ return getObjectByKey(rowKey);
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object getKey(T o) {
+ return dataProvider.getKey(o);
+ }
+
+ public T getObjectByKey(Object key) {
+ T t = wrappedData.get(key);
+ if (t == null){
+ t = dataProvider.getItemByKey(key);
+ wrappedData.put(key, t);
+ }
+ return t;
+ }
+
+ private Integer rowIndex;
+
+ /**
+ * Unused rudiment from old JSF staff. (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ public int getRowIndex() {
+ //throw new UnsupportedOperationException();
+ return rowIndex.intValue();
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ //throw new UnsupportedOperationException();
+ this.rowIndex = rowIndex;
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Unused rudiment from old JSF staff.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Never called by framework.
+ * (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ return getRowData() != null;
+ }
+
+ /**
+ * This method suppose to produce SerializableDataModel that will be
+ * serialized into View State and used on a post-back. In current
+ * implementation we just mark current model as serialized. In more
+ * complicated cases we may need to transform data to actually serialized
+ * form.
+ */
+// public SerializableDataModel getSerializableModel(Range range) {
+// if (wrappedKeys != null) {
+// detached = true;
+// // Some activity to detach persistent data from wrappedData map may be taken here.
+// // In that specific case we are doing nothing.
+// return this;
+// } else {
+// return null;
+// }
+// }
+
+ /**
+ * Resets internal cached data. Call this method to reload data from data
+ * provider on first access for data.
+ */
+ public void reset(){
+ wrappedKeys = null;
+ wrappedData.clear();
+ rowCount = null;
+ rowIndex = -1;
+ rowKey = null;
+ }
+
+ public DataProvider<T> getDataProvider() {
+ return dataProvider;
+ }
+
+ public void setDataProvider(DataProvider<T> dataProvider) {
+ this.dataProvider = dataProvider;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ExtendedTableDataModifiableModel.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,131 @@
+/**
+* License Agreement.
+*
+* JBoss RichFaces - Ajax4jsf Component Library
+*
+* Copyright (C) 2008 CompuGROUP Holding AG
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1 as published by the Free Software Foundation.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author pawelgo
+ *
+ */
+public class ExtendedTableDataModifiableModel<T> extends ModifiableModel {
+
+ //private static final Log log = LogFactory.getLog(ExtendedTableDataModifiableModel.class);
+
+ private ExtendedTableDataModel<T> orgModel;
+ private boolean sortNeeded = true;
+ private boolean filterNeeded = true;
+
+ @SuppressWarnings("unchecked")
+ public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider, String var) {
+ super(new ExtendedTableDataModel<T>(dataProvider), var);
+ this.orgModel = (ExtendedTableDataModel<T>)this.originalModel;
+ }
+
+ public ExtendedTableDataModifiableModel(DataProvider<T> dataProvider) {
+ this(dataProvider, null);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ExtendedTableDataModifiableModel(ExtendedTableDataModel<T> dataModel, String var) {
+ super(dataModel, var);
+ this.orgModel = dataModel;
+ }
+
+ @Override
+ public Object getRowKey() {
+ return originalModel.getRowKey();
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ originalModel.setRowKey(key);
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, rowKeys.get(currentRow), argument);
+ }
+ }
+
+ /**
+ * Resets internal cached data. Call this method to reload data from data
+ * provider on first access for data.
+ */
+ public void reset(){
+ orgModel.reset();
+ rowKeys = null;
+ sortNeeded = true;
+ filterNeeded = true;
+ }
+
+ public Object getKey(T o) {
+ return orgModel.getKey(o);
+ }
+
+ public T getObjectByKey(Object key) {
+ return orgModel.getObjectByKey(key);
+ }
+
+ @Override
+ public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
+ if (sortNeeded || filterNeeded){
+ if (var == null){
+ throw new IllegalStateException("\"var\" model attribute can not be null.");
+ }
+ super.modify(filterFields, sortFields);
+ sortNeeded = false;
+ filterNeeded = false;
+ }
+ }
+
+ public void resetSort(){
+ sortNeeded = true;
+ }
+
+ public void resetFilter(){
+ filterNeeded = true;
+ }
+
+ public void setVar(String var){
+ this.var = var;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ListSequenceDataModel.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,162 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ListSequenceDataModel extends ExtendedDataModel {
+
+ private List<?> list;
+ private int index;
+
+ public ListSequenceDataModel(List<?> list) {
+ setWrappedData(list);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ @Override
+ public Object getRowKey() {
+ if(index<0){
+ return null;
+ }
+ return new Integer(index);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ @Override
+ public void setRowKey(Object key) {
+ if(null == key){
+ index = -1;
+ } else {
+ setRowIndex(((Integer) key).intValue());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = list !=null ? list.size() : -1;
+ int currentRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ setRowIndex(currentRow);
+ visitor.process(context, new Integer(currentRow), argument);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ if (list == null) {
+ return (-1);
+ }
+ return list.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ @Override
+ public Object getRowData() {
+ if (!isRowAvailable()) {
+ throw new IllegalArgumentException();
+ } else {
+ return list.get(index);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ @Override
+ public int getRowIndex() {
+ return index;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ @Override
+ public Object getWrappedData() {
+ return list;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ @Override
+ public boolean isRowAvailable() {
+ return list != null && 0 <= index && index < list.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ @Override
+ public void setRowIndex(int rowIndex) {
+ if (rowIndex < -1) {
+ throw new IllegalArgumentException();
+ }
+ index = rowIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ @Override
+ public void setWrappedData(Object data) {
+ if (data == null) {
+ list = null;
+ setRowIndex(-1);
+ } else {
+ list = (List<?>) data;
+ setRowIndex(0);
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/ModifiableModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/ModifiableModel.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,277 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+import org.ajax4jsf.model.SerializableDataModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.model.impl.expressive.JavaBeanWrapper;
+import org.richfaces.model.impl.expressive.ObjectWrapperFactory;
+import org.richfaces.model.impl.expressive.WrappedBeanComparator2;
+import org.richfaces.model.impl.expressive.WrappedBeanFilter;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableModel extends ExtendedDataModel implements Modifiable, LocaleAware {
+
+ protected class RowKeyWrapperFactory extends ObjectWrapperFactory {
+
+ private class ExtendedJavaBeanWrapper extends JavaBeanWrapper {
+
+ private Object key;
+
+ public ExtendedJavaBeanWrapper(Object key, Object o, Map<Object, Object> props) {
+ super(o, props);
+ this.key = key;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+ }
+
+ public RowKeyWrapperFactory(FacesContext context, String var,
+ List<? extends Field> sortOrder) {
+ super(context, var, sortOrder);
+ }
+
+ @Override
+ public JavaBeanWrapper wrapObject(Object key) {
+ originalModel.setRowKey(key);
+ JavaBeanWrapper wrapObject = super.wrapObject(originalModel.getRowData());
+ return new ExtendedJavaBeanWrapper(key, wrapObject.getWrappedObject(), wrapObject.getProperties());
+ }
+
+ @Override
+ public Object unwrapObject(Object wrapper) {
+ return ((ExtendedJavaBeanWrapper) wrapper).getKey();
+ }
+ }
+
+ private static final Log log = LogFactory.getLog(ModifiableModel.class);
+
+ protected List<Object> rowKeys;
+
+ protected ExtendedDataModel originalModel;
+
+ protected String var;
+
+ protected Locale locale = null;
+
+ public ModifiableModel(ExtendedDataModel originalModel, String var) {
+ this.originalModel = originalModel;
+ this.var = var;
+ }
+
+ @Override
+ public void addDataModelListener(DataModelListener listener) {
+ originalModel.addDataModelListener(listener);
+ }
+
+ @Override
+ public DataModelListener[] getDataModelListeners() {
+ return originalModel.getDataModelListeners();
+ }
+
+ public Locale getLocale() {
+ return locale;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ }
+
+ @Override
+ public Object getRowKey() {
+ Object originalModelKey = originalModel.getRowKey();
+ int idx = rowKeys.indexOf(originalModelKey);
+
+ if (originalModelKey != null || idx >= 0) {
+ return idx;
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public void setRowKey(Object key) {
+ Object originalKey = null;
+ if(key != null){
+ int i = (Integer)key;
+ if (i >= 0 && i < rowKeys.size()) {
+ originalKey = rowKeys.get(i);
+ }
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ @Override
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ final SequenceRange seqRange = (SequenceRange) range;
+ int rows = seqRange.getRows();
+ int rowCount = getRowCount();
+ int currentRow = seqRange.getFirstRow();
+ if(rows > 0){
+ rows += currentRow;
+ rows = Math.min(rows, rowCount);
+ } else {
+ rows = rowCount;
+ }
+ for (; currentRow < rows; currentRow++) {
+ visitor.process(context, currentRow, argument);
+ }
+ }
+
+ @Override
+ public int getRowCount() {
+ if (rowKeys == null) {
+ return -1;
+ } else {
+ return rowKeys.size();
+ }
+ }
+
+ @Override
+ public Object getRowData() {
+ return originalModel.getRowData();
+ }
+
+ @Override
+ public int getRowIndex() {
+ return rowKeys.indexOf(originalModel.getRowKey());
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return originalModel.getWrappedData();
+ }
+
+ @Override
+ public boolean isRowAvailable() {
+ return originalModel.isRowAvailable();
+ }
+
+ @Override
+ public void setRowIndex(int rowIndex) {
+ Object originalKey = null;
+ if (rowIndex >= 0 && rowIndex < rowKeys.size()) {
+ originalKey = rowKeys.get(rowIndex);
+ }
+ originalModel.setRowKey(originalKey);
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ originalModel.setWrappedData(data);
+ }
+
+ @Override
+ public SerializableDataModel getSerializableModel(Range range) {
+ return originalModel.getSerializableModel(range);
+ }
+
+ @Override
+ public void removeDataModelListener(DataModelListener listener) {
+ originalModel.removeDataModelListener(listener);
+ }
+
+
+ public void modify(List<FilterField> filterFields, List<SortField2> sortFields) {
+ int rowCount = originalModel.getRowCount();
+
+ if (rowCount > 0) {
+ rowKeys = new ArrayList<Object>(rowCount);
+ } else {
+ rowKeys = new ArrayList<Object>();
+ }
+
+ FacesContext context = FacesContext.getCurrentInstance();
+ try {
+
+ originalModel.walk(context, new DataVisitor() {
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+ originalModel.setRowKey(rowKey);
+ if (originalModel.isRowAvailable()) {
+ rowKeys.add(rowKey);
+ }
+ }
+ }, new SequenceRange(0, -1),
+ null);
+ } catch (IOException e) {
+ log.error(e.getMessage(), e);
+ }
+
+ filter(filterFields);
+ sort(sortFields);
+
+ }
+
+ protected List<Object> filter(List<FilterField> filterFields) {
+ if (filterFields != null && !filterFields.isEmpty()) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ List <Object> filteredCollection = new ArrayList<Object>();
+ ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(context, var, filterFields);
+
+ WrappedBeanFilter wrappedBeanFilter = new WrappedBeanFilter(filterFields, locale);
+ wrapperFactory.wrapList(rowKeys);
+ for (Object object : rowKeys) {
+ if(wrappedBeanFilter.accept((JavaBeanWrapper)object)) {
+ filteredCollection.add(object);
+ }
+ }
+ rowKeys = filteredCollection;
+ wrapperFactory.unwrapList(rowKeys);
+ }
+ return rowKeys;
+ }
+
+ protected void sort(List<SortField2> sortFields) {
+ if (sortFields != null && !sortFields.isEmpty()) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ ObjectWrapperFactory wrapperFactory = new RowKeyWrapperFactory(
+ context, var, sortFields);
+
+ WrappedBeanComparator2 wrappedBeanComparator = new WrappedBeanComparator2(
+ sortFields, locale);
+ wrapperFactory.wrapList(rowKeys);
+ Collections.sort(rowKeys, wrappedBeanComparator);
+ wrapperFactory.unwrapList(rowKeys);
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/impl (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/impl)
Copied: root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/package-info.java (from rev 14980, root/framework/trunk/impl/src/main/java/org/richfaces/model/package-info.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/package-info.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/impl/src/main/java/org/richfaces/model/package-info.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,4 @@
+/**
+ * Models implementation classes
+ */
+package org.richfaces.model;
Copied: root/ui-sandbox/trunk/components/tables/impl/src/test/java/org/richfaces/model/impl/expressive (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/impl/expressive)
Copied: root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/ISimpleToggleListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/ISimpleToggleListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/ISimpleToggleListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/ISimpleToggleListener.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+
+//TODO by nick - denis - add addToggleListener method to component
+public interface ISimpleToggleListener extends FacesListener {
+
+ public void processToggle(SimpleToggleEvent event);
+
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/SimpleToggleEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/SimpleToggleEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/SimpleToggleEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/togglepanels/src/main/java/org/richfaces/event/SimpleToggleEvent.java 2009-07-23 16:55:55 UTC (rev 14986)
@@ -0,0 +1,81 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/*
+ * Created on 11.07.2006
+ */
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author igels
+ */
+public class SimpleToggleEvent extends ActionEvent {
+
+ private static final long serialVersionUID = 5582624805941635421L;
+ private boolean _opened;
+
+ /**
+ * @param source
+ * @param opened
+ */
+ public SimpleToggleEvent(UIComponent source, boolean opened) {
+ super(source);
+ this._opened = opened;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof ISimpleToggleListener || super.isAppropriateListener(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ if (listener instanceof ISimpleToggleListener) {
+ ((ISimpleToggleListener) listener).processToggle(this);
+ } else {
+ super.processListener(listener);
+ }
+
+ }
+
+ /**
+ * @return Returns the _state.
+ */
+ public boolean isIsOpen() {
+ return _opened;
+ }
+
+ /**
+ *
+ * @param opened The state to set
+ */
+ public void setIsOpen(boolean opened) {
+ this._opened = opened;
+ }
+}
\ No newline at end of file
15 years, 5 months
JBoss Rich Faces SVN: r14985 - in root/ui-sandbox/trunk/components: calendar/api/src/main/java/org/richfaces and 55 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 12:41:49 -0400 (Thu, 23 Jul 2009)
New Revision: 14985
Added:
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java
root/ui-sandbox/trunk/components/drag-drop/
root/ui-sandbox/trunk/components/drag-drop/src/
root/ui-sandbox/trunk/components/drag-drop/src/main/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Draggable.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Dropzone.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DnDEvent.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragEvent.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragListener.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropEvent.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropListener.java
root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropSource.java
root/ui-sandbox/trunk/components/fileupload/
root/ui-sandbox/trunk/components/fileupload/src/
root/ui-sandbox/trunk/components/fileupload/src/main/
root/ui-sandbox/trunk/components/fileupload/src/main/java/
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/FileUploadListener.java
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/UploadEvent.java
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/UploadItem.java
root/ui-sandbox/trunk/components/selects/
root/ui-sandbox/trunk/components/selects/src/
root/ui-sandbox/trunk/components/selects/src/main/
root/ui-sandbox/trunk/components/selects/src/main/java/
root/ui-sandbox/trunk/components/selects/src/main/java/org/
root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleDataModel.java
root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleRowKey.java
root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/OrderingListDataModel.java
root/ui-sandbox/trunk/components/tables/
root/ui-sandbox/trunk/components/tables/src/
root/ui-sandbox/trunk/components/tables/src/main/
root/ui-sandbox/trunk/components/tables/src/main/java/
root/ui-sandbox/trunk/components/tables/src/main/java/org/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Column.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Filterable.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Row.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Selectable.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable2.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/extdt/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/scroll/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/sort/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/DataProvider.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ExtendedFilterField.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Field.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/FilterField.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/LocaleAware.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Modifiable.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Ordering.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataModel.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataRange.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SelectionMode.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField2.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortOrder.java
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/filter/
root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/selection/
root/ui-sandbox/trunk/components/tables/src/test/
root/ui-sandbox/trunk/components/tables/src/test/java/
root/ui-sandbox/trunk/components/tables/src/test/java/org/
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/FilterFieldTest.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockDataModel.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockRange.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ModifiableModelTest.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java
root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/SortField2Test.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModel.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java
root/ui-sandbox/trunk/components/tree-model/api/src/test/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Directory.java
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/File.java
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Named.java
root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Project.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedListener.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedListener.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/LastElementAware.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ListRowKey.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/MapDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SequenceDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeDataModel.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNode.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNodeImpl.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRange.java
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRowKey.java
root/ui-sandbox/trunk/components/tree/api/src/test/
root/ui-sandbox/trunk/components/tree/api/src/test/java/
root/ui-sandbox/trunk/components/tree/api/src/test/java/org/
root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/
root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/ClassicTreeModelKeyConversionTest.java
root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/SwingTreeModelKeyConversionTest.java
Log:
Moving component APIs into ui-sandbox
Copied: root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.event;
+
+import java.util.Date;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+public class CurrentDateChangeEvent extends FacesEvent {
+
+
+ private static final long serialVersionUID = -8169207286087810907L;
+ private Date currentDate = null;
+ private String currentDateString = null;
+
+ @Deprecated
+ public CurrentDateChangeEvent(UIComponent component, Date curentDate) {
+ super(component);
+ this.currentDate = curentDate;
+
+ }
+
+ public CurrentDateChangeEvent(UIComponent component, String curentDateString) {
+ super(component);
+ this.currentDateString = curentDateString;
+ }
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+ public void processListener(FacesListener listener) {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ public Date getCurrentDate() {
+ return currentDate;
+ }
+
+ public void setCurrentDate(Date currentDate) {
+ this.currentDate = currentDate;
+ }
+
+ public String getCurrentDateString() {
+ return currentDateString;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/event/CurrentDateChangeListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,36 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Alexej Kushunin - akushunin(a)exadel.com
+ * created 28.08.2007
+ *
+ * Base calendar events interface
+ */
+public interface CurrentDateChangeListener extends FacesListener {
+
+ public void processCurrentDateChange(CurrentDateChangeEvent event);
+
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Draggable.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Draggable.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Draggable.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Draggable.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,135 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.MethodBinding;
+
+import org.richfaces.event.DragListener;
+
+
+/**
+ * Interface for all draggable components. Describe bean properties, implemented by component.
+ * @author shura
+ *
+ */
+public interface Draggable {
+
+ /**
+ * Getter for value parameter, used as key for draggable component.
+ * @return
+ */
+ public Object getDragValue();
+
+ public void setDragValue(Object value);
+
+ /**
+ * Getter for id of component ( instance of {@link UIDragIndicator} ) used for create drag cursor.
+ * @return
+ */
+ public String getDragIndicator();
+
+ /**
+ * @param dragIndicator - id of cursor component
+ */
+ public void setDragIndicator(String dragIndicator);
+
+ /**
+ * Draggable implementation may wish to resolve drag indicator id to clientId itself
+ * @param facesContext {@link FacesContext} instance
+ * @return resolved indicator client id or null
+ * @since 3.1
+ */
+ public String getResolvedDragIndicator(FacesContext facesContext);
+
+ /**
+ * Getter for type of this draggable ( file, mail etc ).
+ * @return
+ */
+ public String getDragType();
+
+ /**
+ * @param dragType
+ */
+ public void setDragType(String dragType);
+
+ /**
+ * Getter for JavaScript event handler, called before start drag operation.
+ * If this handler return false, drag operation is cancelled.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragstart();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragstart(String ondrag);
+
+ /**
+ * Getter for JavaScript event handler; Called when drag operation end.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragend();
+ public void setOndragend(String ondrag);
+
+ /**
+ * Getter for JavaScript event handler; Called when dragged element over the dropzone.
+ * @return javaScript code of event handler.
+ */
+ public String getOndropover();
+ public void setOndropover(String ondropover);
+
+ /**
+ * Getter for JavaScript event handler; Called when dragged element out the dropzone.
+ * @return javaScript code of event handler.
+ */
+ public String getOndropout();
+ public void setOndropout(String ondropout);
+
+ /**
+ * Append drag listener to component listeners collection
+ * @param listener
+ */
+ public void addDragListener(DragListener listener);
+
+ /**
+ * Get array of all Drop Listeners
+ * @return
+ */
+ public DragListener[] getDragListeners();
+
+ /**
+ * Remove drop listener from component listeners array.
+ * @param listener
+ */
+ public void removeDragListener(DragListener listener);
+
+ public void setDragListener(MethodBinding binding);
+ public MethodBinding getDragListener();
+
+ public String getGrabCursors();
+ public void setGrabCursors(String grabCursors);
+
+ public String getGrabbingCursors();
+ public void setGrabbingCursors(String grabbingCursors);
+
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Dropzone.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Dropzone.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Dropzone.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/component/Dropzone.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.event.DropSource;
+
+/**
+ * Base interface for all components, accesible as drop zone.
+ * @author shura
+ *
+ */
+public interface Dropzone extends DropSource {
+
+ /**
+ * Getter for dropType's , accepted by this zone.
+ * @return
+ */
+ public Object getAcceptedTypes();
+
+ public void setAcceptedTypes(Object types);
+
+ /**
+ * Getter for mapping between drop types and indicator states.
+ * @return
+ */
+ public Object getTypeMapping();
+
+ public void setTypeMapping(Object types);
+
+
+ /**
+ * Getter for mapping between drop types and acceptable cursors
+ * @return
+ */
+ public Object getCursorTypeMapping();
+ public void setCursorTypeMapping(Object types);
+
+ /**
+ * Getter for JavaScript event handler, called then drag curcor enter in component area.
+ * If this handler return false, or "declined", drop operation on this component not allowed.
+ * If handler return true or "allowed" , or any other supported indicator states, drop operation
+ * is allowed and corresponding indicator state will be displayed.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragenter();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragenter(String ondrag);
+
+ /**
+ * Getter for JavaScript event handler, called before drag cursor leave component area.
+ * @return javaScript code of event handler.
+ */
+ public String getOndragexit();
+
+ /**
+ * @param dragType
+ */
+ public void setOndragexit(String ondrag);
+
+ public Object getDropValue();
+
+ public void setDropValue(Object o);
+
+ /**
+ * Javascript code called before drop event.
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOndrop();
+
+ /**
+ * @param newOndrop the value to set
+ */
+ public abstract void setOndrop(String newOndrop);
+
+ /**
+ * Javascript handler for event fired on drop even the drop for given type is not available
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract String getOndropend();
+
+ /**
+ * @param newname the value to set
+ */
+ public abstract void setOndropend(String ondropend);
+
+ /**
+ * Getter for the list of comma separated cursors that indicates when acceptable draggable over dropzone
+ */
+ public String getAcceptCursors();
+ public void setAcceptCursors(String acceptCursors);
+
+ /**
+ * Getter for the list of comma separated cursors that indicates when rejectable draggable over dropzone
+ */
+ public String getRejectCursors();
+ public void setRejectCursors(String rejectCursors);
+
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DnDEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DnDEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DnDEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DnDEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+
+/**
+ *
+ * <br /><br />
+ *
+ * Created 12.11.2007
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public abstract class DnDEvent extends FacesEvent {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2455016405742082110L;
+
+ public DnDEvent(UIComponent component) {
+ super(component);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DragEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,102 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.component.Draggable;
+import org.richfaces.component.Dropzone;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.12.2006
+ *
+ */
+public class DragEvent extends DnDEvent {
+
+ private Dropzone dropTarget;
+ private Object acceptedTypes;
+ private Object dropValue;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6179268394391836905L;
+
+ public DragEvent(UIComponent uiComponent) {
+ super(uiComponent);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener faceslistener) {
+ return faceslistener instanceof DragListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener faceslistener) {
+ ((DragListener) faceslistener).processDrag(this);
+ }
+
+ public Object getDragValue() {
+ return ((Draggable) this.getSource()).getDragValue();
+ }
+
+ public Dropzone getDropTarget() {
+ return dropTarget;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+/* public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
+ append("component", getComponent()).append("source", getSource()).append("phaseId", getPhaseId()).
+ append("dragValue", getDragValue()).
+ append("dropTarget", getDropTarget()).
+ append("dropValue", getDropValue()).
+ toString();
+ }
+*/
+ public void setDropTarget(Dropzone dropTarget) {
+ this.dropTarget = dropTarget;
+ }
+
+ public Object getAcceptedTypes() {
+ return acceptedTypes;
+ }
+
+ public void setAcceptedTypes(Object acceptedTypes) {
+ this.acceptedTypes = acceptedTypes;
+ }
+
+ public Object getDropValue() {
+ return dropValue;
+ }
+
+ public void setDropValue(Object dropValue) {
+ this.dropValue = dropValue;
+ }
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DragListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DragListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.12.2006
+ *
+ */
+public interface DragListener extends FacesListener {
+ public void processDrag(DragEvent event);
+
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DropEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,107 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.component.Draggable;
+import org.richfaces.component.Dropzone;
+
+/**
+ * @author shura
+ *
+ */
+public class DropEvent extends DnDEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1660545054556302746L;
+
+ private Draggable draggableSource;
+ private String dragType;
+ private Object dragValue;
+
+ public DropEvent(UIComponent component) {
+ super(component);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof DropListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((DropListener) listener).processDrop(this);
+ }
+
+ /**
+ * @return the dropValue
+ */
+ public Object getDropValue() {
+ return ((Dropzone) this.getSource()).getDropValue();
+ }
+
+ public Draggable getDraggableSource() {
+ return draggableSource;
+ }
+
+ /**
+ * @see java.util.EventObject#toString()
+ */
+/* public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
+ append("component", getComponent()).
+ append("source", getSource()).
+ append("phaseId", getPhaseId()).
+ append("dropValue", getDropValue()).
+ append("draggableSource", getDraggableSource()).
+ append("dragValue", getDragValue()).
+ toString();
+ }
+*/
+ public void setDraggableSource(Draggable draggableSource) {
+ this.draggableSource = draggableSource;
+ }
+
+ public String getDragType() {
+ return dragType;
+ }
+
+ public void setDragType(String dragType) {
+ this.dragType = dragType;
+ }
+
+ public Object getDragValue() {
+ return dragValue;
+ }
+
+ public void setDragValue(Object dragValue) {
+ this.dragValue = dragValue;
+ }
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DropListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,39 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+/**
+ * Listener for process Drop events
+ * @author shura
+ *
+ */
+public interface DropListener extends FacesListener {
+
+ /**
+ * Process event on Drop for this component.
+ * @param event
+ */
+ public void processDrop(DropEvent event);
+
+}
Copied: root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropSource.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/DropSource.java)
===================================================================
--- root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropSource.java (rev 0)
+++ root/ui-sandbox/trunk/components/drag-drop/src/main/java/org/richfaces/event/DropSource.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,54 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.el.MethodBinding;
+
+/**
+ * Interface for component applicable to process drag/drop events.
+ * @author shura
+ *
+ */
+public interface DropSource {
+
+ /**
+ * Append drop listener to component listeners collection
+ * @param listener
+ */
+ public void addDropListener(DropListener listener);
+
+ /**
+ * Get array of all Drop Listeners
+ * @return
+ */
+ public DropListener[] getDropListeners();
+
+ /**
+ * Remove drop listener from component listeners array.
+ * @param listener
+ */
+ public void removeDropListener(DropListener listener);
+
+ public void setDropListener(MethodBinding binding);
+ public MethodBinding getDropListener();
+
+}
Copied: root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/FileUploadListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/FileUploadListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/FileUploadListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/FileUploadListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,29 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.FacesListener;
+
+public interface FileUploadListener extends FacesListener {
+
+ public void processUpload(UploadEvent event);
+}
Copied: root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/UploadEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/UploadEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/UploadEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/event/UploadEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,78 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.event;
+
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.model.UploadItem;
+
+public class UploadEvent extends FacesEvent{
+
+ private static final long serialVersionUID = -7645197191376210068L;
+ private List<UploadItem> uploadItems = null;
+
+ public UploadEvent(UIComponent component, List<UploadItem> uploadItems) {
+ super(component);
+ this.uploadItems = uploadItems;
+ }
+
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return false;
+ }
+
+
+ public void processListener(FacesListener listener) {
+
+ }
+
+ /**Returns UploadItem instance.
+ * Returns first element of list of UploadItems in case of multiple upload.
+ * @return the uploadItem
+ */
+ public UploadItem getUploadItem() {
+ if (uploadItems != null && uploadItems.size() > 0) {
+ return uploadItems.get(0);
+ }
+ return null;
+ }
+
+ /**
+ * Return list of UploadItems
+ * @return the uploadItem
+ * @since 3.2.2
+ */
+ public List<UploadItem> getUploadItems() {
+ return uploadItems;
+ }
+
+ /** Return true if multiple files were uploaded with form
+ * @return boolean
+ * @since 3.2.2
+ */
+ public boolean isMultiUpload() {
+ return (uploadItems != null && uploadItems.size() > 1);
+ }
+}
Copied: root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/UploadItem.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/UploadItem.java)
===================================================================
--- root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/UploadItem.java (rev 0)
+++ root/ui-sandbox/trunk/components/fileupload/src/main/java/org/richfaces/model/UploadItem.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,122 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.File;
+import java.io.Serializable;
+
+/**
+ * Class provides object holder for file uploaded.
+ * Instance of this type will be returned by UploadEvent after appropriate listener called after uploading has been completed.
+ * @author "Andrey Markavtsov"
+ *
+ */
+public class UploadItem implements Serializable{
+
+ /**
+ * Serial id
+ */
+ private static final long serialVersionUID = -111723029745124147L;
+
+ /** Users file name */
+ private String fileName;
+
+ /** Content type */
+ private String contentType;
+
+ /** java.io.File instance */
+ private File file;
+
+ /** File byte content */
+ private byte [] bytes;
+
+ /** File size */
+ private int fileSize;
+
+ /**
+ * Constructor for the UploadItem
+ */
+ public UploadItem(String fileName, int fileSize, String contentType, Object file) {
+ this.fileName = fileName;
+ this.contentType = contentType;
+ this.fileSize = fileSize;
+ if (null != file) {
+ if (file.getClass().isAssignableFrom(File.class)) {
+ this.file = (File) file;
+ } else if (file.getClass().isAssignableFrom(byte[].class)) {
+ this.bytes = (byte[]) file;
+ }
+ }
+ }
+
+ /**
+ * Return true if file is holding as java.io.File type.
+ * If true getFile method should be invoked to get file uploaded.
+ * In another case getData method should be invoked to get file's bytes.
+ * @return
+ */
+ public boolean isTempFile () {
+ return (null != file);
+ }
+
+ /**
+ * This method should called only in case of TRUE value returned by {@link #isTempFile()} method.
+ * Otherwise null value will be returned by this method.
+ * @return the file
+ */
+ public File getFile() {
+ return file;
+ }
+
+ /**
+ * This method should called only in case of FALSE value returned by {@link #isTempFile()} method.
+ * Otherwise null value will be returned by this method.
+ * @return the bytes
+ * @throws Exception
+ */
+ public byte[] getData() {
+ return bytes;
+ }
+
+ /**
+ * @return the fileName
+ */
+ public String getFileName() {
+ return fileName;
+ }
+
+ /**
+ * @return the contentType
+ */
+ public String getContentType() {
+ return contentType;
+ }
+
+ /**
+ * @return the fileSize
+ */
+ public int getFileSize() {
+ return fileSize;
+ }
+
+
+}
Copied: root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,168 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModel;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceDataModel;
+
+/**
+ * Dual map-based extended data model for model-translating components like list shuttle
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleDataModel extends ExtendedDataModel {
+
+ private ListShuttleRowKey rowKey;
+
+ private SequenceDataModel sourceModel;
+ private SequenceDataModel targetModel;
+
+ private Map<Object, Object> data;
+
+ private Object wrappedData;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ this.rowKey = (ListShuttleRowKey) key;
+ }
+
+ public void walk(final FacesContext context, final DataVisitor visitor, final Range range,
+ final Object argument) throws IOException {
+ if (data != null) {
+ Iterator<Entry<Object, Object>> iterator = data.entrySet().iterator();
+
+ while (iterator.hasNext()) {
+ Entry<Object, Object> entry = iterator.next();
+
+ visitor.process(context, entry.getKey(), argument);
+ }
+
+ } else {
+ sourceModel.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ ListShuttleRowKey key = new ListShuttleRowKey(rowKey, true);
+ visitor.process(context, key, argument);
+ }
+ }, range, argument);
+
+ targetModel.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+
+ ListShuttleRowKey key = new ListShuttleRowKey(rowKey, false);
+ visitor.process(context, key, argument);
+ }
+
+ }, range, argument);
+ }
+ }
+
+ public int getRowCount() {
+ if (data != null) {
+ return data.size();
+ } else {
+ return sourceModel.getRowCount() + targetModel.getRowCount();
+ }
+ }
+
+ public Object getRowData() {
+ if (data != null) {
+ return data.get(rowKey);
+ } else {
+ if (this.rowKey != null) {
+ if (this.rowKey.isSource()) {
+ return sourceModel.getRowData();
+ } else {
+ return targetModel.getRowData();
+ }
+ } else {
+ return null;
+ }
+ }
+ }
+
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ public boolean isRowAvailable() {
+ if (data != null) {
+ return data.containsKey(rowKey);
+ } else {
+ if (rowKey != null) {
+ if (rowKey.isSource()) {
+ return sourceModel.isRowAvailable();
+ } else {
+ return targetModel.isRowAvailable();
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ public void setRowIndex(int rowIndex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWrappedData(Object data) {
+ this.rowKey = null;
+ this.wrappedData = data;
+
+ if (data instanceof Map) {
+ this.data = (Map<Object, Object>) data;
+ } else {
+ DataModel[] models = (DataModel[]) data;
+ this.sourceModel = new SequenceDataModel(models[0]);
+ this.targetModel = new SequenceDataModel(models[1]);
+ }
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleRowKey.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ListShuttleRowKey.java)
===================================================================
--- root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleRowKey.java (rev 0)
+++ root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/ListShuttleRowKey.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,99 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * Special type of row key containing information on item origin and new placement
+ *
+ * @author Nick Belaevski
+ *
+ */
+public class ListShuttleRowKey implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 3308741255288495879L;
+
+ private boolean source;
+
+ private boolean facadeSource;
+
+ private Object rowKey;
+
+ public boolean isSource() {
+ return source;
+ }
+
+ public boolean isFacadeSource() {
+ return facadeSource;
+ }
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((rowKey == null) ? 0 : rowKey.hashCode());
+ result = prime * result + (source ? 1231 : 1237);
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ListShuttleRowKey other = (ListShuttleRowKey) obj;
+ if (rowKey == null) {
+ if (other.rowKey != null)
+ return false;
+ } else if (!rowKey.equals(other.rowKey))
+ return false;
+ if (source != other.source)
+ return false;
+ return true;
+ }
+
+ public String toString() {
+ return (source ? "" : "t") + rowKey.toString();
+ }
+
+ public ListShuttleRowKey(Object rowKey, boolean source) {
+ super();
+ this.rowKey = rowKey;
+ this.source = source;
+ this.facadeSource = source;
+ }
+
+ public ListShuttleRowKey(Object rowKey, boolean source, boolean facadeSource) {
+ super();
+ this.rowKey = rowKey;
+ this.source = source;
+ this.facadeSource = facadeSource;
+ }
+}
Copied: root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/OrderingListDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/OrderingListDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/OrderingListDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/selects/src/main/java/org/richfaces/model/OrderingListDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,101 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+/**
+ * Map-based extended data model for model-translating components like ordering list
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 07.11.2007
+ *
+ */
+public class OrderingListDataModel extends ExtendedDataModel {
+
+ private Map<Object, Object> data;
+
+ private Object rowKey;
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object rowKey) {
+ this.rowKey = rowKey;
+ }
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ Set<Entry<Object,Object>> entrySet = data.entrySet();
+ Iterator<Entry<Object, Object>> iterator = entrySet.iterator();
+
+ while (iterator.hasNext()) {
+ Entry<Object, Object> entry = iterator.next();
+
+ visitor.process(context, entry.getKey(), argument);
+ }
+ }
+
+ public int getRowCount() {
+ return data.size();
+ }
+
+ public Object getRowData() {
+ return data.get(rowKey);
+ }
+
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Object getWrappedData() {
+ return data;
+ }
+
+ public boolean isRowAvailable() {
+ return data.containsKey(rowKey);
+ }
+
+ public void setRowIndex(int rowIndex) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setWrappedData(Object data) {
+ this.rowKey = null;
+ this.data = (Map<Object, Object>) data;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Column.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Column.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Column.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Column.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import javax.el.MethodExpression;
+
+import org.richfaces.model.Ordering;
+
+/**
+ * Marker interface for all components used as column in UIDataTable
+ * @author shura
+ *
+ */
+public interface Column {
+
+
+ /**
+ * Out this column on new row
+ * @parameter
+ * @return the acceptClass
+ */
+ public abstract boolean isBreakBefore();
+
+ /**
+ * @param newBreakBefore the value to set
+ */
+ public abstract void setBreakBefore(boolean newBreakBefore);
+
+
+ /**
+ * The column allows data sorting
+ * @return
+ */
+ public abstract boolean isSortable();
+
+ public abstract void setSortable(boolean sortable);
+
+ /**
+ * expression used for column sorting.
+ * literal value is treated as property of data object
+ * EL-expression is evaluated on every data row
+ * @param sortExpression
+ */
+ public abstract void setSortExpression(String sortExpression);
+ public abstract String getSortExpression();
+
+ /**
+ * SortOrder is an enumeration of the possible sort orderings.
+ *
+ * @param sortOrder
+ */
+ public abstract void setSortOrder(Ordering sortOrder);
+ public abstract Ordering getSortOrder();
+
+ public abstract void setFilterMethod(MethodExpression methodExpression);
+ public abstract MethodExpression getFilterMethod();
+
+ public abstract void setFilterValue(String filterValue);
+ public abstract String getFilterValue();
+
+ public abstract boolean isSelfSorted();
+ public abstract void setSelfSorted(boolean selfSorted);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Filterable.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Filterable.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Filterable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Filterable.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import java.util.List;
+
+import org.richfaces.model.FilterField;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Filterable {
+
+ public List<FilterField> getFilterFields();
+
+ public void setFilterFields(List<FilterField> filterFields);
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Row.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Row.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Row.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Row.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component;
+
+import java.util.Iterator;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * Marker interface for table columns, rendered as entire row.
+ * @author shura
+ *
+ */
+public interface Row extends Column {
+
+ /**
+ * Get iterator for all columns contained in this row.
+ * @return
+ */
+ public Iterator<UIComponent> columns();
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Selectable.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Selectable.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Selectable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Selectable.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,32 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import org.richfaces.model.selection.Selection;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Selectable {
+ public Selection getSelection();
+ public void setSelection (Selection selection);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,23 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/component/Sortable.java,v $
+ * $Revision: 1.1 $
+ */
+
+package org.richfaces.component;
+
+import org.richfaces.model.SortOrder;
+
+
+/**
+ * @author Maksim Kaszynski
+ * Base interface for sort capable components
+ */
+public interface Sortable {
+ public SortOrder getSortOrder();
+ public void setSortOrder(SortOrder sortOrder);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable2.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/Sortable2.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable2.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/component/Sortable2.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.component;
+
+import java.util.List;
+
+import org.richfaces.model.SortField2;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface Sortable2 {
+
+ public List<SortField2> getSortFields();
+
+ public void setSortFields(List<SortField2> sortFields);
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/ScrollableGridViewEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,70 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class ScrollableGridViewEvent extends AttributedEvent {
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7417387605074667926L;
+ /**
+ * number of rows to update
+ */
+ protected int rows;
+ /**
+ * start position of update
+ */
+ protected int first;
+
+
+ public ScrollableGridViewEvent(UIComponent component, int rows, int first) {
+ super(component);
+ this.rows = rows;
+ this.first = first;
+ }
+
+ public int getFirst() {
+ return first;
+ }
+
+ public int getRows() {
+ return rows;
+ }
+
+ public void setFirst(int first) {
+ this.first = first;
+ }
+
+ public void setRows(int rows) {
+ this.rows = rows;
+ }
+
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/extdt (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/extdt)
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/scroll (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/scroll)
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/event/sort (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/sort)
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/DataProvider.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/DataProvider.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/DataProvider.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/DataProvider.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,68 @@
+/**
+* License Agreement.
+*
+* JBoss RichFaces - Ajax4jsf Component Library
+*
+* Copyright (C) 2008 CompuGROUP Holding AG
+*
+* This library is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License version 2.1 as published by the Free Software Foundation.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+package org.richfaces.model;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * DataProvider is an interface that defines methods for manage loading data.<br>
+ * Usage:
+ * <pre>
+ * DataProvider<SomeDataType> dataProvider = new DataProvider<SomeDataType>();
+ * </pre>
+ * @author pawelgo
+ *
+ */
+public interface DataProvider<T> extends Serializable {
+
+ /**
+ * Get number of all rows.
+ * @return number of rows.
+ */
+ public int getRowCount();
+
+ /**
+ * Loads elements from given range.
+ * Starting from startRow, and up to but excluding endRow.
+ * @param firstRow first row to load
+ * @param endRow end row to load
+ * @return element list
+ */
+ public List<T> getItemsByRange(int firstRow, int endRow);
+
+ /**
+ * Load single element by given key.
+ * @param key element key to be loaded.
+ * @return element or null, if not found
+ */
+ public T getItemByKey(Object key);
+
+ /**
+ * Get element key.
+ * If key is not instance of Integer or org.richfaces.model.ScrollableTableDataModel.SimpleRowKey,
+ * it is necessary to implement javax.faces.convert.Converter for key type.
+ * @param item element, which key to be get
+ * @return element key
+ */
+ public Object getKey(T item);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ExtendedFilterField.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ExtendedFilterField.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ExtendedFilterField.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ExtendedFilterField.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,50 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.el.Expression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ExtendedFilterField extends FilterField{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5443560922389498666L;
+
+ private String filterValue;
+
+ public ExtendedFilterField(Expression expression, String filterValue) {
+ super(expression);
+ this.filterValue = filterValue;
+ }
+
+ public ExtendedFilterField(Expression expression) {
+ this(expression, "");
+ }
+
+ public String getFilterValue() {
+ return filterValue;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Field.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/Field.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Field.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Field.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,75 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+import javax.el.Expression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public abstract class Field implements Serializable{
+
+ private static final long serialVersionUID = 7576046308828980778L;
+
+ private Expression expression;
+
+ public Field(Expression expression) {
+ this.expression = expression;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Field other = (Field) obj;
+ if (expression == null) {
+ if (other.expression != null)
+ return false;
+ } else {
+ return expression.equals(other.expression);
+ }
+ return true;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((expression == null) ? 0 : expression.hashCode());
+ return result;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/FilterField.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/FilterField.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/FilterField.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/FilterField.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,37 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.el.Expression;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FilterField extends Field{
+
+ private static final long serialVersionUID = -5453359866996963829L;
+
+ public FilterField(Expression expression) {
+ super(expression);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/LocaleAware.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/LocaleAware.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/LocaleAware.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/LocaleAware.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,38 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.Locale;
+
+/**
+ * Models that are based on locale-dependent operations should implement this interface
+ *
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public interface LocaleAware {
+
+ public Locale getLocale();
+
+ public void setLocale(Locale locale);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Modifiable.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/Modifiable.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Modifiable.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Modifiable.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,32 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.util.List;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public interface Modifiable{
+
+ void modify(List<FilterField> filterFields, List<SortField2> sortFields);
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Ordering.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/Ordering.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Ordering.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/Ordering.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,31 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+/**
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+public enum Ordering {
+ ASCENDING,
+ DESCENDING,
+ UNSORTED
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,267 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Base class for data models
+ * Subclasses must implement {@link #loadData(int, int, SortOrder)}
+ * For certain features (like selection and sorting) to work correctly together,
+ * both {@link #getId(Object)} and {@link #getObjectById(Object)}
+ * methods need to be overriden
+ *
+ * @author Maksim Kaszynski
+ *
+ */
+public abstract class ScrollableTableDataModel<T> extends ExtendedDataModel {
+
+ /**
+ * Simple implementation - index-based row key
+ * @author Maksim Kaszynski
+ *
+ */
+ public static class SimpleRowKey extends Number implements Serializable{
+
+ private static final long serialVersionUID = 1L;
+
+ public static final String PREFIX = "srk";
+ private int i;
+
+ public SimpleRowKey(int i) {
+ super();
+ this.i = i;
+ }
+
+ public int intValue() {
+ return i;
+ }
+
+ public String toString() {
+ return PREFIX + String.valueOf(i);
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + i;
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SimpleRowKey other = (SimpleRowKey) obj;
+ if (i != other.i)
+ return false;
+ return true;
+ }
+ @Override
+ public double doubleValue() {
+ return i;
+ }
+ @Override
+ public float floatValue() {
+ return i;
+ }
+ @Override
+ public long longValue() {
+ return i;
+ }
+
+ }
+
+
+ private static final Log log = LogFactory.getLog(ScrollableTableDataModel.class);
+
+ private Object rowKey;
+
+ private Map<Object, T> mapping;
+
+ protected SortOrder lastSortOrder;
+
+
+ /**
+ * Load range of data items from the source.
+ * Starting from startRow, and up to but excluding endRow
+ * @param startRow
+ * @param endRow
+ * @param sortOrder
+ * @return list of ordered data
+ */
+ public abstract List<T> loadData(int startRow, int endRow, SortOrder sortOrder);
+
+
+ /**
+ * Load data range, and iterate over it
+ */
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ if (log.isTraceEnabled()) {
+ log.trace("Starting walk");
+ }
+
+ ScrollableTableDataRange sequenceRange = (ScrollableTableDataRange) range;
+
+ int startIndex = sequenceRange.getFirst();
+ int last = sequenceRange.getLast();
+
+ lastSortOrder = sequenceRange.getSortOrder();
+
+ List<T> objects = loadData(startIndex, last, lastSortOrder);
+
+ mapping = new HashMap<Object, T>();
+
+ for (int i = 0; i < objects.size(); i++,startIndex++) {
+ T data = objects.get(i);
+ Object key = getId(data);
+
+ if (key == null) {
+ key = new SimpleRowKey(startIndex);
+ }
+
+ mapping.put(key, data);
+
+ visitor.process(context, key, argument);
+
+ }
+
+ if (log.isTraceEnabled()) {
+ log.trace("Ending walk");
+ }
+
+ }
+
+
+ /**
+ * This method is the reverse of {@link #getId(Object)}
+ * If you override this method, you need to override {@link #getId(Object)} as well
+ * @param id
+ * @return
+ */
+ public T getObjectById(Object id) {
+
+ if (id instanceof SimpleRowKey) {
+ int i = ((SimpleRowKey) id).intValue();
+
+ List<T> l = loadData(i, i + 1, lastSortOrder);
+
+ return l.get(0);
+
+ }
+
+ return null;
+ }
+
+ /**
+ * Implementations may override it to provide domain-specific searches
+ * Id should be serializable
+ * Default implementation returns <code>null</code> anyway
+ * If you override this method, you need to override {@link #getObjectById(Object)} as well
+ * @param o
+ * @return
+ */
+ public Object getId(T o) {
+ return null;
+ }
+
+
+ public Object getRowData() {
+
+ if (mapping != null && mapping.containsKey(rowKey)) {
+ return mapping.get(rowKey);
+ } else {
+ return loadAndMap(rowKey);
+ }
+
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public int getRowIndex() {
+ return -1;
+ }
+
+ /**
+ * Quite simple implementation - data will be cached, so the call will be cheap
+ */
+ public boolean isRowAvailable() {
+ return getRowData() != null;
+ }
+
+ /**
+ * Row indexes navigation is no longer supported
+ */
+ public void setRowIndex(int index) {
+ //if(index != -1)
+ //throw new UnsupportedOperationException("setRowIndex");
+ //setRowKey(null);
+ }
+
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object key) {
+ rowKey = key;
+ }
+
+ private Object loadAndMap(Object id) {
+
+ if (log.isTraceEnabled()) {
+ log.trace("loadAndMap " + id);
+ }
+
+ T t = getObjectById(id);
+ if (t != null) {
+ if (mapping == null) {
+ mapping = new HashMap<Object, T>();
+ }
+ mapping.put(id, t);
+ }
+ return t;
+ }
+ /*
+ * FIXME: This method is most likely redundant
+ public void setSortOrder(SortOrder sortOrder) {
+ lastSortOrder = sortOrder;
+ }
+ */
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataRange.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ScrollableTableDataRange.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataRange.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/ScrollableTableDataRange.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,121 @@
+/*
+ * Copyright
+ * Copyright (c) Exadel,Inc. 2006
+ * All rights reserved.
+ *
+ * History
+ * $Source: /cvs-master/intralinks-jsf-comps/components/data-view-grid/src/component/com/exadel/jsf/model/ScrollableTableDataRange.java,v $
+ * $Revision: 1.7 $
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * Iteration range for Scrollable Grid
+ * @author Maksim Kaszynski
+ * @modified by Anton Belevich
+ */
+public class ScrollableTableDataRange extends SequenceRange implements Serializable{
+
+ private static final long serialVersionUID = -6675002421400464892L;
+
+ private SortOrder sortOrder;
+
+ public ScrollableTableDataRange() {
+ super();
+ }
+
+ public ScrollableTableDataRange(int first, int last, SortOrder sortOrder) {
+ super(first, last > 0 ? last - first : -1);
+ this.sortOrder = sortOrder;
+ }
+
+ /**
+ * @return the bufferSize
+ */
+ public int getLast() {
+ return getFirstRow() + getRows();
+ }
+ /**
+ * @param bufferSize the bufferSize to set
+ */
+ public void setLast(int lastRow) {
+ setRows(lastRow > 0 ? lastRow - getFirstRow() : -1);
+ }
+ /**
+ * @return the first
+ */
+ public int getFirst() {
+ return getFirstRow();
+ }
+ /**
+ * @param first the first to set
+ */
+ public void setFirst(int first) {
+ setFirstRow(first);
+ }
+
+ public SortOrder getSortOrder() {
+ return sortOrder;
+ }
+
+ public void setSortOrder(SortOrder sortOrder) {
+ this.sortOrder = sortOrder;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + getFirstRow();
+ result = prime * result + getRows();
+ result = prime * result
+ + ((sortOrder == null) ? 0 : sortOrder.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ ScrollableTableDataRange other = (ScrollableTableDataRange) obj;
+ if (getFirstRow() != other.getFirstRow())
+ return false;
+ if (getRows() != other.getRows())
+ return false;
+ if (sortOrder == null) {
+ if (other.sortOrder != null)
+ return false;
+ } else if (!sortOrder.equals(other.sortOrder))
+ return false;
+ return true;
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out)
+ throws IOException {
+
+ out.defaultWriteObject();
+
+ out.writeInt(getFirstRow());
+ out.writeInt(getRows());
+ }
+
+ private void readObject(java.io.ObjectInputStream in)
+ throws IOException, ClassNotFoundException {
+
+ in.defaultReadObject();
+
+ setFirstRow(in.readInt());
+ setRows(in.readInt());
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SelectionMode.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SelectionMode.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SelectionMode.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SelectionMode.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,36 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+/**
+ *
+ * @author Konstantin Mishin
+ *
+ */
+public enum SelectionMode {
+ none,
+ single,
+ multi;
+
+ public boolean isSelectionEnabled() {
+ return !equals(none);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SortField.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,93 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * Sort field is the piece of {@link SortOrder}
+ * @author Maksim Kaszynski
+ *
+ */
+public class SortField implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private String name = null;
+ private Boolean ascending = null;
+
+
+
+ public SortField(String name, Boolean ascending) {
+ super();
+ this.name = name;
+ this.ascending = ascending;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Boolean getAscending() {
+ return ascending;
+ }
+
+ public void setAscending(Boolean ascending) {
+ this.ascending = ascending;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((ascending == null) ? 0 : ascending.hashCode());
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SortField other = (SortField) obj;
+ if (ascending == null) {
+ if (other.ascending != null)
+ return false;
+ } else if (!ascending.equals(other.ascending))
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField2.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SortField2.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField2.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortField2.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,78 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.el.Expression;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SortField2 extends Field{
+
+ private static final long serialVersionUID = 4578290842517554179L;
+
+ private Ordering ordering;
+
+ public SortField2(Expression expression) {
+ super(expression);
+ }
+
+ public SortField2(Expression expression, Ordering ordering) {
+ super(expression);
+ this.ordering = ordering;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result
+ + ((ordering == null) ? 0 : ordering.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!super.equals(obj))
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ SortField2 other = (SortField2) obj;
+ if (ordering == null) {
+ if (other.ordering != null)
+ return false;
+ } else if (!ordering.equals(other.ordering))
+ return false;
+ return true;
+ }
+
+ public Ordering getOrdering() {
+ return ordering;
+ }
+
+ public void setOrdering(Ordering ordering) {
+ this.ordering = ordering;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortOrder.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SortOrder.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortOrder.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/SortOrder.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,91 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.Serializable;
+import java.util.Arrays;
+/**
+ * Class representing grid sort order
+ * Sort Order is the combination of {@link SortField}
+ * Order of occurrence of sort fields must be maintained
+ * to guarantee stable sorting
+ * @author Maksim Kaszynski
+ */
+public class SortOrder implements Serializable {
+
+ private static final long serialVersionUID = 2423450561570551363L;
+
+ private static int hashCode(Object[] array) {
+ final int prime = 31;
+ if (array == null)
+ return 0;
+ int result = 1;
+ for (int index = 0; index < array.length; index++) {
+ result = prime * result
+ + (array[index] == null ? 0 : array[index].hashCode());
+ }
+ return result;
+ }
+
+ private SortField [] fields;
+
+ public SortOrder() {
+
+ }
+
+ public SortOrder(SortField[] fields) {
+ super();
+ this.fields = fields;
+ }
+
+
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final SortOrder other = (SortOrder) obj;
+ if (!Arrays.equals(fields, other.fields))
+ return false;
+ return true;
+ }
+
+ public SortField[] getFields() {
+ return fields;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + SortOrder.hashCode(fields);
+ return result;
+ }
+
+ public void setFields(SortField[] fields) {
+ this.fields = fields;
+ }
+
+
+
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/filter (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/filter)
Copied: root/ui-sandbox/trunk/components/tables/src/main/java/org/richfaces/model/selection (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/selection)
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/FilterFieldTest.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/FilterFieldTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/FilterFieldTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/FilterFieldTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,87 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import javax.el.ValueExpression;
+
+import junit.framework.TestCase;
+
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class FilterFieldTest extends TestCase {
+
+ private Field field;
+ private ValueExpression expression;
+
+ /**
+ * @param name
+ */
+ public FilterFieldTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ expression = EasyMock.createNiceMock(ValueExpression.class);
+ field = new FilterField(expression);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ field = null;
+ expression = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.FilterField#FilterField(javax.el.ValueExpression)}.
+ */
+ public final void testFilterField() {
+ Field filterField = new FilterField(expression);
+ assertEquals(filterField, field);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.Field#hashCode()}.
+ */
+ public final void testHashCode() {
+ Field filterField = new FilterField(expression);
+ assertEquals(filterField.hashCode(), field.hashCode());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.Field#equals(java.lang.Object)}.
+ */
+ public final void testEqualsObject() {
+ Field filterField = new FilterField(null);
+ assertFalse(filterField.equals(field));
+ filterField.setExpression(expression);
+ assertTrue(filterField.equals(field));
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.Field#getExpression()}.
+ */
+ public final void testGetExpression() {
+ assertSame(field.getExpression(), expression);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.Field#setExpression(javax.el.ValueExpression)}.
+ */
+ public final void testSetExpression() {
+ field.setExpression(null);
+ assertNull(field.getExpression());
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ListSequenceDataModelTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,133 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.SequenceRange;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ListSequenceDataModelTest extends TestCase {
+
+ private List<Integer> list;
+ private ListSequenceDataModel model;
+ private ListSequenceDataModel nullModel;
+
+ /**
+ * @param name
+ */
+ public ListSequenceDataModelTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ list = new ArrayList<Integer>();
+ for (int i = 0; i < 10; i++) {
+ list.add(new Integer(i));
+ }
+ model = new ListSequenceDataModel(list);
+ nullModel = new ListSequenceDataModel(null);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ nullModel = null;
+ model = null;
+ list = null;
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#isRowAvailable()}.
+ */
+ public final void testIsRowAvailable() {
+ assertFalse(nullModel.isRowAvailable());
+ assertTrue(model.isRowAvailable());
+ model.setRowIndex(-1);
+ assertFalse(model.isRowAvailable());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#getRowCount()}.
+ */
+ public final void testGetRowCount() {
+ assertEquals(model.getRowCount(), list.size());
+ assertEquals(nullModel.getRowCount(), -1);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#setRowIndex()}
+ * and {@link org.richfaces.model.ListSequenceDataModel#getRowIndex()}.
+ */
+ public final void testRowIndex() {
+ int i = 3;
+ model.setRowIndex(i);
+ assertEquals(model.getRowIndex(), i);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#setRowKey(java.lang.Object)}
+ * and {@link org.richfaces.model.ListSequenceDataModel#getRowKey(java.lang.Object)}.
+ */
+ public final void testRowKey() {
+ Integer i = 3;
+ model.setRowKey(i);
+ assertEquals(model.getRowKey(), i);
+ model.setRowKey(null);
+ assertNull(model.getRowKey());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}
+ * and {@link org.richfaces.model.ListSequenceDataModel#getRowData()}.
+ */
+ public final void testWalk() {
+ DataVisitor visitor = new DataVisitor(){
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+ Object key = model.getRowKey();
+ model.setRowKey(rowKey);
+ assertEquals(model.getRowData(), list.get(((Integer)rowKey).intValue()));
+ model.setRowKey(key);
+ }
+ };
+ try {
+ SequenceRange range = new SequenceRange(0, -1);
+ model.walk(null, visitor, range, null);
+ range = new SequenceRange(0, 5);
+ model.walk(null, visitor, range, null);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ListSequenceDataModel#ListSequenceDataModel(java.util.List)},
+ * {@link org.richfaces.model.ListSequenceDataModel#setWrappedData(java.lang.Object)}
+ * and {@link org.richfaces.model.ListSequenceDataModel#getWrappedData()} .
+ */
+ public final void testListSequenceDataModel() {
+ assertNull(nullModel.getWrappedData());
+ ListSequenceDataModel dataModel = new ListSequenceDataModel(list);
+ assertSame(dataModel.getWrappedData(), model.getWrappedData());
+
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockDataModel.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/MockDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,170 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.ajax4jsf.model.SequenceRange;
+
+/**
+ * @author shura
+ *
+ */
+public class MockDataModel extends ExtendedDataModel {
+
+ public static final int ROWS = 10;
+
+ private int rowIndex = 0;
+
+ private int minRow = 0;
+
+ private int maxRow = ROWS;
+
+ private Object wrappedData;
+ /**
+ * @return the maxRow
+ */
+ public int getMaxRow() {
+ return maxRow;
+ }
+
+ /**
+ * @param maxRow the maxRow to set
+ */
+ public void setMaxRow(int maxRow) {
+ this.maxRow = maxRow;
+ }
+
+ /**
+ * @return the minRow
+ */
+ public int getMinRow() {
+ return minRow;
+ }
+
+ /**
+ * @param minRow the minRow to set
+ */
+ public void setMinRow(int minRow) {
+ this.minRow = minRow;
+ }
+
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) throws IOException {
+ int first=0;
+ int count=ROWS;
+ if (range instanceof MockRange) {
+ MockRange mockRange = (MockRange) range;
+ count = mockRange.getCount();
+ } else if (range instanceof SequenceRange) {
+ SequenceRange seqRange = (SequenceRange) range;
+ first = seqRange.getFirstRow();
+ int rows = seqRange.getRows();
+ if(rows>0){
+ count = rows+first;
+ }
+ }
+ for(int row = first; row < count && row < ROWS;row++){
+ visitor.process(context, new Integer(row), argument);
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ // TODO Auto-generated method stub
+ return rowIndex<0?null:new Integer(rowIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.ajax.repeat.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ if(null == key){
+ rowIndex = -1;
+ } else {
+ rowIndex = ((Integer) key).intValue();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ // TODO Auto-generated method stub
+ return getMaxRow();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public Object getRowData() {
+ // TODO Auto-generated method stub
+ return isRowAvailable()?String.valueOf(rowIndex):null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ public int getRowIndex() {
+ // TODO Auto-generated method stub
+ return rowIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ // TODO Auto-generated method stub
+ return wrappedData;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ // TODO Auto-generated method stub
+ return rowIndex>=getMinRow() && rowIndex<getMaxRow();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ this.rowIndex = rowIndex;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ wrappedData = data;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockRange.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/MockRange.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockRange.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/MockRange.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,41 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import org.ajax4jsf.model.Range;
+
+/**
+ * @author shura
+ *
+ */
+public class MockRange implements Range {
+
+ private int count;
+
+ public MockRange(int count) {
+ this.count = count;
+ }
+
+ public int getCount(){
+ return count;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ModifiableModelTest.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/ModifiableModelTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ModifiableModelTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ModifiableModelTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,107 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.LinkedList;
+import java.util.List;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+import javax.faces.model.DataModelListener;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.SequenceRange;
+import org.easymock.classextension.EasyMock;
+import org.richfaces.test.AbstractFacesTest;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class ModifiableModelTest extends AbstractFacesTest {
+
+ private ModifiableModel model;
+ private ExtendedDataModel originalModel;
+ private String var;
+ private List<FilterField> filterFields;
+ private List<SortField2> sortFields;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ setupFacesRequest();
+ var = "var";
+ originalModel = new MockDataModel();
+ filterFields = new LinkedList<FilterField>();
+ sortFields = new LinkedList<SortField2>();
+ model = new ModifiableModel(originalModel, var);
+ model.modify(filterFields, sortFields);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ model = null;
+ var = null;
+ filterFields = null;
+ sortFields = null;
+ originalModel = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ModifiableModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)}.
+ */
+ public final void testWalk() {
+ SequenceRange range = new SequenceRange(0, -1);
+ DataVisitor visitor = new DataVisitor(){
+ public void process(FacesContext context, Object rowKey,
+ Object argument) throws IOException {
+ Object key = model.getRowKey();
+ model.setRowKey(rowKey);
+ Object key2 = originalModel.getRowKey();
+ originalModel.setRowKey(rowKey);
+ assertEquals(model.getRowData(), originalModel.getRowData());
+ model.setRowKey(key);
+ originalModel.setRowKey(key2);
+ }
+ };
+ try {
+ model.walk(null, visitor, range, null);
+ ValueExpression expression =
+ facesContext.getApplication().getExpressionFactory().createValueExpression(Boolean.TRUE, Boolean.class);
+ filterFields.add(new FilterField(expression));
+ sortFields.add(new SortField2(expression, Ordering.ASCENDING));
+ model.walk(null, visitor, range, null);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ModifiableModel#addDataModelListener(javax.faces.model.DataModelListener)}.
+ */
+ public final void testAddDataModelListenerDataModelListener() {
+ DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
+ model.addDataModelListener(mockedListener);
+ assertEquals(model.getDataModelListeners()[0], mockedListener);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.ModifiableModel#removeDataModelListener(javax.faces.model.DataModelListener)}.
+ */
+ public final void testRemoveDataModelListenerDataModelListener() {
+ DataModelListener mockedListener = EasyMock.createNiceMock(DataModelListener.class);
+ model.addDataModelListener(mockedListener);
+ assertSame(model.getDataModelListeners()[0], mockedListener);
+ model.removeDataModelListener(mockedListener);
+ assertEquals(model.getDataModelListeners().length, 0);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java (from rev 14980, root/framework/trunk/api/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/ScrollableTableDataRangeSerializationTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,59 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class ScrollableTableDataRangeSerializationTest extends TestCase {
+
+ private ScrollableTableDataRange readWriteRange(ScrollableTableDataRange range) throws Exception {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(range);
+ oos.close();
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ ObjectInputStream ois = new ObjectInputStream(bais);
+
+ return (ScrollableTableDataRange) ois.readObject();
+ }
+
+ public void testSerialization() throws Exception {
+ SortOrder order = new SortOrder(new SortField[] { new SortField("xxx", true) });
+ ScrollableTableDataRange range = new ScrollableTableDataRange(10, 300, order);
+
+ ScrollableTableDataRange serializedRange = readWriteRange(range);
+
+ assertNotSame(range, serializedRange);
+ assertEquals(range, serializedRange);
+ }
+}
Copied: root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/SortField2Test.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/SortField2Test.java)
===================================================================
--- root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/SortField2Test.java (rev 0)
+++ root/ui-sandbox/trunk/components/tables/src/test/java/org/richfaces/model/SortField2Test.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,99 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import javax.el.ValueExpression;
+
+import junit.framework.TestCase;
+
+import org.easymock.classextension.EasyMock;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class SortField2Test extends TestCase {
+
+ private SortField2 field;
+ private ValueExpression expression;
+ private Ordering ordering;
+ /**
+ * @param name
+ */
+ public SortField2Test(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ expression = EasyMock.createNiceMock(ValueExpression.class);
+ ordering = Ordering.ASCENDING;
+ field = new SortField2(expression, ordering);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ field = null;
+ ordering = null;
+ expression = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#hashCode()}.
+ */
+ public final void testHashCode() {
+ Field sortField = new SortField2(expression, ordering);
+ assertEquals(sortField.hashCode(), field.hashCode());
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#equals(java.lang.Object)}.
+ */
+ public final void testEqualsObject() {
+ SortField2 sortField = new SortField2(null);
+ assertFalse(sortField.equals(field));
+ sortField.setExpression(expression);
+ sortField.setOrdering(ordering);
+ assertTrue(sortField.equals(field));
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression)}.
+ */
+ public final void testSortField2ValueExpression() {
+ SortField2 sortField2 = new SortField2(expression);
+ field.setOrdering(null);
+ assertEquals(sortField2, field);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#SortField2(javax.el.ValueExpression, org.richfaces.model.Ordering)}.
+ */
+ public final void testSortField2ValueExpressionOrdering() {
+ SortField2 sortField2 = new SortField2(expression, ordering);
+ assertEquals(sortField2, field);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#getOrdering()}.
+ */
+ public final void testGetOrdering() {
+ assertEquals(field.getOrdering(), ordering);
+ }
+
+ /**
+ * Test method for {@link org.richfaces.model.SortField2#setOrdering(org.richfaces.model.Ordering)}.
+ */
+ public final void testSetOrdering() {
+ field.setOrdering(null);
+ assertNull(field.getOrdering());
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/xml/XmlNodeData.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,82 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.component.xml;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ *
+ */
+public class XmlNodeData implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 8320619478974873168L;
+
+ private String namespace;
+
+ private String name = "";
+
+ private String text;
+
+ private Map<String, Object> attributes = new HashMap<String, Object>();
+
+ public Map<String, Object> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttribute(String key, Object value) {
+ this.attributes.put(key, value);
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getText() {
+ return text != null ? text : "";
+ }
+
+ public void setNamespace(String namespace) {
+ this.namespace = namespace;
+ }
+
+ public String getNamespace() {
+ return namespace;
+ }
+
+ public String toString() {
+ return getName() + "{" + attributes.toString() + " <" + getText().trim() + ">" + "}";
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxExpandedEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,46 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+
+/**
+ *
+ * <br /><br />
+ *
+ * Created 27.08.2007
+ * @author mikalaj
+ * @since 3.1
+ */
+
+public class AjaxExpandedEvent extends NodeExpandedEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5191468583939051390L;
+
+ public AjaxExpandedEvent(UIComponent component) {
+ super(component);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/AjaxSelectedEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+
+import org.richfaces.model.TreeRowKey;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class AjaxSelectedEvent extends NodeSelectedEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1156974665865521208L;
+
+ public AjaxSelectedEvent(UIComponent component, TreeRowKey oldSelection) {
+ super(component, oldSelection);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,58 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public class NodeExpandedEvent extends FacesEvent {
+
+ public NodeExpandedEvent(UIComponent component) {
+ super(component);
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 2620359072575831666L;
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof NodeExpandedListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+ public void processListener(FacesListener listener) {
+ ((NodeExpandedListener) listener).processExpansion(this);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/NodeExpandedListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeExpandedListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public interface NodeExpandedListener extends FacesListener {
+ public void processExpansion(NodeExpandedEvent nodeExpandedEvent) throws AbortProcessingException;
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,69 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+import javax.faces.event.FacesEvent;
+import javax.faces.event.FacesListener;
+
+import org.richfaces.model.TreeRowKey;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public class NodeSelectedEvent extends FacesEvent {
+
+ private TreeRowKey oldSelection;
+
+ public NodeSelectedEvent(UIComponent component, TreeRowKey oldSelection) {
+ super(component);
+
+ this.oldSelection = oldSelection;
+ }
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -1292268859927735863L;
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#isAppropriateListener(javax.faces.event.FacesListener)
+ */
+
+ public boolean isAppropriateListener(FacesListener listener) {
+ return listener instanceof NodeSelectedListener;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.event.FacesEvent#processListener(javax.faces.event.FacesListener)
+ */
+
+ public void processListener(FacesListener listener) {
+ ((NodeSelectedListener) listener).processSelection(this);
+ }
+
+ public TreeRowKey getOldSelection() {
+ return oldSelection;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedListener.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/NodeSelectedListener.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedListener.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/NodeSelectedListener.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,34 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.FacesListener;
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 27.11.2006
+ *
+ */
+public interface NodeSelectedListener extends FacesListener {
+ public void processSelection(NodeSelectedEvent nodeSelectedEvent) throws AbortProcessingException;
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEvent.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,55 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.component.UIComponent;
+
+import org.ajax4jsf.event.AjaxEvent;
+
+/**
+ * Event send by tree component in case of AJAX of action (node expansion/collapsion or selection).
+ * Contains data to distinguish between different action types in order to support different re-rendering
+ * behaviors for particular actions.
+ *
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public class TreeAjaxEvent extends AjaxEvent {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2410803626536767706L;
+
+ private TreeAjaxEventType eventType;
+
+ public TreeAjaxEvent(UIComponent component, TreeAjaxEventType eventType) {
+ super(component);
+
+ this.eventType = eventType;
+ }
+
+ public TreeAjaxEventType getEventType() {
+ return eventType;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeAjaxEventType.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+/**
+ * Types enumeration for possible tree actions to be used in {@link TreeAjaxEvent}
+ *
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+
+public enum TreeAjaxEventType {
+ EXPANSION, SELECTION
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/TreeListenerEventsProducer.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.event;
+
+import javax.faces.el.MethodBinding;
+
+
+/**
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 29.11.2006
+ *
+ * Base tree events interface
+ */
+public interface TreeListenerEventsProducer {
+ public abstract void setChangeExpandListener(MethodBinding binding);
+ public abstract MethodBinding getChangeExpandListener();
+
+ public abstract void setNodeSelectListener(MethodBinding binding);
+ public abstract MethodBinding getNodeSelectListener();
+
+ public abstract void setDropListener(MethodBinding binding);
+ public abstract MethodBinding getDropListener();
+
+ public abstract void setDragListener(MethodBinding binding);
+ public abstract MethodBinding getDragListener();
+
+ public void addNodeSelectListener(NodeSelectedListener listener);
+ public void addChangeExpandListener(NodeExpandedListener listener);
+
+ //TODO - rename this
+ public boolean hasAjaxSubmitSelection();
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/AbstractTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,176 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+
+/**
+ * Base class for all tree data models
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 07.12.2006
+ */
+public abstract class AbstractTreeDataModel extends ExtendedDataModel {
+ public final static char SEPARATOR = NamingContainer.SEPARATOR_CHAR;
+
+ public final int getRowCount() {
+ return -1;
+ }
+
+ public final int getRowIndex() {
+ return -1;
+ }
+
+ public final void setRowIndex(int rowIndex) {
+ if(rowIndex!=-1) {
+ throw new IllegalArgumentException("In AbstractTreeDataModel rowIndex must be -1.");
+ }
+ }
+
+ public final void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object argument) throws IOException {
+ walk(context, dataVisitor, range, null, argument, false);
+ }
+
+ /**
+ * walk sub-model having row key argument as its root
+ * @param context faces context
+ * @param dataVisitor {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor}
+ * @param range {@link TreeRange} to constraint the walk
+ * @param rowKey row key to treat as root of sub-model
+ * @param argument implementation specific argument
+ * @param last boolean flag indicating whether we started our walk from last element
+ * @throws IOException
+ *
+ * @see {@link ExtendedDataModel#walk(FacesContext, DataVisitor, Range, Object)}
+ */
+ public abstract void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last) throws IOException;
+
+ /**
+ * returns whether this node is leaf
+ * @return
+ */
+ public abstract boolean isLeaf();
+
+ /**
+ * Walk backing sub-model having row key argument as its root. If there is no backing model
+ * configured, calling this method is equivalent to calling {@link #walk(FacesContext, DataVisitor, Range, Object, Object, boolean)}
+ * @param facesContext faces context
+ * @param visitor {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor} instance
+ * @param range {@link Range} to constraint the walk
+ * @param key row key to treat as root of sub-model
+ * @param argument implementation-specific argument
+ * @throws IOException
+ *
+ * @see {@link #walk(FacesContext, DataVisitor, Range, TreeRowKey, Object, boolean)}
+ */
+ public abstract void walkModel(FacesContext facesContext, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException;
+
+ /**
+ * Processes concrete tree node. Knows about {@link LastElementAware} interface and handles it
+ * properly. Checks if argument is instance of {@link SubTreeChildrenAppender} and if it is so
+ * does appending current element
+ * @param context
+ * @param dataVisitor
+ * @param argument
+ * @param treeRowKey
+ * @param last
+ * @throws IOException
+ */
+ protected void processElement(FacesContext context, DataVisitor dataVisitor, Object argument, TreeRowKey treeRowKey, boolean last) throws IOException {
+ if (last && dataVisitor instanceof LastElementAware) {
+ try {
+ ((LastElementAware) dataVisitor).setLastElement();
+ dataVisitor.process(context, treeRowKey, argument);
+ } finally {
+ ((LastElementAware) dataVisitor).resetLastElement();
+ }
+ } else {
+ dataVisitor.process(context, treeRowKey, argument);
+ }
+ }
+
+ /**
+ * Get current tree node.
+ * Note: valid only for classical TreeNode based tree data model implementation
+ *
+ * @return current tree node
+ */
+ public abstract TreeNode getTreeNode();
+
+ /**
+ * Get model node recursively with all sub nodes.
+ * Note: valid only for classical TreeNode based tree data model implementation
+ *
+ * @return current tree node
+ */
+ public TreeNode getModelTreeNode() {
+ return getTreeNode();
+ }
+
+ public abstract Object convertToKey(FacesContext context, String keyString,
+ UIComponent component, Converter converter);
+
+ /**
+ * Get row key for certain tree node object
+ *
+ * @param node to get key for
+ * @return node row key
+ */
+ public Object getTreeNodeRowKey(Object node) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Get node local id in it's parent childs collection
+ *
+ * @param childNode node to get identifier for
+ * @return node local identifier
+ */
+ public Object getChildNodeId(Object childNode) {
+ throw new UnsupportedOperationException();
+ }
+
+ public Object getParentRowKey(Object key) {
+ return ((TreeRowKey) key).getParentKey();
+ }
+
+ public void addNode(Object parentRowKey, Object newNode, Object id) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeNode(Object rowKey) {
+ throw new UnsupportedOperationException();
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableSwingTreeNodeImpl.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * This class provides the solution for "false leaves" issue of cacheable trees
+ *
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class CacheableSwingTreeNodeImpl extends SwingTreeNodeImpl {
+
+ private boolean notLeaf = false;
+
+ @Override
+ public boolean isLeaf() {
+ return !this.notLeaf && super.isLeaf();
+ }
+
+ public void setNotLeaf(boolean notLeaf) {
+ this.notLeaf = notLeaf;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,226 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Extension of {@link TreeDataModel} supporting lazy data fetching for caching
+ *
+ * created 08.01.2007
+ *
+ * @author Nick - mailto:nbelaevski@exadel.com
+ */
+public abstract class CacheableTreeDataModel<T> extends TreeDataModel<T> {
+
+ private Log log = LogFactory.getLog(CacheableTreeDataModel.class);
+
+ private final class CacheFillingVisitor implements DataVisitor {
+
+ private CacheFillingVisitor() {
+ }
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+ TreeRowKey treeRowKey = (TreeRowKey) rowKey;
+ treeDataModel.setRowKey(treeRowKey);
+ setDefaultNodeData(locateTreeNode(treeRowKey, true), treeDataModel.getRowData());
+ }
+
+ }
+
+ private final static DataVisitor NULL_VISITOR = new DataVisitor() {
+
+ public void process(FacesContext context, Object rowKey, Object argument) throws IOException {
+ //do nothing
+ }
+
+ };
+
+ private TreeDataModel<T> treeDataModel;
+
+ public boolean isLeaf() {
+ TreeRowKey rowKey = (TreeRowKey) getRowKey();
+ T treeNode = locateTreeNode(rowKey);
+ if (treeNode != null && !nodeAdaptor.isLeaf(treeNode)) {
+ return false;
+ }
+
+ treeNode = treeDataModel.locateTreeNode(rowKey);
+ if (treeNode != null) {
+ return nodeAdaptor.isLeaf(treeNode);
+ }
+
+ return false;
+ }
+
+ public CacheableTreeDataModel(TreeDataModel<T> model, MissingNodeHandler<T> missingNodeHandler) {
+ super(model.getClazz(), model.getNodeAdaptor(), missingNodeHandler);
+ setWrappedData(missingNodeHandler.handleMissingNode(null, null));
+ setTreeDataModel(model);
+ }
+
+ public void walkModel(FacesContext context, DataVisitor visitor,
+ Range range, Object key, Object argument, boolean last)
+ throws IOException {
+ treeDataModel.walkModel(context, visitor, range, key,
+ argument, last);
+ }
+
+ public void setTreeDataModel(TreeDataModel<T> treeDataModel) {
+ this.treeDataModel = treeDataModel;
+ }
+
+ public TreeDataModel<T> getTreeDataModel() {
+ return treeDataModel;
+ }
+
+ public void walk(FacesContext context, final DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last)
+ throws IOException {
+
+ T cachedTreeNode = locateTreeNode((TreeRowKey) rowKey);
+ T treeNode = treeDataModel.locateTreeNode((TreeRowKey) rowKey);
+
+ if (treeNode != null) {
+ if (cachedTreeNode == null || (nodeAdaptor.isLeaf(cachedTreeNode) && !nodeAdaptor.isLeaf(treeNode))) {
+ //fill cache
+ treeDataModel.walk(context, new CacheFillingVisitor(), range,
+ rowKey, argument, last);
+ }
+
+ super.walk(context, dataVisitor, range, rowKey, argument, last);
+ }
+ }
+
+ public void setTransient(boolean newTransientValue) {
+ if (!newTransientValue) {
+ throw new IllegalArgumentException(
+ "ReplaceableTreeDataModel shouldn't be transient!");
+ }
+ }
+
+ protected abstract void setDefaultNodeData(T node, Object data);
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ Object convertedKey = treeDataModel.convertToKey(context, keyString, component, converter);
+
+ if (convertedKey != null) {
+ final TreeRowKey treeRowKey = (TreeRowKey) convertedKey;
+ try {
+ walk(context, NULL_VISITOR, new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return rowKey == null || rowKey.isSubKey(treeRowKey);
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return this.processChildren(rowKey) || rowKey.equals(treeRowKey);
+ }
+
+ }, null);
+ } catch (IOException e) {
+ context.getExternalContext().log(e.getLocalizedMessage(), e);
+
+ return null;
+ }
+ }
+
+ return convertedKey;
+ }
+
+ @Override
+ public T locateTreeNode(TreeRowKey rowKey) {
+ return locateTreeNode(rowKey, true);
+ }
+
+ @Override
+ public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
+ super.addNode(parentRowKey, newNode, id);
+
+ if (treeDataModel != null) {
+ Object savedRowKey = treeDataModel.getRowKey();
+
+ try {
+ treeDataModel.setRowKey(getRowKey());
+ treeDataModel.addNode(parentRowKey, newNode, id);
+ } finally {
+ try {
+ treeDataModel.setRowKey(savedRowKey);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void removeNode(Object rowKey) {
+ super.removeNode(rowKey);
+
+ if (treeDataModel != null) {
+ Object savedRowKey = treeDataModel.getRowKey();
+
+ try {
+ treeDataModel.setRowKey(getRowKey());
+ treeDataModel.removeNode(rowKey);
+ } finally {
+ try {
+ treeDataModel.setRowKey(savedRowKey);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+ @Override
+ public TreeNode getModelTreeNode() {
+ TreeNode node = null;
+ if (treeDataModel != null) {
+ Object savedRowKey = treeDataModel.getRowKey();
+
+ try {
+ treeDataModel.setRowKey(getRowKey());
+ node = treeDataModel.getModelTreeNode();
+ } finally {
+ try {
+ treeDataModel.setRowKey(savedRowKey);
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+ }
+ }
+
+ return node;
+ }
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/CacheableTreeNodeImpl.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,48 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * This class provides the solution for "false leaves" issue of cacheable trees
+ *
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public class CacheableTreeNodeImpl<T> extends TreeNodeImpl<T> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5918388225735277820L;
+
+ private boolean notLeaf = false;
+
+ @Override
+ public boolean isLeaf() {
+ return !this.notLeaf && super.isLeaf();
+ }
+
+ public void setNotLeaf(boolean notLeaf) {
+ this.notLeaf = notLeaf;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicCacheableTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,73 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * {@link CacheableTreeDataModel} implementation for classic {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class ClassicCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
+
+ private static final MissingNodeHandler<TreeNode> missingNodeHandler = new MissingNodeHandler<TreeNode>() {
+
+ public TreeNode handleMissingNode(TreeNode parentNode,
+ Object pathSegment) {
+
+ TreeNodeImpl childNode = new CacheableTreeNodeImpl();
+
+ if (parentNode != null) {
+ parentNode.addChild(pathSegment, childNode);
+ }
+
+ return childNode;
+ }
+
+ };
+
+ public ClassicCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
+ super(model, missingNodeHandler);
+ }
+
+ @Override
+ protected void setDefaultNodeData(TreeNode node, Object data) {
+ if (node != null) {
+ CacheableTreeNodeImpl cacheableTreeNode = (CacheableTreeNodeImpl) node;
+ cacheableTreeNode.setData(data);
+ cacheableTreeNode.setNotLeaf(!isLeaf());
+ }
+ }
+
+ @Override
+ public TreeNode getTreeNode() {
+ if (isRowAvailable()) {
+ return locateTreeNode((TreeRowKey) getRowKey());
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ClassicTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,94 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class ClassicTreeDataModel extends TreeDataModel<TreeNode> {
+
+ public ClassicTreeDataModel() {
+ super(TreeNode.class, TreeDataModelNodeAdaptor.classicTreeNodeAdaptor, null);
+ }
+
+ @Override
+ public TreeNode getTreeNode() {
+ if (isRowAvailable()) {
+ return locateTreeNode((TreeRowKey) getRowKey());
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ //TODO optimize search for empty string
+ String[] strings = ListRowKey.fromString(keyString);
+ List<Object> list = new ArrayList<Object>(strings.length);
+ TreeNode node = (TreeNode) getWrappedData();
+
+ for (int i = 0; i < strings.length; i++) {
+ String key = strings[i];
+ TreeNode<?> child = node.getChild(key);
+ if (child != null) {
+ node = child;
+ list.add(key);
+ } else {
+ boolean found = false;
+ Iterator<Entry<Object, TreeNode>> children = node.getChildren();
+
+ while (children.hasNext() && !found) {
+ Entry<Object, TreeNode> entry = children.next();
+ Object keyObject = entry.getKey();
+ if (key.equals(keyObject.toString())) {
+ node = entry.getValue();
+ list.add(keyObject);
+ found = true;
+ }
+ }
+
+ if (!found) {
+ return null;
+ }
+ }
+ }
+
+ return new ListRowKey<Object>(list);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ComplexTreeRowKey.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,36 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * Marks complex tree row keys containing several segments
+ *
+ * @author Nick Belaevski
+ * @since 3.3.1
+ */
+
+public interface ComplexTreeRowKey {
+
+ public int getKeySegmentsCount();
+
+ public Object getKeySegment(int i);
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ConvertableKeyModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,51 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+/**
+ * Models that can handle keys conversion should implement this interface
+ *
+ * For internal use only
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public interface ConvertableKeyModel {
+
+ /**
+ * Converts {@link String} to model object key
+ *
+ * @param context
+ * @param key
+ * @param component
+ * @param converter
+ * @return
+ */
+ public Object getKeyAsObject(FacesContext context, String key,
+ UIComponent component, Converter converter);
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/LastElementAware.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/LastElementAware.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/LastElementAware.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/LastElementAware.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,43 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+/**
+ * {@link org.ajax4jsf.ajax.repeat.UIDataAdaptor.ComponentVisitor} instances can implement this interface in order to
+ * be notified of last element occurence at the current tree level. {@link #setLastElement()}
+ * method is invoked before visiting last element and {@link #resetLastElement()} is called after
+ * visiting last element.
+ *
+ * @author Konstantin Mishin
+ */
+public interface LastElementAware {
+
+ /**
+ * The method is invoked to notify that last element occured
+ */
+ public void setLastElement();
+ /**
+ * The method is invoked to notify that we're done with last element
+ */
+ public void resetLastElement();
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ListRowKey.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/ListRowKey.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ListRowKey.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/ListRowKey.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,265 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.NamingContainer;
+
+/**
+ * Default {@link TreeRowKey} implementation based on {@link ArrayList}
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 17.11.2006
+ */
+public class ListRowKey<T> extends TreeRowKey<T> {
+
+ private ArrayList<T> path;
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7718335783201397177L;
+
+ public String toString() {
+ return getPath();
+ }
+
+ /**
+ * Default constructor
+ */
+ public ListRowKey() {
+ super();
+ this.path = new ArrayList<T>();
+ }
+
+ /**
+ * Copy constructor
+ * @param parentRowKey row key to clone
+ */
+
+ @SuppressWarnings("unchecked")
+ public ListRowKey(ListRowKey<T> parentRowKey) {
+ super();
+ if (parentRowKey != null) {
+ this.path = (ArrayList<T>) parentRowKey.path.clone();
+ } else {
+ this.path = new ArrayList<T>();
+ }
+ }
+
+ /**
+ * Appending constructor
+ *
+ * @param parentRowKey base row key
+ * @param pathElement path segment to append to base row key
+ */
+ public ListRowKey(ListRowKey<T> parentRowKey, T pathElement) {
+ this(parentRowKey);
+ this.path.add(pathElement);
+ }
+
+ /**
+ * Appending constructor
+ * @param parentRowKey base row key
+ * @param pathElement path segment to append to base row key
+ */
+ public ListRowKey(ListRowKey<T> parentRowKey, ListRowKey<T> childRowKey) {
+ this(parentRowKey);
+ this.path.addAll(childRowKey.path);
+ }
+
+ protected ListRowKey(ArrayList<T> list) {
+ super();
+
+ this.path = list;
+ }
+
+ /**
+ * Path object constructor
+ * @param path first path segment
+ * @deprecated
+ */
+ public ListRowKey(T path) {
+ super();
+ this.path = new ArrayList<T>(1);
+ this.path.add(path);
+ }
+
+ /**
+ * List constructor
+ * @param list List of strings to create corresponding row key from
+ */
+ public ListRowKey(List<T> list) {
+ super();
+
+ this.path = new ArrayList<T>(list);
+ }
+
+ public int depth() {
+ return path.size();
+ }
+
+ public Iterator<T> iterator() {
+ return path.iterator();
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((path == null) ? 0 : path.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final ListRowKey<?> other = (ListRowKey<?>) obj;
+ if (path == null) {
+ if (other.path != null)
+ return false;
+ } else if (!path.equals(other.path))
+ return false;
+ return true;
+ }
+
+ public Iterator<T> getSubPathIterator(int fromIndex) {
+ return path.listIterator(fromIndex);
+ }
+
+ @Override
+ public TreeRowKey<T> getSubKey(int fromIndex) {
+ return new ListRowKey<T>(path.subList(fromIndex, path.size()));
+ }
+
+
+ @SuppressWarnings("unchecked")
+ public boolean isSubKey(TreeRowKey<T> rowKey) {
+ if (rowKey instanceof ListRowKey) {
+ ListRowKey<T> listRowKey = (ListRowKey<T>) rowKey;
+
+ return depth() == getCommonPathLength(listRowKey);
+ } else {
+ return super.isSubKey(rowKey);
+ }
+ }
+
+ private void appendSegment(StringBuilder builder, String segment) {
+ StringBuilder escapedSubPath = new StringBuilder();
+ for (int i = 0; i < segment.length(); i++) {
+ char ch = segment.charAt(i);
+
+ //escape
+ if (AbstractTreeDataModel.SEPARATOR == ch || ListRowKey.SEPARATOR_ESCAPE_CHAR == ch) {
+ escapedSubPath.append(ListRowKey.SEPARATOR_ESCAPE_CHAR);
+ }
+
+ escapedSubPath.append(ch);
+ }
+
+ builder.append(escapedSubPath.toString());
+ }
+
+ public String getPath() {
+ StringBuilder result = new StringBuilder();
+ Iterator<T> iterator = path.iterator();
+ boolean hasNext = iterator.hasNext();
+
+ while (hasNext) {
+ T segment = iterator.next();
+
+ if (segment instanceof ComplexTreeRowKey) {
+ ComplexTreeRowKey complexKey = (ComplexTreeRowKey) segment;
+
+ int segmentsCount = complexKey.getKeySegmentsCount();
+ for (int i = 0; i < segmentsCount; i++) {
+ appendSegment(result, complexKey.getKeySegment(i).toString());
+ if (i < segmentsCount - 1) {
+ result.append(AbstractTreeDataModel.SEPARATOR);
+ }
+ }
+
+ } else {
+ appendSegment(result, segment.toString());
+ }
+
+ hasNext = iterator.hasNext();
+
+ if (hasNext) {
+ result.append(AbstractTreeDataModel.SEPARATOR);
+ }
+ }
+
+ return result.toString();
+ }
+
+ public int getCommonPathLength(TreeRowKey<T> otherRowKey) {
+ if (otherRowKey == null)
+ return 0;
+ Iterator<T> iterator = this.iterator();
+ Iterator<T> otherIterator = otherRowKey.iterator();
+ int length = 0;
+ while (iterator.hasNext() && otherIterator.hasNext()
+ && iterator.next().equals(otherIterator.next()))
+ length++;
+ return length;
+ }
+
+ public T get(int i) {
+ return path.get(i);
+ }
+
+ private static final String SEPARATOR = "(?<!" + ListRowKey.SEPARATOR_ESCAPE_CHAR + ")\\"
+ + NamingContainer.SEPARATOR_CHAR;
+
+ public static String[] fromString(String keyString) {
+ String[] split = keyString.split(SEPARATOR);
+ for (int i = 0; i < split.length; i++) {
+ //TODO exception if not escaped properly
+ split[i] = split[i].replaceAll("_(:|_)", "$1");
+ }
+
+ return split;
+ }
+
+ public static void main(String[] args) {
+ System.out.println(Arrays.toString(fromString("test_:abc:123:a__b")));
+ }
+
+ @Override
+ public TreeRowKey<T> getParentKey() {
+ int toIdx = path.size() - 1;
+ TreeRowKey<T> result = null;
+
+ if (toIdx >= 0) {
+ result = new ListRowKey<T>(new ArrayList<T>(path.subList(0, toIdx)));
+ }
+
+ return result;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/MapDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/MapDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/MapDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/MapDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,240 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.AbstractMap;
+import java.util.AbstractSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
+import java.util.Map.Entry;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski mailto:nbelaevski@exadel.com created 30.07.2007
+ */
+public class MapDataModel extends ExtendedDataModel implements ConvertableKeyModel {
+
+ private Map<Object, Object> map;
+ private Object rowKey;
+ private Object wrappedData;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+
+ public void setRowKey(Object key) {
+ this.rowKey = key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext,
+ * org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range,
+ * java.lang.Object)
+ */
+
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+ if (map != null) {
+ for (Iterator<Object> iterator = map.keySet().iterator(); iterator.hasNext();) {
+ Object key = (Object) iterator.next();
+
+ visitor.process(context, key, argument);
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+
+ public int getRowCount() {
+ return map != null ? map.size() : 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+
+ public Object getRowData() {
+ return map != null ? map.get(rowKey) : null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+
+ public int getRowIndex() {
+ return 0;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ return map != null && map.containsKey(rowKey);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ this.wrappedData = data;
+ if (data instanceof NamedNodeMap) {
+ this.map = new AbstractMap<Object, Object>() {
+
+ private Set<Entry<Object, Object>> entrySet = new AbstractSet<Entry<Object, Object>>() {
+
+ public Iterator<Entry<Object, Object>> iterator() {
+ return new Iterator<Entry<Object, Object>>() {
+ private int index = 0;
+
+ public boolean hasNext() {
+ return index < ((NamedNodeMap) getWrappedData()).getLength();
+ }
+
+ public Entry<Object, Object> next() {
+ final Node node = ((NamedNodeMap) getWrappedData()).item(index++);
+ if (node == null) {
+ throw new NoSuchElementException();
+ } else {
+ return new Map.Entry<Object, Object>() {
+
+ public Object getKey() {
+ return node.getNodeName();
+ }
+
+ public Object getValue() {
+ return node;
+ }
+
+ public Object setValue(Object arg0) {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+ };
+ }
+
+ public int size() {
+ return ((NamedNodeMap) getWrappedData()).getLength();
+ }
+
+ };
+
+ public boolean containsKey(Object key) {
+ return ((NamedNodeMap) getWrappedData()).getNamedItem((String) key) != null;
+ }
+
+ public Object get(Object key) {
+ return ((NamedNodeMap) getWrappedData()).getNamedItem((String) key);
+ }
+
+ public Set<Entry<Object, Object>> entrySet() {
+ return entrySet;
+ }
+
+ };
+ } else if (data != null) {
+ this.map = (Map<Object, Object>) data;
+ } else {
+ this.map = null;
+ }
+ }
+
+ public Object getKeyAsObject(FacesContext context, String key, UIComponent component, Converter converter) {
+ if (this.map != null) {
+ if (this.map.containsKey(key)) {
+ return key;
+ } else {
+ Set<Entry<Object,Object>> set = this.map.entrySet();
+ for (Entry<Object, Object> entry : set) {
+ Object keyObject = entry.getKey();
+ if (key.equals(keyObject.toString())) {
+ return keyObject;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SequenceDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SequenceDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SequenceDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SequenceDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,171 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.w3c.dom.NodeList;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class SequenceDataModel extends ExtendedDataModel implements ConvertableKeyModel {
+
+ private Object wrappedData;
+ private List list;
+ private Integer key;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return key;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#setRowKey(java.lang.Object)
+ */
+ public void setRowKey(Object key) {
+ this.key = (Integer) key;
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.model.ExtendedDataModel#walk(javax.faces.context.FacesContext, org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range, java.lang.Object)
+ */
+ public void walk(FacesContext context, DataVisitor visitor, Range range,
+ Object argument) throws IOException {
+
+ if (list != null) {
+ int i = 0;
+ for (Iterator iterator = list.iterator(); iterator.hasNext();) {
+ iterator.next();
+
+ visitor.process(context, new Integer(i), argument);
+
+ i++;
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowCount()
+ */
+ public int getRowCount() {
+ return list != null ? list.size() : 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public Object getRowData() {
+ return (list != null && key != null) ? list.get(key.intValue()) : null;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getRowIndex()
+ */
+ public int getRowIndex() {
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#getWrappedData()
+ */
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ return list != null && key != null && list.size() > key.intValue();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setRowIndex(int)
+ */
+ public void setRowIndex(int rowIndex) {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.faces.model.DataModel#setWrappedData(java.lang.Object)
+ */
+ public void setWrappedData(Object data) {
+ this.wrappedData = data;
+ if (data instanceof List) {
+ this.list = (List) data;
+ } else if (data instanceof Collection) {
+ this.list = new ArrayList((Collection) data);
+ //copying all collection content into new collection here should prevent us
+ //from possible issues caused by iteration tricks. e.g.: returning custom iterator
+ //caching current element and comparing indices inside get()
+ //
+ //possible concurrent collection modifications and multithreading will break the magic
+ } else if (data instanceof NodeList) {
+ this.list = new AbstractList() {
+
+ public Object get(int index) {
+ return ((NodeList) getWrappedData()).item(index);
+ }
+
+ public int size() {
+ return ((NodeList) getWrappedData()).getLength();
+ }
+
+ };
+ } else if (data instanceof Object[]) {
+ this.list = Arrays.asList((Object[]) data);
+ } else if (data != null) {
+ this.list = Collections.singletonList(data);
+ } else {
+ this.list = null;
+ }
+ }
+
+ public Object getKeyAsObject(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ int key = Integer.parseInt(keyString);
+ if (key >= 0 && this.list != null && key < this.list.size()) {
+ return key;
+ } else {
+ return null;
+ }
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingCacheableTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,77 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import javax.swing.tree.TreeNode;
+
+/**
+ * {@link CacheableTreeDataModel} implementation for Swing {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class SwingCacheableTreeDataModel extends CacheableTreeDataModel<TreeNode> {
+
+ private static final MissingNodeHandler<TreeNode> missingNodeHandler = new MissingNodeHandler<TreeNode>() {
+
+ public TreeNode handleMissingNode(TreeNode parent,
+ Object pathSegment) {
+
+ SwingTreeNodeImpl childNode = new CacheableSwingTreeNodeImpl();
+
+ if (parent != null) {
+ SwingTreeNodeImpl parentNode = (SwingTreeNodeImpl) parent;
+
+ parentNode.addChild(pathSegment, childNode);
+ childNode.setParent(parentNode);
+ }
+
+ return childNode;
+ }
+
+ };
+
+ public SwingCacheableTreeDataModel(TreeDataModel<TreeNode> model) {
+ super(model, missingNodeHandler);
+ }
+
+ @Override
+ public Object getRowData() {
+ SwingTreeNodeImpl swingTreeNodeImpl = ((SwingTreeNodeImpl) super.getRowData());
+ if (swingTreeNodeImpl != null) {
+ return swingTreeNodeImpl.getData();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ protected void setDefaultNodeData(TreeNode node, Object data) {
+ CacheableSwingTreeNodeImpl cacheableTreeNode = (CacheableSwingTreeNodeImpl) node;
+ cacheableTreeNode.setData(data);
+ cacheableTreeNode.setNotLeaf(!isLeaf());
+ }
+}
+
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,110 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.swing.tree.TreeNode;
+
+/**
+ * {@link TreeDataModel} implementation for classic {@link TreeNode} instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public class SwingTreeDataModel extends TreeDataModel<TreeNode> {
+
+ private TreeNode treeNode;
+
+ public SwingTreeDataModel() {
+ super(TreeNode.class, TreeDataModelNodeAdaptor.swingTreeNodeAdaptor, null);
+ }
+
+ @Override
+ protected TreeNode getData() {
+ return treeNode;
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ if (data != null) {
+ SwingTreeNodeImpl treeNodeImpl = new SwingTreeNodeImpl();
+
+ if (data instanceof Collection<?>) {
+ Collection<?> collection = (Collection<?>) data;
+
+ for (Iterator<?> iterator = collection.iterator(); iterator
+ .hasNext();) {
+ treeNodeImpl.addChild((TreeNode) iterator.next());
+ }
+ } else if (data.getClass().isArray()) {
+ Object[] nodes = (Object[]) data;
+ for (int i = 0; i < nodes.length; i++) {
+ treeNodeImpl.addChild((TreeNode) nodes[i]);
+ }
+ } else {
+ treeNodeImpl.addChild((TreeNode) data);
+ }
+
+ this.treeNode = treeNodeImpl;
+ } else {
+ this.treeNode = null;
+ }
+
+ super.setWrappedData(data);
+ }
+
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString, UIComponent component, Converter converter) {
+ String[] strings = ListRowKey.fromString(keyString);
+ List<Integer> list = new ArrayList<Integer>(strings.length);
+ TreeNode node = this.treeNode;
+
+ if (node != null) {
+ TreeDataModelNodeAdaptor<TreeNode> adaptor = getNodeAdaptor();
+
+ for (int i = 0; i < strings.length; i++) {
+ int key = Integer.parseInt(strings[i]);
+
+ node = adaptor.getChild(node, key);
+ if (node != null) {
+ list.add(key);
+ } else {
+ return null;
+ }
+ }
+ }
+
+ return new ListRowKey<Integer>(list);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/SwingTreeNodeImpl.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,145 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.swing.tree.TreeNode;
+
+/**
+ * Map-based Swing {@link TreeNode} implementation
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+@Deprecated
+public class SwingTreeNodeImpl implements TreeNode {
+
+ private List<TreeNode> children = new ArrayList<TreeNode>();
+
+ private TreeNode parent;
+
+ private Object data;
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#children()
+ */
+ public Enumeration children() {
+ return new Enumeration() {
+ private Iterator<?> iterator = children.iterator();
+
+ public boolean hasMoreElements() {
+ return iterator.hasNext();
+ }
+
+ public Object nextElement() {
+ return iterator.next();
+ }
+ };
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getAllowsChildren()
+ */
+ public boolean getAllowsChildren() {
+ return true;
+ }
+
+ public void setAllowsChildren(boolean allowsChildren) {
+ if (!allowsChildren) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getChildAt(int)
+ */
+ public TreeNode getChildAt(int childIndex) {
+ return children.get(childIndex);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getChildCount()
+ */
+ public int getChildCount() {
+ return children.size();
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getIndex(javax.swing.tree.TreeNode)
+ */
+ public int getIndex(TreeNode node) {
+ return children.indexOf(node);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#getParent()
+ */
+ public TreeNode getParent() {
+ return parent;
+ }
+
+ public void setParent(TreeNode parent) {
+ this.parent = parent;
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.tree.TreeNode#isLeaf()
+ */
+ public boolean isLeaf() {
+ return children.isEmpty();
+ }
+
+ public void addChild(TreeNode node) {
+ children.add(node);
+ }
+
+ public void addChild(Object key, TreeNode node) {
+ if (Integer.valueOf(children.size()).equals(key)) {
+ children.add(node);
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public Object getData() {
+ return data;
+ }
+
+ public void setData(Object data) {
+ this.data = data;
+ }
+
+ public void removeChild(TreeNode node) {
+ this.children.remove(node);
+ }
+
+ public void removeChildByKey(Object key) {
+ this.children.remove(((Integer) key).intValue());
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeDataModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,401 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.Range;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski - nbelaevski(a)exadel.com created 16.11.2006
+ *
+ */
+public abstract class TreeDataModel<T> extends AbstractTreeDataModel {
+
+ private Object wrappedData;
+ private Class<T> clazz;
+
+ private TreeRowKey currentRowKey;
+
+ private TreeRowKey oldRowKey;
+
+ private Boolean rowAvailable = Boolean.FALSE;
+ private T rowTreeData;
+
+ protected final TreeDataModelNodeAdaptor<T> nodeAdaptor;
+
+ private MissingNodeHandler<T> missingNodeHandler;
+
+ /**
+ * Interface aimed to handle missing nodes for externally-generated keys.
+ * Typical usage for the interface is filling model cache
+ * @param <T> generic tree node type
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+ public static interface MissingNodeHandler<T> {
+ T handleMissingNode(T parentNode, Object pathSegment);
+ };
+
+ public TreeDataModel(Class<T> clazz, TreeDataModelNodeAdaptor<T> nodeAdaptor,
+ MissingNodeHandler<T> missingNodeHandler) {
+
+ this.clazz = clazz;
+ this.nodeAdaptor = nodeAdaptor;
+ this.missingNodeHandler = missingNodeHandler;
+ }
+
+ public final Class<T> getClazz() {
+ return clazz;
+ }
+
+ public final TreeDataModelNodeAdaptor<T> getNodeAdaptor() {
+ return nodeAdaptor;
+ }
+
+ public Object getRowKey() {
+ return this.currentRowKey;
+ }
+
+ public void setRowKey(Object rowKey) {
+ if (rowKey != null) {
+ ListRowKey newRowKey = (ListRowKey) rowKey;
+ this.currentRowKey = newRowKey;
+ this.rowAvailable = null;
+ } else {
+ this.currentRowKey = null;
+ this.oldRowKey = null;
+ this.rowTreeData = null;
+ this.rowAvailable = Boolean.FALSE;
+ }
+ }
+
+ protected void doWalk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last) throws IOException {
+ ListRowKey listRowKey = (ListRowKey) rowKey;
+
+ T node = locateTreeNode(listRowKey);
+
+ if (node != null) {
+ TreeRange treeRange = (TreeRange) range;
+
+ if (treeRange == null || treeRange.processNode(listRowKey)) {
+
+ //root node is not processed, it is considered fake for this class of models
+ if (listRowKey != null && listRowKey.depth() > 0) {
+ processElement(context, dataVisitor, argument, listRowKey, last);
+ }
+
+ if (treeRange == null || treeRange.processChildren(listRowKey)) {
+ if (!nodeAdaptor.isLeaf(node)) {
+ Iterator<Map.Entry<Object, T>> children = nodeAdaptor.getChildren(node);
+
+ if (children != null) {
+ Map.Entry<Object, T> childEntry = children.hasNext() ? children.next() : null;
+ T childNode;
+ Object identifier;
+
+ if (childEntry != null) {
+ childNode = childEntry.getValue();
+ identifier = childEntry.getKey();
+ } else {
+ childNode = null;
+ identifier = null;
+ }
+
+ do {
+ Map.Entry<Object, T> nextChildEntry = children.hasNext() ? children.next() : null;
+ T nextChildNode;
+ Object nextIdentifier;
+
+ if (nextChildEntry != null) {
+ //TODO consider lazy initialization of value
+ nextChildNode = nextChildEntry.getValue();
+ nextIdentifier = nextChildEntry.getKey();
+ } else {
+ nextChildNode = null;
+ nextIdentifier = null;
+ }
+
+ if (childNode != null) {
+
+ boolean isLast = nextChildNode == null;
+
+ ListRowKey newRowKey = new ListRowKey(listRowKey, identifier);
+ this.doWalk(context, dataVisitor, range, newRowKey, argument, isLast);
+ }
+
+ identifier = nextIdentifier;
+ childNode = nextChildNode;
+ } while (childNode != null);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument, boolean last) throws IOException {
+
+ if (rowKey != null) {
+ setRowKey(rowKey);
+ if (!isRowAvailable()) {
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+ }
+
+ doWalk(context, dataVisitor, range, rowKey, argument, last);
+ }
+
+ public T locateTreeNode(TreeRowKey rowKey) {
+ return locateTreeNode(rowKey, false);
+ }
+
+ public T locateTreeNode(TreeRowKey rowKey, boolean allowCreate) {
+ T tmpRowTreeData = this.rowTreeData;
+ TreeRowKey tmpOldRowKey = this.oldRowKey;
+
+ boolean useCached = (rowTreeData != null && rowKey != null && rowKey.equals(tmpOldRowKey));
+ if (!useCached) {
+ T rootNode = getData();
+
+ if (rootNode != null) {
+ if (rowKey != null) {
+ int commonPathLength = rowKey.getCommonPathLength(tmpOldRowKey);
+ if (tmpOldRowKey == null) {
+ tmpRowTreeData = rootNode;
+ } else {
+ int rootOpsCount = rowKey.depth();
+ int currentUpOpsCount = tmpOldRowKey.depth() - commonPathLength;
+ int currentOpsCount = currentUpOpsCount + rootOpsCount - commonPathLength;
+
+ if (rootOpsCount > currentOpsCount) {
+ for (int i = 0; i < tmpOldRowKey.depth()
+ - commonPathLength; i++) {
+
+ tmpRowTreeData = nodeAdaptor.getParent(tmpRowTreeData);
+ }
+ } else {
+ commonPathLength = 0;
+ tmpRowTreeData = rootNode;
+ tmpOldRowKey = null;
+ }
+ }
+ tmpOldRowKey = rowKey;
+ Iterator<?> iterator = rowKey.getSubPathIterator(commonPathLength);
+ while (iterator.hasNext()) {
+ //TODO nick - check rowTreeData for null
+
+ Object pathSegment = iterator.next();
+ T childRowTreeData = nodeAdaptor.getChild(tmpRowTreeData, pathSegment);
+
+ if (childRowTreeData == null) {
+ if (!allowCreate) {
+ //TODO nick - reset rowTreeData
+ return null;
+ } else {
+ if (missingNodeHandler != null) {
+ childRowTreeData = missingNodeHandler.
+ handleMissingNode(tmpRowTreeData, pathSegment);
+
+ if (childRowTreeData == null) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+ }
+
+ tmpRowTreeData = childRowTreeData;
+ }
+ } else {
+ return rootNode;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ // check whether we were found something and store it
+ if (tmpRowTreeData != null) {
+ rowTreeData = tmpRowTreeData;
+ oldRowKey = tmpOldRowKey;
+ }
+ return rowTreeData;
+ }
+
+ public boolean isRowAvailable() {
+ if (Boolean.FALSE.equals(rowAvailable)) {
+ return false;
+ }
+
+ T data = locateTreeNode(this.currentRowKey);
+
+ if (data != null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ public Object getRowData() {
+ if (isRowAvailable()) {
+ T treeNode = locateTreeNode(this.currentRowKey);
+ if (treeNode != null) {
+ return nodeAdaptor.getRowData(treeNode);
+ }
+
+ return null;
+ }
+
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ public boolean isLeaf() {
+ if (isRowAvailable()) {
+ T treeNode = locateTreeNode(this.currentRowKey);
+ if (treeNode != null) {
+ return nodeAdaptor.isLeaf(treeNode);
+ }
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ public void walkModel(FacesContext context, DataVisitor visitor, Range range, Object key, Object argument, boolean last) throws IOException {
+ walk(context, visitor, range, key, argument, last);
+ }
+
+ @Override
+ public Object getWrappedData() {
+ return wrappedData;
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ this.wrappedData = data;
+ }
+
+ protected T getData() {
+ return clazz.cast(wrappedData);
+ }
+
+ public TreeNode<T> getTreeNode() {
+ return null;
+ }
+
+ /**
+ * Get row key for certain tree node object
+ *
+ * @param node to get key for
+ * @return node row key
+ */
+ @Override
+ @SuppressWarnings("unchecked")
+ public Object getTreeNodeRowKey(Object node) {
+ if (node == null) {
+ throw new UnsupportedOperationException();
+ }
+
+ T childNode = (T) node;
+ List<Object> path = new LinkedList<Object>();
+ Object id = nodeAdaptor.getChildNodeId(childNode);
+ if (id != null) {
+ path.add(id);
+ }
+
+ T parentNode = childNode;
+ while ((parentNode = nodeAdaptor.getParent(parentNode)) != null) {
+ id = nodeAdaptor.getChildNodeId(parentNode);
+ if (id != null) {
+ path.add(0, id);
+ } else if (nodeAdaptor.getParent(parentNode) != null) {
+ throw new UnsupportedOperationException();
+ }
+ }
+ return new ListRowKey(path);
+ }
+
+ /**
+ * Get node local id in it's parent childs collection
+ *
+ * @param childNode node to get identifier for
+ * @return node local identifier
+ */
+ @Override
+ public Object getChildNodeId(Object childNode) {
+ return getNodeAdaptor().getChildNodeId((T) childNode);
+ }
+
+ @Override
+ public void addNode(Object parentRowKey, TreeNode newNode, Object id) {
+ addNode(parentRowKey, (Object) newNode, id);
+ }
+
+ public void addNode(Object parentRowKey, Object newNode, Object id) {
+ Object initialRowKey = getRowKey();
+ try {
+ T parentTreeNode = locateTreeNode((TreeRowKey) parentRowKey);
+
+ if (parentTreeNode == null) {
+ throw new IllegalArgumentException("Parent node not found!");
+ }
+
+ getNodeAdaptor().appendChild(parentTreeNode, id, clazz.cast(newNode));
+ } finally {
+ setRowKey(initialRowKey);
+ }
+ }
+
+ @Override
+ public void removeNode(Object rowKey) {
+ Object initialRowKey = getRowKey();
+ try {
+ T treeNode = locateTreeNode((TreeRowKey) rowKey);
+
+ if (treeNode == null) {
+ throw new IllegalArgumentException("Node not fond!");
+ }
+
+ getNodeAdaptor().removeFromParent(treeNode);
+ } finally {
+ setRowKey(initialRowKey);
+ }
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNode.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNode.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNode.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNode.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,112 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.faces.component.NamingContainer;
+
+
+/**
+ * Interface representing tree ADT nodes
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ */
+public interface TreeNode<T> extends Serializable{
+
+ /**
+ * getter for node attached data
+ * @return node attached data
+ */
+ public T getData();
+ /**
+ * setter for node attached data
+ * @param data data to set as attached node data
+ */
+ public void setData(T data);
+
+ /**
+ * Returns whether this node is leaf
+ * @return <code>true</code> if this node is leaf else returns <code>false</code>
+ */
+ public boolean isLeaf();
+
+ /**
+ * Getter for children entries. Each children entry contains identifier (key) and child node (value).
+ *
+ * Identifiers are used to generate model keys representing paths to tree node. Model keys are used:
+ * <ol>
+ * <li>
+ * For persisting tree state. That means that identifiers should be serializable when
+ * some JSF features are used, e.g. client-side state saving.
+ * </li>
+ * <li>
+ * For constructing client identifiers. Client identifier for tree nodes consists of
+ * {@link Object#toString()} representations of identifier separated with
+ * {@link NamingContainer#SEPARATOR_CHAR} chars. String representation of identifier
+ * should be a valid XML ID, e.g. conform to this: <a href="http://www.w3.org/TR/xml11/#NT-Name">
+ * XML Name Production</a>
+ * production.
+ * </li>
+ * </ol>
+ *
+ * @return {@link Iterator} of {@link Map.Entry} instances containing {@link TreeNode} as values
+ * and their identifiers as keys.
+ *
+ */
+ public Iterator<Map.Entry<Object, TreeNode<T>>> getChildren();
+ /**
+ * find child by id
+ * Please see {@link #getChildren()} for more information about identifier constraints.
+ * @param id identifier of the child to find
+ * @return designated {@link TreeNode} instance or <code>null</code>
+ */
+ public TreeNode<T> getChild(Object id);
+
+ /**
+ * adds child to children collection
+ * @param identifier child identifier.
+ * Please see {@link #getChildren()} for more information about identifier constraints.
+ * @param child child
+ */
+ public void addChild(Object identifier, TreeNode<T> child);
+
+ /**
+ * Please see {@link #getChildren()} for more information about identifier constraints.
+ * removes child from children collection by child id
+ * @param id id of the child to remove
+ */
+ public void removeChild(Object id);
+
+ /**
+ * getter for parent {@link TreeNode}
+ * @return parent {@link TreeNode} instance or <code>null</code> if this node is root
+ */
+ public TreeNode<T> getParent();
+ /**
+ * setter for parent {@link TreeNode}
+ * @param parent {@link TreeNode} to set as parent
+ */
+ public void setParent(TreeNode<T> parent);
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNodeImpl.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeNodeImpl.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNodeImpl.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeNodeImpl.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,84 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+/**
+ * Default {@link TreeNode} implementation based on {@link LinkedHashMap} to preserve
+ * elements ordering
+ *
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 16.11.2006
+ */
+public class TreeNodeImpl<T> implements TreeNode<T> {
+
+ private static final long serialVersionUID = -5498990493803705085L;
+ private T data;
+ private TreeNode<T> parent;
+
+ private Map<Object, TreeNode<T>> childrenMap =
+ new LinkedHashMap<Object, TreeNode<T>>();
+
+ public T getData() {
+ return data;
+ }
+
+ public TreeNode<T> getChild(Object identifier) {
+ return (TreeNode<T>) childrenMap.get(identifier);
+ }
+
+ public void addChild(Object identifier, TreeNode<T> child) {
+ child.setParent(this);
+ childrenMap.put(identifier, child);
+ }
+
+ public void removeChild(Object identifier) {
+ TreeNode<T> treeNode = childrenMap.remove(identifier);
+ if (treeNode != null) {
+ treeNode.setParent(null);
+ }
+ }
+
+ public void setData(T data) {
+ this.data = data;
+ }
+
+ public TreeNode<T> getParent() {
+ return parent;
+ }
+
+ public void setParent(TreeNode<T> parent) {
+ this.parent = parent;
+ }
+
+ public Iterator<Map.Entry<Object, TreeNode<T>>> getChildren() {
+ return childrenMap.entrySet().iterator();
+ }
+
+ public boolean isLeaf() {
+ return childrenMap.isEmpty();
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRange.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRange.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRange.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRange.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,66 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import org.ajax4jsf.model.Range;
+
+/**
+ * {@link Range} implmentation variant for {@link AbstractTreeDataModel}
+ *
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 23.11.2006
+ */
+public interface TreeRange extends Range {
+
+ /**
+ * Returns <code>true</code> if node with that rowKey should be processed.
+ * If <code>false</code> is returned, then skips processing child nodes also.
+ * @param rowKey {@link TreeRowKey} key instance
+ * @return <code>true</code> or <code>false</code>
+ */
+ public boolean processNode(TreeRowKey rowKey);
+
+ /**
+ * Returns <code>true</code> if children of the node with that rowKey should be processed
+ * @param rowKey {@link TreeRowKey} key instance
+ * @return <code>true</code> or <code>false</code>
+ */
+ public boolean processChildren(TreeRowKey rowKey);
+
+
+ /**
+ * Unconstrained variant of {@link TreeRange}.
+ * Is stateless and safe to use in multi-threaded environments.
+ *
+ * @since 3.2.2
+ * @author Nick Belaevski
+ */
+ public final static TreeRange RANGE_UNCONSTRAINED = new TreeRange() {
+ public boolean processChildren(TreeRowKey rowKey) {
+ return true;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+ };
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRowKey.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeRowKey.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRowKey.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/TreeRowKey.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,103 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+import java.util.Iterator;
+
+/**
+ * Base abstract clas for all tree row keys
+ * @author Nick Belaevski - nbelaevski(a)exadel.com
+ * created 06.12.2006
+ */
+public abstract class TreeRowKey<T> implements Serializable {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -7318192501938658798L;
+
+ public static final char SEPARATOR_ESCAPE_CHAR = '_';
+
+ /**
+ * getter for key depth
+ * @return key depth
+ */
+ public abstract int depth();
+
+ /**
+ * getter for subpath iterator
+ * @param fromIndex
+ * @return subpath segments iterator
+ */
+ public abstract Iterator<T> getSubPathIterator(int fromIndex);
+
+ /**
+ * getter for path string representation
+ * @return path string
+ */
+ public abstract String getPath();
+
+ public String toString() {
+ return getPath();
+ }
+
+ /**
+ * tests if specified rowKey is sub-key of this row key
+ * @param rowKey
+ * @return
+ */
+ public boolean isSubKey(TreeRowKey<T> rowKey) {
+ if (rowKey == null) {
+ return false;
+ }
+
+ String otherPath = rowKey.getPath();
+ String path = getPath();
+
+ if (otherPath.startsWith(path)) {
+ return otherPath.length() == path.length() ||
+ otherPath.charAt(path.length()) == AbstractTreeDataModel.SEPARATOR;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * getter for path iterator
+ * @return path segments iterator
+ */
+ public abstract Iterator<T> iterator();
+
+ /**
+ * returns this row key and otherRowKey argument row key common path segments count
+ * @param otherRowKey {@link TreeRowKey} to count common path segments for
+ * @return common path segmments count
+ */
+ public abstract int getCommonPathLength(TreeRowKey<T> otherRowKey);
+
+ public abstract TreeRowKey<T> getParentKey();
+
+ public TreeRowKey<T> getSubKey(int fromIndex) {
+ throw new UnsupportedOperationException();
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/ClassicTreeModelKeyConversionTest.java (from rev 14980, root/framework/trunk/api/src/test/java/org/richfaces/model/ClassicTreeModelKeyConversionTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/ClassicTreeModelKeyConversionTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/ClassicTreeModelKeyConversionTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,142 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import junit.framework.TestCase;
+
+/**
+ * Created 26.08.2008
+ * @author Nick Belaevski
+ * @since 3.2.2
+ */
+
+public class ClassicTreeModelKeyConversionTest extends TestCase {
+
+ private ClassicTreeDataModel dataModel;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ dataModel = new ClassicTreeDataModel();
+
+ TreeNodeImpl<String> rootNode = new TreeNodeImpl<String>();
+
+ TreeNodeImpl<String> node;
+
+ node = new TreeNodeImpl<String>();
+ node.addChild("0", new TreeNodeImpl<String>());
+ node.addChild("1", new TreeNodeImpl<String>());
+ for (int i = 2; i < 5; i++) {
+ node.addChild(Long.valueOf(i), new TreeNodeImpl<String>());
+ }
+ rootNode.addChild("6", node);
+
+ node = new TreeNodeImpl<String>();
+ for (int i = 0; i < 3; i++) {
+ node.addChild(Integer.valueOf(i), new TreeNodeImpl<String>());
+ }
+ rootNode.addChild("abc_cde:fgh", node);
+
+ dataModel.setWrappedData(rootNode);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ dataModel = null;
+ }
+
+ public void testEmptyString() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "", null, null);
+ assertNull(key);
+ }
+
+ public void testStraightWayShort() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "6", null, null);
+ assertNotNull(key);
+
+ Iterator<Object> iterator = key.iterator();
+ assertEquals("6", iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+
+ public void testStraightWay() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "6:1", null, null);
+ assertNotNull(key);
+
+ Iterator<Object> iterator = key.iterator();
+ assertEquals("6", iterator.next());
+ assertEquals("1", iterator.next());
+ assertFalse(iterator.hasNext());
+
+ key = (TreeRowKey<Object>) dataModel.convertToKey(null, "6:1", null, null);
+ assertNotNull(key);
+
+ iterator = key.iterator();
+ assertEquals("6", iterator.next());
+ assertEquals("1", iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+
+ public void testSearch() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "6:4", null, null);
+ assertNotNull(key);
+
+ Iterator<Object> iterator = key.iterator();
+ assertEquals("6", iterator.next());
+ assertEquals(Long.valueOf(4), iterator.next());
+ assertFalse(iterator.hasNext());
+
+ }
+
+ public void testSearchMissing() throws Exception {
+ assertNull(dataModel.convertToKey(null, "6:10", null, null));
+ assertNull(dataModel.convertToKey(null, "7", null, null));
+ }
+
+ public void testUnescape() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "abc__cde_:fgh:1", null, null);
+ assertNotNull(key);
+
+ Iterator<Object> iterator = key.iterator();
+ assertEquals("abc_cde:fgh", iterator.next());
+ assertEquals(Integer.valueOf(1), iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+
+ public void testUnescapeShort() throws Exception {
+ TreeRowKey<Object> key = (TreeRowKey<Object>) dataModel.convertToKey(null, "abc__cde_:fgh", null, null);
+ assertNotNull(key);
+
+ Iterator<Object> iterator = key.iterator();
+ assertEquals("abc_cde:fgh", iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/SwingTreeModelKeyConversionTest.java (from rev 14980, root/framework/trunk/api/src/test/java/org/richfaces/model/SwingTreeModelKeyConversionTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/SwingTreeModelKeyConversionTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree/api/src/test/java/org/richfaces/model/SwingTreeModelKeyConversionTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,109 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.Iterator;
+
+import javax.swing.tree.TreeNode;
+
+import junit.framework.TestCase;
+
+/**
+ * Created 26.08.2008
+ * @author Nick Belaevski
+ * @since 3.2.2
+ */
+
+public class SwingTreeModelKeyConversionTest extends TestCase {
+
+ private SwingTreeDataModel dataModel;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ dataModel = new SwingTreeDataModel();
+
+ //1
+ SwingTreeNodeImpl node = new SwingTreeNodeImpl();
+ //1:0
+ node.addChild(new SwingTreeNodeImpl());
+ //1:1
+ node.addChild(new SwingTreeNodeImpl());
+ //1:2
+ node.addChild(new SwingTreeNodeImpl());
+
+ dataModel.setWrappedData(new TreeNode[] {
+ new SwingTreeNodeImpl(), node
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+
+ dataModel = null;
+ }
+
+ public void testEmptyString() throws Exception {
+ //TODO make it work
+// Object key = dataModel.convertToKey(null, "", null, null);
+// assertNull(key);
+ }
+
+ public void testStraightWay() throws Exception {
+ TreeRowKey<Integer> key;
+ Iterator<Integer> iterator;
+
+ key = (TreeRowKey<Integer>) dataModel.convertToKey(null, "0", null, null);
+ iterator = key.iterator();
+ assertEquals(Integer.valueOf(0), iterator.next());
+ assertFalse(iterator.hasNext());
+
+ key = (TreeRowKey<Integer>) dataModel.convertToKey(null, "1", null, null);
+ iterator = key.iterator();
+ assertEquals(Integer.valueOf(1), iterator.next());
+ assertFalse(iterator.hasNext());
+
+ key = (TreeRowKey<Integer>) dataModel.convertToKey(null, "1:0", null, null);
+ iterator = key.iterator();
+ assertEquals(Integer.valueOf(1), iterator.next());
+ assertEquals(Integer.valueOf(0), iterator.next());
+ assertFalse(iterator.hasNext());
+
+ key = (TreeRowKey<Integer>) dataModel.convertToKey(null, "1:2", null, null);
+ iterator = key.iterator();
+ assertEquals(Integer.valueOf(1), iterator.next());
+ assertEquals(Integer.valueOf(2), iterator.next());
+ assertFalse(iterator.hasNext());
+ }
+
+ public void testMissingNodes() throws Exception {
+ assertNull(dataModel.convertToKey(null, "2", null, null));
+ assertNull(dataModel.convertToKey(null, "0:3", null, null));
+ }
+}
+
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,615 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.ajax4jsf.model.ExtendedDataModel;
+import org.ajax4jsf.model.Range;
+import org.apache.commons.collections.Predicate;
+import org.apache.commons.collections.iterators.FilterIterator;
+import org.w3c.dom.NamedNodeMap;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski mailto:nbelaevski@exadel.com created 25.07.2007
+ *
+ */
+public class StackingTreeModel extends AbstractTreeDataModel {
+
+ //ctor arguments
+ private String id;
+ private String var;
+ private StackingTreeModelDataProvider dataProvider;
+
+ //structural elements
+ private StackingTreeModel parent;
+ private Map<String, StackingTreeModel> models = new LinkedHashMap<String, StackingTreeModel>();
+
+ private Object rowKey;
+
+ private class StackEntry {
+ private Object modelKey;
+ private Object varObject;
+ private StackingTreeModel model;
+ private Object rowData;
+
+ public StackEntry(Object varObject, Object modelKey, Object rowData, StackingTreeModel model) {
+ super();
+ this.varObject = varObject;
+ this.modelKey = modelKey;
+ this.rowData = rowData;
+ this.model = model;
+ }
+ }
+
+// private StackingTreeModel stackingTreeModel;
+ private LinkedList<StackEntry> stackEntries = new LinkedList<StackEntry>();
+
+ public ExtendedDataModel getDataModel() {
+ Object data = dataProvider.getData();
+ ExtendedDataModel dataModel;
+ if (data instanceof Map || data instanceof NamedNodeMap) {
+ dataModel = new MapDataModel();
+ } else {
+ dataModel = new SequenceDataModel();
+ }
+
+ dataModel.setWrappedData(data);
+ return dataModel;
+ }
+
+ protected StackingTreeModel getCurrentModel() {
+ if (this.rowKey == null) {
+ return this;
+ }
+
+ if (isRowAvailable()) {
+ return ((StackEntry) stackEntries.getLast()).model;
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ public boolean isEmpty() {
+ //TODO optimize that
+ return getDataModel().getRowCount() == 0;
+ }
+
+ private void leaveModel(Iterator<StackEntry> iterator, StackEntry currentEntry, FacesContext context) {
+ if (iterator == null) {
+ return ;
+ }
+
+ LinkedList<StackEntry> stack = new LinkedList<StackEntry>();
+
+ StackingTreeModel lastModel = null;
+ if (currentEntry != null) {
+ iterator.remove();
+ stack.addFirst(currentEntry);
+ lastModel = currentEntry.model;
+ }
+
+ while (iterator.hasNext()) {
+ StackEntry entry = (StackEntry) iterator.next();
+ if (entry.model != lastModel) {
+ //always true for non-recursive models
+ lastModel = entry.model;
+ stack.addFirst(entry);
+ }
+
+ iterator.remove();
+ }
+
+ for (Iterator<StackEntry> iterator2 = stack.iterator(); iterator2.hasNext();) {
+ StackEntry stackEntry = (StackEntry) iterator2.next();
+ stackEntry.model.setupVariable(stackEntry.varObject, context);
+ }
+ }
+
+ protected StackingTreeModel doSetupKey(Iterator<StackingTreeModelKey> keyIterator, Iterator<StackEntry> entriesIterator, FacesContext context, Object modelKey) {
+ if (modelKey != null) {
+ if (!setupModel(modelKey, context)) {
+ //no key is available
+ leaveModel(getRoot().stackEntries.iterator(), null, context);
+ return null;
+ }
+
+ //TODO what's here?
+ }
+
+ if (keyIterator != null && keyIterator.hasNext()) {
+ StackingTreeModelKey key = keyIterator.next();
+ StackingTreeModel stackingTreeModel = this.getInternalModelById(key.modelId);
+ Iterator<StackEntry> nextEntriesIterator = null;
+ Object nextModelKey = key.modelKey;
+
+ if (entriesIterator != null && entriesIterator.hasNext()) {
+ StackEntry entry = entriesIterator.next();
+ if (!entry.model.equals(stackingTreeModel) || !entry.modelKey.equals(nextModelKey)) {
+ leaveModel(entriesIterator, entry, context);
+ } else {
+ //continue iterating entries, they still lead us by key path
+ nextEntriesIterator = entriesIterator;
+ nextModelKey = null;
+ }
+ }
+
+ //should not be called when nextEntriesIterator & nextModelKey are both valid
+ return stackingTreeModel.doSetupKey(keyIterator, nextEntriesIterator, context, nextModelKey);
+
+ } else {
+ leaveModel(entriesIterator, null, context);
+ return this;
+ }
+ }
+
+ protected StackingTreeModel setupKey(Object key, FacesContext context) {
+ if (key == this.rowKey) {
+ if (stackEntries.isEmpty()) {
+ return this;
+ } else {
+ return (stackEntries.getLast()).model;
+ }
+ } else {
+ Iterator<StackingTreeModelKey> keyIterator = null;
+ if (key != null) {
+ keyIterator = ((ListRowKey<StackingTreeModelKey>) key).iterator();
+ }
+
+ StackingTreeModel model = doSetupKey(keyIterator, stackEntries.iterator(), context, null);
+ this.rowKey = key;
+
+ return model;
+ }
+ }
+
+ public StackingTreeModel(String id, String var, StackingTreeModelDataProvider dataProvider) {
+ super();
+ this.id = id;
+ this.var = var;
+ this.dataProvider = dataProvider;
+ }
+
+ public StackingTreeModel() {
+ this(null, null, null);
+ }
+
+ private Object setupVariable(Object variable, FacesContext context) {
+ if (var != null) {
+ Map<String, Object> map = context.getExternalContext().getRequestMap();
+ return map.put(var, variable);
+ }
+
+ return null;
+ }
+
+ public boolean setupModel(Object key, FacesContext facesContext) {
+ ExtendedDataModel dataModel = getDataModel();
+ dataModel.setRowKey(key);
+
+ if (dataModel.isRowAvailable()) {
+ Object rowData = dataModel.getRowData();
+ //System.out.println("StackingTreeModel.setupModel() " + rowData);
+ Object varObject = setupVariable(rowData, facesContext);
+
+ getRoot().stackEntries.add(new StackEntry(varObject, key, rowData, this));
+
+ return true;
+ }
+
+ return false;
+ }
+
+ public void setParent(StackingTreeModel parent) {
+ this.parent = parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.AbstractTreeDataModel#getTreeNode()
+ */
+ public TreeNode getTreeNode() {
+ if (isRowAvailable()) {
+ return null;
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.AbstractTreeDataModel#isLeaf()
+ */
+ public boolean isLeaf() {
+ if (isRowAvailable()) {
+ StackEntry lastEntry = (StackEntry) stackEntries.getLast();
+ for (Iterator<StackingTreeModel> iterator = lastEntry.model.getInternalModelsIterator(); iterator.hasNext();) {
+ StackingTreeModel stackingTreeModel = iterator.next();
+
+ if (!stackingTreeModel.isEmpty()) {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ protected StackingTreeModel getRoot() {
+ if (parent != null) {
+ return parent.getRoot();
+ }
+
+ return this;
+ }
+
+ protected void doWalk(FacesContext context, DataVisitor dataVisitor,
+ Range range, ListRowKey argumentKey, Object argument,
+ boolean last) throws IOException {
+
+ TreeRange treeRange = (TreeRange) range;
+
+ if (treeRange == null || treeRange.processNode(argumentKey)) {
+ StackingTreeModel rootModel = getRoot();
+
+ if (argumentKey != null) {
+ processElement(context, dataVisitor, argument, argumentKey, last);
+ }
+
+ final ShiftingDataVisitor shiftingDataVisitor = new ShiftingDataVisitor(
+ new Visitor1(dataVisitor));
+
+ if (treeRange == null || treeRange.processChildren(argumentKey)) {
+
+ Object savedRowKey = rootModel.getRowKey();
+ //setup key in order for nested components to initialize data models
+ rootModel.setRowKey(context, argumentKey);
+ Iterator<StackingTreeModel> iterator = this.getInternalModelsIterator();
+ rootModel.setRowKey(context, savedRowKey);
+
+ while (iterator.hasNext()) {
+ final StackingTreeModel model = iterator.next();
+
+ savedRowKey = rootModel.getRowKey();
+ rootModel.setRowKey(context, argumentKey);
+ final ExtendedDataModel scalarModel = model.getDataModel();
+ rootModel.setRowKey(context, savedRowKey);
+
+ Argument argument2 = new Argument();
+ argument2.listRowKey = argumentKey;
+ argument2.argument = argument;
+ // setup current model
+ argument2.model = model;
+ argument2.range = range;
+
+ scalarModel.walk(context, new DataVisitor() {
+
+ public void process(FacesContext context,
+ Object rowKey, Object argument)
+ throws IOException {
+
+ Object key = scalarModel.getRowKey();
+ scalarModel.setRowKey(rowKey);
+ Object data = scalarModel.getRowData();
+
+ Object variable = model.setupVariable(data, context);
+ boolean activeData = model.isActiveData();
+ model.setupVariable(variable, context);
+ scalarModel.setRowKey(key);
+
+ if (activeData) {
+ shiftingDataVisitor.process(context, rowKey, argument);
+ }
+ }
+
+ }, null, argument2);
+
+ }
+ }
+
+ shiftingDataVisitor.end(context);
+ }
+ }
+
+ private StackingTreeModel getInternalModelById(String id) {
+ StackingTreeModel model = getModelById(id);
+ if (model.isActive()) {
+ return model;
+ }
+
+ throw new IllegalStateException();
+ }
+
+ public StackingTreeModel getModelById(String id) {
+ return (StackingTreeModel) models.get(id);
+ }
+
+ private Iterator<StackingTreeModel> getInternalModelsIterator() {
+ return new FilterIterator(getModelsIterator(), ACTIVE_MODEL_PREDICATE);
+ }
+
+ public Iterator<StackingTreeModel> getModelsIterator() {
+ return models.values().iterator();
+ }
+
+ public void walk(FacesContext context, DataVisitor dataVisitor,
+ Range range, Object rowKey, Object argument,
+ boolean last) throws IOException {
+ StackingTreeModel rootModel = getRoot();
+
+ if (rowKey != null) {
+ ListRowKey listRowKey = (ListRowKey) rowKey;
+
+ StackingTreeModel treeModel = rootModel.setupKey(listRowKey, context);
+
+ treeModel.doWalk(context, dataVisitor, range, listRowKey, argument,
+ last);
+
+ } else {
+ doWalk(context, dataVisitor, range,
+ (ListRowKey) rowKey, argument, last);
+ }
+ }
+
+ private class Argument {
+ private ListRowKey listRowKey;
+ private StackingTreeModel model;
+ private Range range;
+ private Object argument;
+ }
+
+ private class Visitor1 implements DataVisitor, LastElementAware {
+ private DataVisitor dataVisitor;
+ private boolean theLast;
+
+ public Visitor1(DataVisitor dataVisitor) {
+ super();
+ this.dataVisitor = dataVisitor;
+ }
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ Argument a = (Argument) argument;
+ ListRowKey listRowKey = new ListRowKey(a.listRowKey, new StackingTreeModelKey(
+ a.model.id, rowKey));
+ //System.out.println(".walk() " + (theLast ? " * " : "") + listRowKey);
+
+ a.model.doWalk(context, dataVisitor, a.range, listRowKey, a.argument,
+ theLast);
+ }
+
+ public void resetLastElement() {
+ theLast = false;
+ }
+
+ public void setLastElement() {
+ theLast = true;
+ }
+
+ }
+
+ private static class ShiftingDataVisitor implements DataVisitor {
+
+ private DataVisitor dataVisitor;
+
+ public ShiftingDataVisitor(DataVisitor dataVisitor) {
+ super();
+ this.dataVisitor = dataVisitor;
+ }
+
+ private Object rowKey;
+ private Object argument;
+ private boolean shifted = false;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ if (!shifted) {
+ this.rowKey = rowKey;
+ this.argument = argument;
+ this.shifted = true;
+ } else {
+ dataVisitor.process(context, this.rowKey, this.argument);
+ this.rowKey = rowKey;
+ this.argument = argument;
+ }
+ }
+
+ public void end(FacesContext context) throws IOException {
+ if (shifted) {
+ try {
+ ((LastElementAware) dataVisitor).setLastElement();
+ dataVisitor.process(context, this.rowKey, argument);
+ } finally {
+ ((LastElementAware) dataVisitor).resetLastElement();
+ }
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.model.AbstractTreeDataModel#walkModel(javax.faces.context.FacesContext,
+ * org.ajax4jsf.model.DataVisitor, org.ajax4jsf.model.Range,
+ * java.lang.Object, java.lang.Object, boolean)
+ */
+ public void walkModel(FacesContext facesContext, DataVisitor visitor,
+ Range range, Object key, Object argument, boolean last)
+ throws IOException {
+
+ walk(facesContext, visitor, range, key, argument, last);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
+ */
+ public Object getRowKey() {
+ return rowKey;
+ }
+
+ public void setRowKey(Object key) {
+ setRowKey(FacesContext.getCurrentInstance(), key);
+ }
+
+ public void setRowKey(FacesContext context, Object key) {
+ setupKey(key, context);
+ }
+
+ public void addStackingModel(StackingTreeModel model) {
+ this.models.put(model.id, model);
+ model.setParent(this);
+ }
+
+ public void removeStackingModel(StackingTreeModel model) {
+ this.models.remove(model.id);
+ model.setParent(null);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#getRowData()
+ */
+ public Object getRowData() {
+ if (isRowAvailable()) {
+ StackEntry lastEntry = (StackEntry) stackEntries.getLast();
+ return lastEntry.rowData;
+ }
+
+ throw new IllegalStateException(
+ "No tree element available or row key not set!");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.faces.model.DataModel#isRowAvailable()
+ */
+ public boolean isRowAvailable() {
+ return !stackEntries.isEmpty();
+ }
+
+ public StackingTreeModel getParent() {
+ return parent;
+ }
+
+ protected boolean isActiveData() {
+ return true;
+ }
+
+ protected boolean isActive() {
+ return true;
+ }
+
+ private final static Predicate ACTIVE_MODEL_PREDICATE = new Predicate() {
+
+ public boolean evaluate(Object object) {
+ StackingTreeModel model = (StackingTreeModel) object;
+ if (model == null) {
+ return false;
+ }
+
+ return model.isActive();
+ }
+
+ };
+
+ @Override
+ public Object getWrappedData() {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public void setWrappedData(Object data) {
+ throw new UnsupportedOperationException();
+ }
+
+ @Override
+ public Object convertToKey(FacesContext context, String keyString,
+ UIComponent component, Converter converter) {
+
+ //force model leave
+ setRowKey(context, null);
+
+ String[] strings = ListRowKey.fromString(keyString);
+ int l = strings.length / 2;
+ List<Object> list = new ArrayList<Object>(l);
+ StackingTreeModel model = getRoot();
+
+ for (int i = 0; i < l; i++) {
+ int idx = i*2;
+
+ String modelId = strings[idx];
+ model = model.getModelById(modelId);
+ if (model.isActive()) {
+ Object key = model.convert(context, strings[idx + 1], component, converter);
+ if (key == null) {
+ return null;
+ }
+
+ list.add(new StackingTreeModelKey(modelId, key));
+
+ if (!model.setupModel(key, context) || !model.isActiveData()) {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ return new ListRowKey<Object>(list);
+ }
+
+ protected Object convert(FacesContext context, String string,
+ UIComponent component, Converter converter) {
+
+ ConvertableKeyModel convertable = (ConvertableKeyModel) getDataModel();
+ return convertable.getKeyAsObject(context, string, component, converter);
+ }
+
+ public String getId() {
+ return id;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelDataProvider.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,33 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public interface StackingTreeModelDataProvider {
+ public Object getData();
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelKey.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,103 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.io.Serializable;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ */
+public class StackingTreeModelKey<T> implements Serializable, ComplexTreeRowKey {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6821854350257816571L;
+ protected T modelKey;
+ protected String modelId;
+
+ public StackingTreeModelKey(String modelId, T modelKey) {
+ super();
+ this.modelId = modelId;
+ this.modelKey = modelKey;
+ }
+
+ public String toString() {
+ return this.modelId + AbstractTreeDataModel.SEPARATOR + this.modelKey;
+ }
+
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((modelId == null) ? 0 : modelId.hashCode());
+ result = prime * result
+ + ((modelKey == null) ? 0 : modelKey.hashCode());
+ return result;
+ }
+
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final StackingTreeModelKey other = (StackingTreeModelKey) obj;
+ if (modelId == null) {
+ if (other.modelId != null)
+ return false;
+ } else if (!modelId.equals(other.modelId))
+ return false;
+ if (modelKey == null) {
+ if (other.modelKey != null)
+ return false;
+ } else if (!modelKey.equals(other.modelKey))
+ return false;
+ return true;
+ }
+
+ public String getModelId() {
+ return modelId;
+ }
+
+ public Object getModelKey() {
+ return modelKey;
+ }
+
+ public int getKeySegmentsCount() {
+ return 2;
+ }
+
+ public Object getKeySegment(int i) {
+ switch (i) {
+ case 0:
+ return modelId;
+ case 1:
+ return modelKey;
+
+ default:
+ throw new IllegalArgumentException(String.valueOf(i));
+ }
+ }
+}
\ No newline at end of file
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/StackingTreeModelProvider.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,78 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski mailto:nbelaevski@exadel.com created 25.07.2007
+ *
+ */
+public abstract class StackingTreeModelProvider extends UIComponentBase {
+
+ public abstract Object getNodes();
+ public abstract void setNodes(Object nodes);
+
+ public Object getData() {
+ return getNodes();
+ }
+
+ protected abstract StackingTreeModel createStackingTreeModel();
+
+ private List<StackingTreeModel> createChildModelsList() {
+ List<StackingTreeModel> childModels = new ArrayList<StackingTreeModel>();
+
+ if (getChildCount() > 0) {
+ Iterator<UIComponent> children = getChildren().iterator();
+ while (children.hasNext()) {
+ UIComponent component = children.next();
+ if (component instanceof StackingTreeModelProvider) {
+ StackingTreeModelProvider provider = (StackingTreeModelProvider) component;
+ childModels.add(provider.getStackingModel());
+ }
+ }
+ }
+
+ return childModels;
+ }
+
+ protected void addChildModels(StackingTreeModel model, List<StackingTreeModel> childModels) {
+ for (StackingTreeModel childModel : childModels) {
+ model.addStackingModel(childModel);
+ }
+ }
+
+ public StackingTreeModel getStackingModel() {
+ StackingTreeModel stackingTreeModel = createStackingTreeModel();
+
+ addChildModels(stackingTreeModel, createChildModelsList());
+
+ return stackingTreeModel;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeDataModelNodeAdaptor.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,278 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.model;
+
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreeNode;
+
+/**
+ * {@link TreeDataModel} adaptor for generic types. Contains adaptors for Swing & classic ({@link TreeNode})
+ * tree node types embedded into this interface as static instances
+ *
+ * Created 01.11.2007
+ *
+ * @author Nick Belaevski
+ * @since 3.2
+ */
+
+public interface TreeDataModelNodeAdaptor<T> {
+ public T getParent(T node);
+
+ public boolean isLeaf(T node);
+
+ public T getChild(T node, Object key);
+
+ public Iterator<Map.Entry<Object, T>> getChildren(T node);
+
+ public Object getRowData(T node);
+
+ /**
+ * Get node local id in it's parent childs collection
+ *
+ * @param childNode node to get identifier for
+ * @return node local identifier
+ */
+ public Object getChildNodeId(T childNode);
+
+ public void appendChild(T parentNode, Object key, T childNode);
+
+ public void removeFromParent(T childNode);
+
+ /**
+ * Instance of {@link TreeDataModelNodeAdaptor} for {@link org.richfaces.model.TreeNode} nodes handling
+ */
+ @SuppressWarnings("unchecked")
+ public static final TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode> classicTreeNodeAdaptor =
+ new TreeDataModelNodeAdaptor<org.richfaces.model.TreeNode>() {
+
+ public org.richfaces.model.TreeNode getChild(org.richfaces.model.TreeNode node, Object key) {
+ return node.getChild(key);
+ }
+
+ public Iterator<Entry<Object, org.richfaces.model.TreeNode>> getChildren(
+ org.richfaces.model.TreeNode node) {
+ return node.getChildren();
+ }
+
+ public org.richfaces.model.TreeNode getParent(org.richfaces.model.TreeNode node) {
+ return node.getParent();
+ }
+
+ public Object getRowData(org.richfaces.model.TreeNode node) {
+ return node.getData();
+ }
+
+ public boolean isLeaf(org.richfaces.model.TreeNode node) {
+ return node.isLeaf();
+ }
+
+ /**
+ * Get node local id in it's parent childs collection
+ *
+ * @param childNode node to get identifier for
+ * @return node local identifier
+ */
+ public Object getChildNodeId(org.richfaces.model.TreeNode childNode) {
+ org.richfaces.model.TreeNode parentNode = getParent(childNode);
+ if (childNode != null && parentNode != null) {
+ Iterator<Map.Entry<Object, TreeNode>> iter = parentNode.getChildren();
+ while (iter != null && iter.hasNext()) {
+ Map.Entry<Object, TreeNode> entry = iter.next();
+ if (entry != null && childNode.equals(entry.getValue())) {
+ return entry.getKey();
+ }
+ }
+ }
+ return null;
+ }
+
+ public void appendChild(org.richfaces.model.TreeNode parentNode,
+ Object childKey, org.richfaces.model.TreeNode childNode) {
+
+ parentNode.addChild(childKey, childNode);
+ }
+
+ public void removeFromParent(org.richfaces.model.TreeNode childNode) {
+ org.richfaces.model.TreeNode parent = childNode.getParent();
+ Object childNodeId = getChildNodeId(childNode);
+ if (childNodeId != null) {
+ parent.removeChild(childNodeId);
+ }
+ }
+ };
+
+ /**
+ * Instance of {@link TreeDataModelNodeAdaptor} for {@link javax.swing.tree.TreeNode} nodes handling
+ */
+ public static final TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode> swingTreeNodeAdaptor =
+ new TreeDataModelNodeAdaptor<javax.swing.tree.TreeNode>() {
+
+ final class SwingNodeMapEntry implements Map.Entry<Object, TreeNode> {
+
+ private Object key;
+ private TreeNode child;
+
+ public SwingNodeMapEntry(int i, TreeNode child) {
+ this.key = Integer.valueOf(i);
+ this.child = child;
+ }
+
+ public Object getKey() {
+ return this.key;
+ }
+
+ public TreeNode getValue() {
+ return child;
+ }
+
+ public TreeNode setValue(TreeNode value) {
+ TreeNode node = this.child;
+ this.child = value;
+
+ return node;
+ }
+
+ };
+
+ public javax.swing.tree.TreeNode getChild(
+ javax.swing.tree.TreeNode node, Object key) {
+
+ int intKey = ((Integer) key).intValue();
+ if (intKey < node.getChildCount() && intKey >= 0) {
+ return node.getChildAt(intKey);
+ }
+
+ return null;
+ }
+
+ public Iterator<Entry<Object, javax.swing.tree.TreeNode>> getChildren(
+ final javax.swing.tree.TreeNode node) {
+
+ if (node.getAllowsChildren()) {
+ return new Iterator<Entry<Object,javax.swing.tree.TreeNode>>() {
+
+ private final Enumeration<?> e = node.children();
+ private int counter = 0;
+
+ public boolean hasNext() {
+ return e.hasMoreElements();
+ }
+
+ public Entry<Object, javax.swing.tree.TreeNode> next() {
+ javax.swing.tree.TreeNode child = (javax.swing.tree.TreeNode) e.nextElement();
+ SwingNodeMapEntry entry = new SwingNodeMapEntry(counter++, child);
+ return entry;
+
+ }
+
+ public void remove() {
+ throw new UnsupportedOperationException();
+ }
+
+ };
+ }
+
+ return null;
+ }
+
+ public javax.swing.tree.TreeNode getParent(
+ javax.swing.tree.TreeNode node) {
+ return node.getParent();
+ }
+
+ public Object getRowData(javax.swing.tree.TreeNode node) {
+ return node;
+ }
+
+ public boolean isLeaf(javax.swing.tree.TreeNode node) {
+ return !node.getAllowsChildren() || node.isLeaf();
+ }
+
+ /**
+ * Get node local id in it's parent childs collection
+ *
+ * @param childNode node to get identifier for
+ * @return node local identifier
+ */
+ public Object getChildNodeId(javax.swing.tree.TreeNode childNode) {
+ javax.swing.tree.TreeNode parentNode = getParent(childNode);
+ if (childNode != null && parentNode != null) {
+ int idx = parentNode.getIndex(childNode);
+ if (idx != -1) {
+ return idx;
+ } else {
+ return null;
+ }
+ } else {
+ return null;
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void appendChild(javax.swing.tree.TreeNode parentNode, Object key,
+ javax.swing.tree.TreeNode childNode) {
+
+ if (childNode instanceof MutableTreeNode) {
+ MutableTreeNode mutableChildNode = (MutableTreeNode) childNode;
+ MutableTreeNode mutableParentNode = (MutableTreeNode) parentNode;
+ int idx;
+
+ if (key != null) {
+ idx = (Integer) key;
+ } else {
+ idx = mutableParentNode.getChildCount();
+ }
+
+ mutableParentNode.insert(mutableChildNode, idx);
+ } else {
+ SwingTreeNodeImpl swingTreeNodeImpl = (SwingTreeNodeImpl) childNode;
+ SwingTreeNodeImpl parent = (SwingTreeNodeImpl) parentNode;
+
+ if (key != null) {
+ parent.addChild(key, swingTreeNodeImpl);
+ } else {
+ parent.addChild(swingTreeNodeImpl);
+ }
+
+ swingTreeNodeImpl.setParent(parent);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ public void removeFromParent(javax.swing.tree.TreeNode node) {
+ if (node instanceof MutableTreeNode) {
+ ((MutableTreeNode) node).removeFromParent();
+ } else {
+ SwingTreeNodeImpl swingTreeNodeImpl = (SwingTreeNodeImpl) node;
+ SwingTreeNodeImpl parent = (SwingTreeNodeImpl) swingTreeNodeImpl.getParent();
+
+ parent.removeChild(swingTreeNodeImpl);
+ swingTreeNodeImpl.setParent(null);
+ }
+ }
+ };
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/TreeModelVisualComponentProvider.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,35 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 29.07.2007
+ *
+ */
+public interface TreeModelVisualComponentProvider {
+ public UIComponent getComponent();
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/VisualStackingTreeModel.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,61 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import javax.faces.component.UIComponent;
+
+/**
+ * That is intended for internal use
+ *
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 15.08.2007
+ *
+ */
+public class VisualStackingTreeModel extends StackingTreeModel implements TreeModelVisualComponentProvider {
+ private UIComponent component;
+
+ public VisualStackingTreeModel(UIComponent component) {
+ super();
+
+ this.component = component;
+ }
+
+ public VisualStackingTreeModel(String id, String var,
+ StackingTreeModelDataProvider dataProvider, UIComponent component) {
+ super(id, var, dataProvider);
+
+ this.component = component;
+ }
+
+ public UIComponent getComponent() {
+ if (this.component != null) {
+ return this.component;
+ }
+
+ StackingTreeModel currentModel = getCurrentModel();
+ if (currentModel != null && currentModel != this) {
+ return ((TreeModelVisualComponentProvider) currentModel).getComponent();
+ }
+
+ return null;
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/StackingTreeDataModelTest.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,450 @@
+/**
+ *
+ */
+package org.richfaces.model;
+
+import java.io.IOException;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.ajax4jsf.model.DataVisitor;
+import org.richfaces.model.entity.Directory;
+import org.richfaces.model.entity.File;
+import org.richfaces.model.entity.Named;
+import org.richfaces.model.entity.Project;
+import org.richfaces.test.AbstractFacesTest;
+
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class StackingTreeDataModelTest extends AbstractFacesTest {
+
+ private StackingTreeModel stackingTreeModel;
+ private StackingTreeModel projectsModel;
+ private StackingTreeModel directoriesModel;
+ private StackingTreeModel filesModel;
+
+ private Object projectRequestObject;
+ private Object directoryRequestObject;
+ private Object fileRequestObject;
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ setupFacesRequest();
+ this.stackingTreeModel = new StackingTreeModel();
+ projectsModel = new StackingTreeModel("project", "project", new StackingTreeModelDataProvider() {
+
+ private Map<String, Project> data = null;
+
+ public Object getData() {
+ if (data == null) {
+ data = new LinkedHashMap<String, Project>();
+ Project projectA = new Project("projectA", 10);
+
+ Directory adir1 = new Directory("ADir1", 50);
+
+ adir1.addFile(new File("AFile1", 60));
+ adir1.addFile(new File("AFile2", 61));
+
+ Directory adir2 = new Directory("ADir2", 101);
+
+ projectA.addDirectory(adir1);
+ projectA.addDirectory(adir2);
+
+ data.put(projectA.getName(), projectA);
+
+ Project projectB = new Project("projectB", 501);
+
+ Directory bdir1 = new Directory("BDir1", 600);
+ Directory bdir2 = new Directory("BDir2", 700);
+ Directory bdir3 = new Directory("BDir3", 801);
+
+ projectB.addDirectory(bdir1);
+ projectB.addDirectory(bdir2);
+ projectB.addDirectory(bdir3);
+
+ data.put(projectB.getName(), projectB);
+ }
+ return data;
+ }
+ });
+ final ValueBinding dirVB = application.createValueBinding("#{project.directories}");
+ directoriesModel = new StackingTreeModel("directory", "directory", new StackingTreeModelDataProvider() {
+ public Object getData() {
+ return dirVB.getValue(facesContext);
+ }
+ });
+ final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
+ filesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
+ public Object getData() {
+ return fileVB.getValue(facesContext);
+ }
+ });
+ directoriesModel.addStackingModel(filesModel);
+ projectsModel.addStackingModel(directoriesModel);
+ this.stackingTreeModel.addStackingModel(projectsModel);
+
+ projectRequestObject = new Object();
+ directoryRequestObject = new Object();
+ fileRequestObject = new Object();
+
+ Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+ requestMap.put("project", projectRequestObject);
+ requestMap.put("directory", directoryRequestObject);
+ requestMap.put("file", fileRequestObject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ super.tearDown();
+ this.stackingTreeModel = null;
+ this.projectsModel = null;
+ this.directoriesModel = null;
+ this.filesModel = null;
+
+ this.projectRequestObject = null;
+ this.directoryRequestObject = null;
+ this.fileRequestObject = null;
+ }
+
+ public void testWalk() throws Exception {
+ StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
+ this.stackingTreeModel.walk(facesContext, visitor1, null, null);
+ assertEquals(9, visitor1.getCounter());
+ this.stackingTreeModel.setRowKey(null);
+ assertFalse(this.stackingTreeModel.isRowAvailable());
+
+ Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
+ assertSame(this.projectRequestObject, requestMap.get("project"));
+ assertSame(this.directoryRequestObject, requestMap.get("directory"));
+ assertSame(this.fileRequestObject, requestMap.get("file"));
+ }
+
+ public void testBadKey() throws Exception {
+ StackingTreeDataModelTestVisitor1 visitor1 = new StackingTreeDataModelTestVisitor1();
+ this.stackingTreeModel.walk(facesContext, visitor1, null, null);
+ this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModelKey("project", "projectA")));
+ assertTrue(this.stackingTreeModel.isRowAvailable());
+ assertNotNull(this.stackingTreeModel.getRowData());
+
+ assertNull(this.stackingTreeModel.getTreeNode());
+ assertFalse(this.stackingTreeModel.isLeaf());
+
+ this.stackingTreeModel.setRowKey(new ListRowKey(new StackingTreeModelKey("project", "projectAAAAA")));
+ assertFalse(this.stackingTreeModel.isRowAvailable());
+ try {
+ Object rowData = this.stackingTreeModel.getRowData();
+ assertNull(rowData);
+ //FIXME: Maksim - bad keys happen for a reason
+ //fail();
+ } catch (Exception e) {
+
+ }
+
+ try {
+ boolean leaf = this.stackingTreeModel.isLeaf();
+ assertTrue(leaf);
+ //FIXME: Maksim - bad keys happen for a reason
+ //fail();
+ } catch (Exception e) {
+
+ }
+
+ try {
+ TreeNode node = this.stackingTreeModel.getTreeNode();
+ assertNull(node);
+ //FIXME: Maksim - bad keys happen for a reason
+ //fail();
+ } catch (Exception e) {
+
+ }
+ }
+
+ public void testActiveData() throws Exception {
+ final ValueBinding fileVB = application.createValueBinding("#{directory.files}");
+ StackingTreeModel localFilesModel = new StackingTreeModel("file", "file", new StackingTreeModelDataProvider() {
+ public Object getData() {
+ return fileVB.getValue(facesContext);
+ }
+
+ }) {
+ protected boolean isActiveData() {
+ Map requestMap = facesContext.getExternalContext().getRequestMap();
+ Object object = requestMap.get("file");
+ assertNotNull(object);
+ File file = (File) object;
+ if (file.getTag() == 61) {
+ return false;
+ }
+
+ return super.isActiveData();
+ }
+ };
+ directoriesModel.removeStackingModel(filesModel);
+ directoriesModel.addStackingModel(localFilesModel);
+
+ stackingTreeModel.walk(facesContext, new StackingTreeDataModelTestVisitor3(), null, null);
+ }
+
+ public void testKey() throws Exception {
+ StackingTreeModelKey key = new StackingTreeModelKey("aaa", new Integer(10));
+ StackingTreeModelKey key2 = new StackingTreeModelKey("aaa", new Integer(11));
+ StackingTreeModelKey key3 = new StackingTreeModelKey("aaa", new Integer(10));
+ StackingTreeModelKey key4 = new StackingTreeModelKey("bbb", new Integer(10));
+
+ assertFalse(key.equals(new StackingTreeModelKey("aaa", new Integer(0)) {} ));
+
+ assertTrue(key.equals(key3));
+ assertTrue(key3.equals(key));
+ assertTrue(key2.equals(key2));
+ assertTrue(key4.equals(key4));
+
+ assertTrue(key.hashCode() == key3.hashCode());
+ assertTrue(key3.hashCode() == key.hashCode());
+ assertTrue(key2.hashCode() == key2.hashCode());
+ assertTrue(key4.hashCode() == key4.hashCode());
+
+ assertFalse(key.equals(key2));
+ assertFalse(key3.equals(key2));
+ assertFalse(key2.equals(key));
+ assertFalse(key2.equals(key3));
+
+ assertFalse(key.hashCode() == key2.hashCode());
+ assertFalse(key3.hashCode() == key2.hashCode());
+ assertFalse(key2.hashCode() == key.hashCode());
+ assertFalse(key2.hashCode() == key3.hashCode());
+
+ assertFalse(key4.equals(key));
+ assertFalse(key4.equals(key2));
+ assertFalse(key4.equals(key3));
+
+ assertFalse(key4.hashCode() == key.hashCode());
+ assertFalse(key4.hashCode() == key2.hashCode());
+ assertFalse(key4.hashCode() == key3.hashCode());
+
+ assertFalse(key.equals(key4));
+ assertFalse(key2.equals(key4));
+ assertFalse(key3.equals(key4));
+
+ assertFalse(new StackingTreeModelKey("aaa", new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(null));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(null));
+ assertFalse(new StackingTreeModelKey(null, null).equals(null));
+
+ assertFalse(key.hashCode() == key4.hashCode());
+ assertFalse(key2.hashCode() == key4.hashCode());
+ assertFalse(key3.hashCode() == key4.hashCode());
+
+ assertFalse(key.hashCode() == 0);
+ assertFalse(key2.hashCode() == 0);
+ assertFalse(key3.hashCode() == 0);
+ assertFalse(key4.hashCode() == 0);
+
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).equals(new StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey(null, new Integer(11))));
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).equals(new StackingTreeModelKey("aaa", new Integer(10))));
+
+ assertTrue(new StackingTreeModelKey(null, new Integer(11)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey(null, new Integer(11)).hashCode());
+ assertFalse(new StackingTreeModelKey(null, new Integer(10)).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
+
+ assertTrue(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("bbb", null)));
+ assertFalse(new StackingTreeModelKey("aaa", null).equals(new StackingTreeModelKey("aaa", new Integer(10))));
+
+ assertTrue(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("bbb", null).hashCode());
+ assertFalse(new StackingTreeModelKey("aaa", null).hashCode() == new StackingTreeModelKey("aaa", new Integer(10)).hashCode());
+ }
+
+ class StackingTreeDataModelTestVisitor1 implements DataVisitor, LastElementAware {
+
+ private boolean last;
+ private int tag = 0;
+ private int counter = 0;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ StackingTreeDataModelTestVisitor2 visitor2 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor2, null, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
+ argument, false);
+
+ assertEquals(5, visitor2.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor20 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor20, new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return false;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return false;
+ }
+
+ }, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
+ argument, false);
+
+ assertEquals(0, visitor20.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor21 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor21, new TreeRange() {
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ return false;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+
+ }, new ListRowKey(new StackingTreeModelKey("project", "projectA")),
+ argument, false);
+
+ assertEquals(1, visitor21.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor22 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor22, null, new ListRowKey(new StackingTreeModelKey("project", "projectB")),
+ argument, false);
+
+ assertEquals(4, visitor22.getCounter());
+
+ StackingTreeDataModelTestVisitor2 visitor23 = new StackingTreeDataModelTestVisitor2();
+
+ stackingTreeModel.walk(context, visitor23, new TreeRange() {
+
+ private boolean rootProcessed = false;
+
+ public boolean processChildren(TreeRowKey rowKey) {
+ boolean result = rootProcessed;
+ rootProcessed = true;
+ return !result;
+ }
+
+ public boolean processNode(TreeRowKey rowKey) {
+ return true;
+ }
+
+ }, new ListRowKey(new StackingTreeModelKey("project", "projectB")),
+ argument, false);
+
+ assertEquals(4, visitor23.getCounter());
+
+ stackingTreeModel.setRowKey(rowKey);
+
+ assertSame(rowKey, stackingTreeModel.getRowKey());
+
+ assertNull(stackingTreeModel.getTreeNode());
+ Object rowData = stackingTreeModel.getRowData();
+ assertNotNull(rowData);
+ assertTrue(rowData instanceof Named);
+
+ Named named = (Named) rowData;
+
+ int currentTag = named.getTag();
+ assertTrue(currentTag > tag);
+ this.tag = currentTag;
+
+ if (this.tag % 10 == 1) {
+ assertTrue(last);
+ } else {
+ assertFalse(last);
+ }
+
+ if (named instanceof Directory) {
+ if ("ADir1".equals(named.getName())) {
+ assertFalse(stackingTreeModel.isLeaf());
+ } else {
+ assertTrue(stackingTreeModel.isLeaf());
+ }
+ } else if (named instanceof Project) {
+ assertFalse(stackingTreeModel.isLeaf());
+ } else if (named instanceof File) {
+ assertTrue(stackingTreeModel.isLeaf());
+ } else {
+ fail();
+ }
+
+ counter++;
+ }
+
+ public void resetLastElement() {
+ this.last = false;
+ }
+
+ public void setLastElement() {
+ this.last = true;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+ }
+
+ class StackingTreeDataModelTestVisitor2 implements DataVisitor {
+ private int counter = 0;
+ private int tag = 0;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ stackingTreeModel.setRowKey(rowKey);
+ Object rowData = stackingTreeModel.getRowData();
+ assertNotNull(rowData);
+ Named named = (Named) rowData;
+
+ int currentTag = named.getTag();
+ assertTrue(currentTag > tag);
+ tag = currentTag;
+ counter++;
+ }
+
+ public int getCounter() {
+ return counter;
+ }
+ }
+
+ class StackingTreeDataModelTestVisitor3 implements DataVisitor, LastElementAware {
+
+ private boolean last;
+
+ public void process(FacesContext context, Object rowKey, Object argument)
+ throws IOException {
+
+ stackingTreeModel.setRowKey(rowKey);
+ Named named = (Named) stackingTreeModel.getRowData();
+ int tag = named.getTag();
+
+ if (tag == 60) {
+ assertTrue(last);
+ }
+ assertFalse(tag == 61);
+ }
+
+ public void resetLastElement() {
+ this.last = false;
+ }
+
+ public void setLastElement() {
+ this.last = true;
+ }
+ }
+}
+
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Directory.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/Directory.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Directory.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Directory.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,30 @@
+/**
+ *
+ */
+package org.richfaces.model.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class Directory extends Named {
+
+ public Directory(String name, int tag) {
+ super(name, tag);
+ }
+
+ private List files = new ArrayList();
+
+ public List getFiles() {
+ return files;
+ }
+
+ public void addFile(File file) {
+ this.files.add(file);
+ }
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/File.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/File.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/File.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/File.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,18 @@
+/**
+ *
+ */
+package org.richfaces.model.entity;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class File extends Named {
+
+ public File(String name, int tag) {
+ super(name, tag);
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Named.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/Named.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Named.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Named.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,27 @@
+/**
+ *
+ */
+package org.richfaces.model.entity;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class Named {
+ private String name;
+ private int tag;
+ public String getName() {
+ return name;
+ }
+ public int getTag() {
+ return tag;
+ }
+ public Named(String name, int tag) {
+ super();
+ this.name = name;
+ this.tag = tag;
+ }
+
+}
Copied: root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Project.java (from rev 14980, root/framework/trunk/impl/src/test/java/org/richfaces/model/entity/Project.java)
===================================================================
--- root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Project.java (rev 0)
+++ root/ui-sandbox/trunk/components/tree-model/api/src/test/java/org/richfaces/model/entity/Project.java 2009-07-23 16:41:49 UTC (rev 14985)
@@ -0,0 +1,29 @@
+/**
+ *
+ */
+package org.richfaces.model.entity;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nick Belaevski
+ * mailto:nbelaevski@exadel.com
+ * created 30.07.2007
+ *
+ */
+public class Project extends Named {
+ public Project(String name, int tag) {
+ super(name, tag);
+ }
+
+ private List directories = new ArrayList();
+
+ public List getDirectories() {
+ return directories;
+ }
+
+ public void addDirectory(Directory directory) {
+ directories.add(directory);
+ }
+}
15 years, 5 months
JBoss Rich Faces SVN: r14984 - root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 11:08:56 -0400 (Thu, 23 Jul 2009)
New Revision: 14984
Added:
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java
Log:
Calendar component API moved
Copied: root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModel.java)
===================================================================
--- root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java (rev 0)
+++ root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModel.java 2009-07-23 15:08:56 UTC (rev 14984)
@@ -0,0 +1,44 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+import java.util.Date;
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+public interface CalendarDataModel {
+
+ /**
+ * @return array of CalendarDataModelItems for selected dates.
+ * This method will be called every time when components will need next block of CalendarDataItems.
+ * That may happens when calendar rendered, or when user navigate to next(previous) month or in any other case when calendar renders.
+ * This method will be called in Ajax mode when Calendar renders new page.
+ * */
+ public CalendarDataModelItem[] getData(Date[] dateArray);
+
+ /**
+ * @return tool tip when it's used in "single" mode
+ * This method used when tool tips are displayed in "single" mode
+ * */
+ public Object getToolTip(Date date);
+}
Copied: root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java (from rev 14980, root/framework/trunk/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java)
===================================================================
--- root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java (rev 0)
+++ root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/CalendarDataModelItem.java 2009-07-23 15:08:56 UTC (rev 14984)
@@ -0,0 +1,68 @@
+/**
+ * License Agreement.
+ *
+ * JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+package org.richfaces.model;
+
+
+
+/**
+ * @author Alexej Kushunin
+ * created 19.06.2007
+ *
+ */
+
+public interface CalendarDataModelItem {
+
+ /**
+ *@return true if date is �selectable� on calendar, default implementation return true
+ **/
+ public boolean isEnabled();
+
+ /**
+ * @return String that will be appended to style class for that date span.
+ * For example it may be �relevant holyday� � that mean class will be like �rich-cal-day relevant holyday�.
+ * Default implementation return empty string.
+ * */
+ public String getStyleClass();
+
+ /**
+ * @return any additional payload that must be JSON-serialazable object.
+ * May be used in custom date representation on calendar (inside custom facet).*/
+ public Object getData();
+
+ /**
+ * @return true if given date has an associated with it tooltip data.
+ * Default implementation return false.*/
+ public boolean hasToolTip();
+
+ /**
+ *@return tool tip data that will be used in �batch� tooltip loading mode.
+ **/
+ public Object getToolTip();
+
+ /**
+ *@return day of the month on which data must be shown.
+ **/
+ public int getDay();
+
+}
+
+
+
15 years, 5 months
JBoss Rich Faces SVN: r14983 - in root/ui-sandbox/trunk/components: calendar and 21 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 11:01:55 -0400 (Thu, 23 Jul 2009)
New Revision: 14983
Added:
root/ui-sandbox/trunk/components/calendar/
root/ui-sandbox/trunk/components/calendar/api/
root/ui-sandbox/trunk/components/calendar/api/src/
root/ui-sandbox/trunk/components/calendar/api/src/main/
root/ui-sandbox/trunk/components/calendar/api/src/main/java/
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/calendar/api/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tree-model/
root/ui-sandbox/trunk/components/tree-model/api/
root/ui-sandbox/trunk/components/tree-model/api/src/
root/ui-sandbox/trunk/components/tree-model/api/src/main/
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/tree-model/api/src/main/java/org/richfaces/model/
root/ui-sandbox/trunk/components/tree/
root/ui-sandbox/trunk/components/tree/api/
root/ui-sandbox/trunk/components/tree/api/src/
root/ui-sandbox/trunk/components/tree/api/src/main/
root/ui-sandbox/trunk/components/tree/api/src/main/java/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/component/xml/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/event/
root/ui-sandbox/trunk/components/tree/api/src/main/java/org/richfaces/model/
Log:
Created placeholder for calendar/tree framework APIs
15 years, 5 months
JBoss Rich Faces SVN: r14982 - in root: ui-sandbox and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 10:03:32 -0400 (Thu, 23 Jul 2009)
New Revision: 14982
Added:
root/ui-sandbox/
root/ui-sandbox/trunk/
root/ui-sandbox/trunk/components/
root/ui-sandbox/trunk/components/framework-api/
root/ui-sandbox/trunk/components/framework-impl/
Log:
ui-sandbox module added
15 years, 5 months
JBoss Rich Faces SVN: r14981 - in root/framework/trunk: impl/src/main/java/org/ajax4jsf and 14 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-07-23 10:00:42 -0400 (Thu, 23 Jul 2009)
New Revision: 14981
Removed:
root/framework/trunk/impl/src/main/java/org/ajax4jsf/FastFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/Filter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/org/w3c/tidy/
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/nekko/
root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/tidy/
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/AttributesImplSerializer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/CharInfo.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/DOMSerializer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemContext.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemDesc.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EmptySerializer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EncodingInfo.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Encodings.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedContentHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedLexicalHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Method.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ObjectFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertiesFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertyUtils.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport12.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializationHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Serializer.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerBase.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerConstants.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerFactory.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTrace.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTraceWriter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLSAXHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToSAXHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextSAXHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToUnknownStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLSAXHandler.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLStream.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TransformStateSetter.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TreeWalker.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Version.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterChain.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToASCI.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToUTF8Buffered.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/XSLOutputAttributes.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/package-info.java
root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/utils/
root/framework/trunk/impl/src/test/java/org/ajax4jsf/framework/ajax/xmlfilter/nekko/
root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java
Modified:
root/framework/trunk/impl/
root/framework/trunk/impl/pom.xml
root/framework/trunk/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml
root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/AllParsingTests.java
root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
root/framework/trunk/test-base/src/main/resources/org/richfaces/test/web.xml
root/framework/trunk/test-base/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml
root/framework/trunk/version-matrix/pom.xml
Log:
https://jira.jboss.org/jira/browse/RF-7553
https://jira.jboss.org/jira/browse/RF-7554
Added seam-mock dependency
MutlipartRequest invalid import removed
XML files edited to make them IDE-valid
Property changes on: root/framework/trunk/impl
___________________________________________________________________
Name: svn:ignore
- target
.settings
.project
.classpath
.clover
+ target
.settings
.project
.classpath
.clover
bin
Modified: root/framework/trunk/impl/pom.xml
===================================================================
--- root/framework/trunk/impl/pom.xml 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/pom.xml 2009-07-23 14:00:42 UTC (rev 14981)
@@ -145,11 +145,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>net.sourceforge.nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>org.jboss.cache</groupId>
<artifactId>jbosscache-core</artifactId>
<optional>true</optional>
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/FastFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/FastFilter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/FastFilter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,27 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf;
-
-
-public class FastFilter extends org.ajax4jsf.webapp.NekkoFilter {
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/Filter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/Filter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/Filter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,35 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf;
-
-import org.ajax4jsf.webapp.ConfigurableFilter;
-
-/**
- * Proxy for resource/ajax xml parsing filter.
- *
- * @author asmirnov(a)exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:29 $
- *
- */
-public class Filter extends ConfigurableFilter {
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/io/parser/FastHtmlParser.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,258 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.io.parser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Writer;
-import java.lang.reflect.Field;
-
-import org.ajax4jsf.io.FastBufferReader;
-import org.ajax4jsf.webapp.HtmlParser;
-import org.ajax4jsf.xml.serializer.Method;
-import org.ajax4jsf.xml.serializer.OutputPropertiesFactory;
-import org.ajax4jsf.xml.serializer.Serializer;
-import org.ajax4jsf.xml.serializer.SerializerFactory;
-import org.ajax4jsf.xml.serializer.TreeWalker;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Node;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * Simplified and fast HTML parsed - for find insertion point of <html><head>
- * there can be inserted <script><style> and <meta> tags.
- *
- * @author shura
- *
- */
-public class FastHtmlParser implements HtmlParser {
-
- private static final Log log = LogFactory.getLog(FastHtmlParser.class);
-
- private String encoding;
-
- private String doctype;
-
- private String viewState;
-
- private String mimeType;
-
- private Node[] headEvents;
-
- public void parse(Reader in, Writer out) throws IOException {
- boolean haveHtml = false;
- boolean haveHead = false;
- boolean closingElement = false;
-//see if any characters has been written http://jira.jboss.com/jira/browse/RF-3685
- boolean parsed = false;
-// Always parse content, see http://jira.jboss.com/jira/browse/RF-3577
-// if (null != scripts || null != styles || null != userStyles) {
- ParsingStateManager stateManager = ParsingStateManager
- .getInstance();
- ParserState state = stateManager.getInitialState();
- ParsingContext context = new ParsingContext(out);
- int nextChar;
- while ((nextChar = in.read()) > 0) {
- parsed = true;
- char c = (char)nextChar;
- state = state.getNextState(c, context);
- if (log.isDebugEnabled()) {
- // Find state name.
- Class<? extends ParsingStateManager> stateMgrClass = stateManager.getClass();
- Field[] fields = stateMgrClass.getDeclaredFields();
- for (int i = 0; i < fields.length; i++) {
- Field field = fields[i];
- try {
- if (field.get(stateManager) == state) {
- log
- .debug("Parser reached state is StateManager."
- + field.getName());
- break;
- }
- } catch (Exception e) {
- // ignore ...
- }
- }
- }
- state.send(c, context);
- if (state == stateManager.LT) {
- closingElement = false;
- } else if (state == stateManager.CLOSINGELEMENT) {
- closingElement = true;
- } else if (state == stateManager.ENDELEMENT) {
- if (context.getLastMatched() == stateManager.HTML) {
- haveHtml = true;
- //if xmlns is not set on HTML element, append xmlns attribute
- if (!context.contains("xmlns=")) {
- context.insert(" xmlns=\"http://www.w3.org/1999/xhtml\"");
- }
-
- context.send();
- if (log.isDebugEnabled()) {
- log.debug("Found <html> element");
- }
- } else if (context.getLastMatched() == stateManager.HEAD) {
- haveHead = true;
- if (log.isDebugEnabled()) {
- log.debug("Found <head> element");
- }
- if (closingElement) {
- writeToHead(out, haveHtml, haveHead);
- break;
- } else {
- context.send();
- }
- } else if (context.getLastMatched() == stateManager.TITLE) {
- context.send();
- haveHead = true;
- haveHtml = true;
- if (log.isDebugEnabled()) {
- log.debug("Found <title> element");
- }
- } else if (context.getLastMatched() == stateManager.BASE) {
- context.send();
- haveHead = true;
- haveHtml = true;
- if (log.isDebugEnabled()) {
- log.debug("Found <base> element");
- }
- } else {
- if (log.isDebugEnabled()) {
- log
- .debug("non <html> or <head><title>|<base> element");
- }
- writeToHead(out, haveHtml, haveHead);
- break;
- }
- } else if (state == stateManager.ELEMENT) {
- writeToHead(out, haveHtml, haveHead);
- break;
- }
- }
- context.send();
-// } else {
-// haveHtml = true;
-// }
- // Send rest of input.
- if (in instanceof FastBufferReader) {
- FastBufferReader fastIn = (FastBufferReader) in;
- fastIn.writeTo(out);
-
- } else {
- char[] buffer = new char[1024];
- int buffersCount = -1;
- int length;
- for (length = in.read(buffer); length > 0; length = in.read(buffer)) {
- out.write(buffer, 0, length);
- buffersCount++;
- }
- }
- if (!haveHtml && parsed) {
- out.write("</html>");
- }
-
- }
-
- private void writeToHead(Writer out, boolean haveHtml, boolean haveHead)
- throws IOException {
- if (!haveHead && !haveHtml) {
- out.write("<html xmlns=\"http://www.w3.org/1999/xhtml\">");
- }
- if (!haveHead) {
- out.write("<head>");
- }
-
- if (headEvents != null && headEvents.length > 0) {
- Serializer serializer = SerializerFactory.getSerializer(
- OutputPropertiesFactory.getDefaultMethodProperties(Method.XHTML));
-
- serializer.setWriter(out);
-
- ContentHandler contentHandler = serializer.asContentHandler();
- TreeWalker walker = new TreeWalker(contentHandler);
-
- try {
- contentHandler.startDocument();
-
- for (Node node : headEvents) {
- walker.traverseFragment(node);
- }
-
- contentHandler.endDocument();
-
- } catch (SAXException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- if (!haveHead) {
- out.write("</head>");
- }
-
- }
-
- public void parseHtml(InputStream input, Writer output) throws IOException {
- parse(new InputStreamReader(input, encoding), output);
-
- }
-
- public void parseHtml(Reader input, Writer output) throws IOException {
- parse(input, output);
-
- }
-
- public void setInputEncoding(String encoding) {
- this.encoding = encoding;
-
- }
-
- public void setOutputEncoding(String encoding) {
- // TODO Auto-generated method stub
-
- }
-
- public void setMoveElements(boolean move) {
- }
-
- public void setDoctype(String doctype) {
- this.doctype = doctype;
-
- }
-
- public void setViewState(String viewState) {
- this.viewState = viewState;
-
- }
-
- public boolean setMime(String mimeType) {
- this.mimeType=mimeType;
- return true;
- }
-
- public void setHeadNodes(Node[] events) {
- this.headEvents = events;
- }
-}
Modified: root/framework/trunk/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/request/MultipartRequest.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -30,7 +30,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
-import java.rmi.server.UID;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
@@ -38,6 +37,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -208,8 +208,7 @@
public File createTempFile() {
try {
- tempFile = File.createTempFile(new UID().toString().replace(
- ":", "-"), ".upload");
+ tempFile = File.createTempFile(UUID.randomUUID().toString(), ".upload");
// tempFile.deleteOnExit();
fOut = new FileOutputStream(tempFile);
} catch (IOException ex) {
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableFilter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,37 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.ajax4jsf.webapp;
-
-/**
- * @author asmirnov
- *
- */
-public class ConfigurableFilter extends BaseFilter {
-
- /**
- *
- */
- public ConfigurableFilter() {
- xmlFilter = new ConfigurableXMLFilter();
- xmlFilter.setFilter(this);
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/ConfigurableXMLFilter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,267 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-package org.ajax4jsf.webapp;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.EmptyStackException;
-import java.util.Properties;
-import java.util.regex.PatternSyntaxException;
-
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-import org.ajax4jsf.Messages;
-import org.ajax4jsf.io.parser.FastHtmlParser;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.webapp.nekko.NekkoParser;
-import org.ajax4jsf.webapp.tidy.TidyParser;
-import org.apache.commons.collections.ArrayStack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author asmirnov
- *
- */
-public class ConfigurableXMLFilter extends BaseXMLFilter {
-
- public static final String NONE = "NONE";
-
- public static final String NEKO = "NEKO";
-
- public static final String TIDY = "TIDY";
-
- private static final Log log = LogFactory
- .getLog(ConfigurableXMLFilter.class);
-
- private static final String PARSERS_LIST_PARAMETER = "org.ajax4jsf.xmlparser.ORDER";
-
- private static final String VIEW_ID_PATTERN_PARAMETER = "org.ajax4jsf.xmlparser.";
-
- /**
- * map of the parsers names and viewId patterns for all parser type.
- */
- private ParserConfig parsers = new TidyParserConfig();
-
- // private ParserConfig passParserConfig = new PassParserConfig();
-
- public void init(FilterConfig config) throws ServletException {
- super.init(config);
- ServletContext servletContext = config.getServletContext();
- String parsersParameter = servletContext
- .getInitParameter(PARSERS_LIST_PARAMETER);
- if (null != parsersParameter) {
- configureParsers(servletContext, parsersParameter);
- }
- }
-
- /**
- * @param servletContext
- * @param parsersParameter
- * @throws ServletException
- */
- public void configureParsers(ServletContext servletContext,
- String parsersParameter) throws ServletException {
- String[] parsersNames = parsersParameter.split("\\s*,\\s*");
- for (int i = parsersNames.length - 1; i >= 0; i--) {
- String parserName = parsersNames[i];
- ParserConfig parserConfig;
- if (TIDY.equals(parserName)) {
- parserConfig = new TidyParserConfig();
- } else if (NEKO.equals(parserName)) {
- parserConfig = new NekoParserConfig();
- } else if (NONE.equals(parserName)) {
- parserConfig = new PassParserConfig();
- } else {
- throw new ServletException(
- "Unknown XML parser type in config parameter "
- + parserName);
- }
- parserConfig.setNext(parsers);
- if (null != servletContext) {
- try {
- String parserViewPattern = servletContext
- .getInitParameter(VIEW_ID_PATTERN_PARAMETER
- + parserName);
- parserConfig.setPatterns(parserViewPattern);
-
- } catch (PatternSyntaxException e) {
- throw new ServletException("Invalid pattern for a parser "
- + parserName + " :" + e.getMessage());
- }
- }
- parsers = parserConfig;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.webapp.BaseXMLFilter#getParser(java.lang.String,
- * boolean, java.lang.String)
- */
- protected HtmlParser getParser(String mimetype, boolean isAjax,
- String viewId) {
-
- HtmlParser parser = null;
-
- if (isAjax || mimetype.startsWith(TEXT_HTML) || mimetype.startsWith(APPLICATION_XHTML_XML)) {
- if (isAjax || isForcexml()) {
- parser = parsers.getParser(viewId, mimetype);
- } else {
- parser = new FastHtmlParser();
- }
- }
-
- return parser;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.webapp.BaseXMLFilter#reuseParser(org.ajax4jsf.webapp.HtmlParser)
- */
- protected void reuseParser(HtmlParser parser) {
- parsers.reuseParser(parser);
-
- }
-
- private static final int STACK_SIZE = 100;
-
- private ArrayStack _xhtmlParsersPool = new ArrayStack(STACK_SIZE);
-
- private class NekoParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- NekkoParser parser;
- try {
- synchronized (_xhtmlParsersPool) {
- parser = (NekkoParser) _xhtmlParsersPool.pop();
- }
- } catch (EmptyStackException e) {
- parser = new NekkoParser();
- parser.setPublicId(getPublicid());
- parser.setSystemid(getSystemid());
- parser.setNamespace(getNamespace());
- // If tidy not handle all requests, disable reorganising
- // of html
- // parser.setMoveElements(isForcexml());
- parser.init();
- }
- parser.setMime(mime);
- // TODO - set header scripts/styles filter.
- return parser;
- }
-
- boolean storeParser(HtmlParser parser) {
- if (null != parser && parser instanceof NekkoParser) {
- synchronized (_xhtmlParsersPool) {
- if (_xhtmlParsersPool.size() < STACK_SIZE) {
- ((NekkoParser) parser).reset();
- _xhtmlParsersPool.push(parser);
- }
-
- }
- return true;
- }
- return false;
- }
- }
-
- private class TidyParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- // TODO Auto-generated method stub
- TidyParser tidyParser = new TidyParser(getTidyProperties());
- tidyParser.setMoveElements(isForcexml());
- tidyParser.setMime(mime);
- return tidyParser;
- }
-
- }
-
- private class PassParserConfig extends ParserConfig {
-
- protected HtmlParser createParser(String mime) {
- return new FastHtmlParser();
- }
-
- }
-
- private Properties _tidyProperties;
-
- private Properties getTidyProperties() {
- if (null == _tidyProperties) {
- _tidyProperties = new Properties();
- InputStream defaultprops = null;
- InputStream props = null;
- try {
- defaultprops = URLToStreamHelper.urlToStreamSafe(TidyParser.class
- .getResource("tidy.properties"));
- if (null != defaultprops) {
- _tidyProperties.load(defaultprops);
- if (log.isDebugEnabled()) {
- log.debug("default tidy parser properties loaded");
- }
- } else if (log.isDebugEnabled()) {
- log.debug("No default tidy parser properties found");
- }
-
- // Second part - user-defined properties.
- props = URLToStreamHelper.urlToStreamSafe(Thread.currentThread().getContextClassLoader()
- .getResource("tidy.properties"));
- if (null != props) {
- _tidyProperties.load(props);
- if (log.isDebugEnabled()) {
- log.debug("application-specific tidy parser properties loaded");
- }
- }
- } catch (IOException e) {
- // TODO Auto-generated catch block
- log.warn(Messages
- .getMessage(Messages.READING_TIDY_PROPERTIES_ERROR), e);
- } finally {
- if (null != props) {
- try {
- props.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- if (null != defaultprops) {
- try {
- defaultprops.close();
- } catch (IOException e) {
- // can be ignored
- }
- }
- }
- }
- return _tidyProperties;
- }
-
- public ParserConfig getParsers() {
- return parsers;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/NekkoFilter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,50 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.webapp;
-
-import org.ajax4jsf.webapp.nekko.NekkoXMLFilter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * This class implements a simple Servlet filter that convert basic html
- * output of JSF to valid XML or JavaScript, for parsing different versions
- * of XmlHttpRequest's on client side.
- */
-public class NekkoFilter extends BaseFilter implements javax.servlet.Filter {
- static final Log log = LogFactory.getLog(NekkoFilter.class);
-
- /**
- *
- */
- public NekkoFilter() {
- super();
- // default - not force
-// setForcexml(false);
- xmlFilter = new NekkoXMLFilter();
- xmlFilter.setFilter(this);
- }
-
-}
-
-
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/webapp/TidyFilter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,44 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.webapp;
-
-import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-
-/**
- * Convert Html Output to XML using Jtidy.
- * @author shura (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/01/09 18:58:20 $
- */
-public class TidyFilter extends BaseFilter {
- static final Log log = LogFactory.getLog(TidyFilter.class);
-
- public TidyFilter() {
- // For Tidy, publicId can be pre-defined omit | auto | strict | loose | ignore | [fpi]
- xmlFilter = new TidyXMLFilter();
- xmlFilter.setFilter(this);
- xmlFilter.setPublicid("omit");
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/AttributesImplSerializer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/AttributesImplSerializer.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/AttributesImplSerializer.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,235 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: AttributesImplSerializer.java,v 1.1.2.1 2007/01/09 18:57:22 alexsmirnov Exp $
- */
-
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Hashtable;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * This class extends org.xml.sax.helpers.AttributesImpl which implements org.
- * xml.sax.Attributes. But for optimization this class adds a Hashtable for
- * faster lookup of an index by qName, which is commonly done in the stream
- * serializer.
- *
- * @see org.xml.sax.Attributes
- *
- * @xsl.usage internal
- */
-public final class AttributesImplSerializer extends AttributesImpl
-{
- /**
- * Hash table of qName/index values to quickly lookup the index
- * of an attributes qName. qNames are in uppercase in the hash table
- * to make the search case insensitive.
- *
- * The keys to the hashtable to find the index are either
- * "prefix:localName" or "{uri}localName".
- */
- private final Hashtable m_indexFromQName = new Hashtable();
-
- private final StringBuffer m_buff = new StringBuffer();
-
- /**
- * This is the number of attributes before switching to the hash table,
- * and can be tuned, but 12 seems good for now - Brian M.
- */
- private static final int MAX = 12;
-
- /**
- * One less than the number of attributes before switching to
- * the Hashtable.
- */
- private static final int MAXMinus1 = MAX - 1;
-
- /**
- * This method gets the index of an attribute given its qName.
- * @param qname the qualified name of the attribute, e.g. "prefix1:locName1"
- * @return the integer index of the attribute.
- * @see org.xml.sax.Attributes#getIndex(String)
- */
- public final int getIndex(String qname)
- {
- int index;
-
- if (super.getLength() < MAX)
- {
- // if we haven't got too many attributes let the
- // super class look it up
- index = super.getIndex(qname);
- return index;
- }
- // we have too many attributes and the super class is slow
- // so find it quickly using our Hashtable.
- Integer i = (Integer)m_indexFromQName.get(qname);
- if (i == null)
- index = -1;
- else
- index = i.intValue();
- return index;
- }
- /**
- * This method adds the attribute, but also records its qName/index pair in
- * the hashtable for fast lookup by getIndex(qName).
- * @param uri the URI of the attribute
- * @param local the local name of the attribute
- * @param qname the qualified name of the attribute
- * @param type the type of the attribute
- * @param val the value of the attribute
- *
- * @see org.xml.sax.helpers.AttributesImpl#addAttribute(String, String, String, String, String)
- * @see #getIndex(String)
- */
- public final void addAttribute(
- String uri,
- String local,
- String qname,
- String type,
- String val)
- {
- int index = super.getLength();
- super.addAttribute(uri, local, qname, type, val);
- // (index + 1) is now the number of attributes
- // so either compare (index+1) to MAX, or compare index to (MAX-1)
-
- if (index < MAXMinus1)
- {
- return;
- }
- else if (index == MAXMinus1)
- {
- switchOverToHash(MAX);
- }
- else
- {
- /* add the key with the format of "prefix:localName" */
- /* we have just added the attibute, its index is the old length */
- Integer i = new Integer(index);
- m_indexFromQName.put(qname, i);
-
- /* now add with key of the format "{uri}localName" */
- m_buff.setLength(0);
- m_buff.append('{').append(uri).append('}').append(local);
- String key = m_buff.toString();
- m_indexFromQName.put(key, i);
- }
- return;
- }
-
- /**
- * We are switching over to having a hash table for quick look
- * up of attributes, but up until now we haven't kept any
- * information in the Hashtable, so we now update the Hashtable.
- * Future additional attributes will update the Hashtable as
- * they are added.
- * @param numAtts
- */
- private void switchOverToHash(int numAtts)
- {
- for (int index = 0; index < numAtts; index++)
- {
- String qName = super.getQName(index);
- Integer i = new Integer(index);
- m_indexFromQName.put(qName, i);
-
- // Add quick look-up to find with uri/local name pair
- String uri = super.getURI(index);
- String local = super.getLocalName(index);
- m_buff.setLength(0);
- m_buff.append('{').append(uri).append('}').append(local);
- String key = m_buff.toString();
- m_indexFromQName.put(key, i);
- }
- }
-
- /**
- * This method clears the accumulated attributes.
- *
- * @see org.xml.sax.helpers.AttributesImpl#clear()
- */
- public final void clear()
- {
-
- int len = super.getLength();
- super.clear();
- if (MAX <= len)
- {
- // if we have had enough attributes and are
- // using the Hashtable, then clear the Hashtable too.
- m_indexFromQName.clear();
- }
-
- }
-
- /**
- * This method sets the attributes, previous attributes are cleared,
- * it also keeps the hashtable up to date for quick lookup via
- * getIndex(qName).
- * @param atts the attributes to copy into these attributes.
- * @see org.xml.sax.helpers.AttributesImpl#setAttributes(Attributes)
- * @see #getIndex(String)
- */
- public final void setAttributes(Attributes atts)
- {
-
- super.setAttributes(atts);
-
- // we've let the super class add the attributes, but
- // we need to keep the hash table up to date ourselves for the
- // potentially new qName/index pairs for quick lookup.
- int numAtts = atts.getLength();
- if (MAX <= numAtts)
- switchOverToHash(numAtts);
-
- }
-
- /**
- * This method gets the index of an attribute given its uri and locanName.
- * @param uri the URI of the attribute name.
- * @param localName the local namer (after the ':' ) of the attribute name.
- * @return the integer index of the attribute.
- * @see org.xml.sax.Attributes#getIndex(String)
- */
- public final int getIndex(String uri, String localName)
- {
- int index;
-
- if (super.getLength() < MAX)
- {
- // if we haven't got too many attributes let the
- // super class look it up
- index = super.getIndex(uri,localName);
- return index;
- }
- // we have too many attributes and the super class is slow
- // so find it quickly using our Hashtable.
- // Form the key of format "{uri}localName"
- m_buff.setLength(0);
- m_buff.append('{').append(uri).append('}').append(localName);
- String key = m_buff.toString();
- Integer i = (Integer)m_indexFromQName.get(key);
- if (i == null)
- index = -1;
- else
- index = i.intValue();
- return index;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/CharInfo.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/CharInfo.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/CharInfo.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,747 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: CharInfo.java,v 1.1.2.1 2007/01/09 18:57:18 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-import javax.xml.transform.TransformerException;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.SystemIDResolver;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException;
-
-/**
- * This class provides services that tell if a character should have
- * special treatement, such as entity reference substitution or normalization
- * of a newline character. It also provides character to entity reference
- * lookup.
- *
- * DEVELOPERS: See Known Issue in the constructor.
- *
- * @xsl.usage internal
- */
-final class CharInfo
-{
- /** Given a character, lookup a String to output (e.g. a decorated entity reference). */
- private Hashtable m_charToString = new Hashtable();
-
- /**
- * The name of the HTML entities file.
- * If specified, the file will be resource loaded with the default class loader.
- */
- public static final String HTML_ENTITIES_RESOURCE =
- "org.ajax4jsf.xml.serializer.HTMLEntities";
-
- /**
- * The name of the XML entities file.
- * If specified, the file will be resource loaded with the default class loader.
- */
- public static final String XML_ENTITIES_RESOURCE =
- "org.ajax4jsf.xml.serializer.XMLEntities";
-
- /** The horizontal tab character, which the parser should always normalize. */
- public static final char S_HORIZONAL_TAB = 0x09;
-
- /** The linefeed character, which the parser should always normalize. */
- public static final char S_LINEFEED = 0x0A;
-
- /** The carriage return character, which the parser should always normalize. */
- public static final char S_CARRIAGERETURN = 0x0D;
-
- /** This flag is an optimization for HTML entities. It false if entities
- * other than quot (34), amp (38), lt (60) and gt (62) are defined
- * in the range 0 to 127.
- * @xsl.usage internal
- */
- final boolean onlyQuotAmpLtGt;
-
- /** Copy the first 0,1 ... ASCII_MAX values into an array */
- private static final int ASCII_MAX = 128;
-
- /** Array of values is faster access than a set of bits
- * to quickly check ASCII characters in attribute values.
- */
- private boolean[] isSpecialAttrASCII = new boolean[ASCII_MAX];
-
- /** Array of values is faster access than a set of bits
- * to quickly check ASCII characters in text nodes.
- */
- private boolean[] isSpecialTextASCII = new boolean[ASCII_MAX];
-
- private boolean[] isCleanTextASCII = new boolean[ASCII_MAX];
-
- /** An array of bits to record if the character is in the set.
- * Although information in this array is complete, the
- * isSpecialAttrASCII array is used first because access to its values
- * is common and faster.
- */
- private int array_of_bits[] = createEmptySetOfIntegers(65535);
-
-
- // 5 for 32 bit words, 6 for 64 bit words ...
- /*
- * This constant is used to shift an integer to quickly
- * calculate which element its bit is stored in.
- * 5 for 32 bit words (int) , 6 for 64 bit words (long)
- */
- private static final int SHIFT_PER_WORD = 5;
-
- /*
- * A mask to get the low order bits which are used to
- * calculate the value of the bit within a given word,
- * that will represent the presence of the integer in the
- * set.
- *
- * 0x1F for 32 bit words (int),
- * or 0x3F for 64 bit words (long)
- */
- private static final int LOW_ORDER_BITMASK = 0x1f;
-
- /*
- * This is used for optimizing the lookup of bits representing
- * the integers in the set. It is the index of the first element
- * in the array array_of_bits[] that is not used.
- */
- private int firstWordNotUsed;
-
-
- /**
- * Constructor that reads in a resource file that describes the mapping of
- * characters to entity references.
- * This constructor is private, just to force the use
- * of the getCharInfo(entitiesResource) factory
- *
- * Resource files must be encoded in UTF-8 and can either be properties
- * files with a .properties extension assumed. Alternatively, they can
- * have the following form, with no particular extension assumed:
- *
- * <pre>
- * # First char # is a comment
- * Entity numericValue
- * quot 34
- * amp 38
- * </pre>
- *
- * @param entitiesResource Name of properties or resource file that should
- * be loaded, which describes that mapping of characters to entity
- * references.
- */
- private CharInfo(String entitiesResource, String method)
- {
- this(entitiesResource, method, false);
- }
-
- private CharInfo(String entitiesResource, String method, boolean internal)
- {
- ResourceBundle entities = null;
- boolean noExtraEntities = true;
-
- // Make various attempts to interpret the parameter as a properties
- // file or resource file, as follows:
- //
- // 1) attempt to load .properties file using ResourceBundle
- // 2) try using the class loader to find the specified file a resource
- // file
- // 3) try treating the resource a URI
-
- if (internal) {
- try {
- // Load entity property files by using PropertyResourceBundle,
- // cause of security issure for applets
- entities = PropertyResourceBundle.getBundle(entitiesResource);
- } catch (Exception e) {}
- }
-
- if (entities != null) {
- Enumeration keys = entities.getKeys();
- while (keys.hasMoreElements()){
- String name = (String) keys.nextElement();
- String value = entities.getString(name);
- int code = Integer.parseInt(value);
- defineEntity(name, (char) code);
- if (extraEntity(code))
- noExtraEntities = false;
- }
- set(S_LINEFEED);
- set(S_CARRIAGERETURN);
- } else {
- InputStream is = null;
-
- // Load user specified resource file by using URL loading, it
- // requires a valid URI as parameter
- try {
- if (internal) {
- is = URLToStreamHelper.urlToStreamSafe(
- CharInfo.class.getResource(entitiesResource));
- } else {
- ClassLoader cl = ObjectFactory.findClassLoader();
- if (cl == null) {
- is = URLToStreamHelper.urlToStreamSafe(
- ClassLoader.getSystemResource(entitiesResource));
- } else {
- is = URLToStreamHelper.urlToStreamSafe(cl.getResource(entitiesResource));
- }
-
- if (is == null) {
- try {
- URL url = new URL(entitiesResource);
- is = url.openStream();
- } catch (Exception e) {}
- }
- }
-
- if (is == null) {
- throw new RuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_RESOURCE_COULD_NOT_FIND,
- new Object[] {entitiesResource, entitiesResource}));
- }
-
- // Fix Bugzilla#4000: force reading in UTF-8
- // This creates the de facto standard that Xalan's resource
- // files must be encoded in UTF-8. This should work in all
- // JVMs.
- //
- // %REVIEW% KNOWN ISSUE: IT FAILS IN MICROSOFT VJ++, which
- // didn't implement the UTF-8 encoding. Theoretically, we should
- // simply let it fail in that case, since the JVM is obviously
- // broken if it doesn't support such a basic standard. But
- // since there are still some users attempting to use VJ++ for
- // development, we have dropped in a fallback which makes a
- // second attempt using the platform's default encoding. In VJ++
- // this is apparently ASCII, which is subset of UTF-8... and
- // since the strings we'll be reading here are also primarily
- // limited to the 7-bit ASCII range (at least, in English
- // versions of Xalan), this should work well enough to keep us
- // on the air until we're ready to officially decommit from
- // VJ++.
-
- BufferedReader reader;
- try {
- reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- } catch (UnsupportedEncodingException e) {
- reader = new BufferedReader(new InputStreamReader(is));
- }
-
- String line = reader.readLine();
-
- while (line != null) {
- if (line.length() == 0 || line.charAt(0) == '#') {
- line = reader.readLine();
-
- continue;
- }
-
- int index = line.indexOf(' ');
-
- if (index > 1) {
- String name = line.substring(0, index);
-
- ++index;
-
- if (index < line.length()) {
- String value = line.substring(index);
- index = value.indexOf(' ');
-
- if (index > 0) {
- value = value.substring(0, index);
- }
-
- int code = Integer.parseInt(value);
-
- defineEntity(name, (char) code);
- if (extraEntity(code))
- noExtraEntities = false;
- }
- }
-
- line = reader.readLine();
- }
-
- is.close();
- set(S_LINEFEED);
- set(S_CARRIAGERETURN);
- } catch (Exception e) {
- throw new RuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_RESOURCE_COULD_NOT_LOAD,
- new Object[] { entitiesResource,
- e.toString(),
- entitiesResource,
- e.toString()}));
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (Exception except) {}
- }
- }
- }
-
- /* initialize the array isCleanTextASCII[] with a cache of values
- * for use by ToStream.character(char[], int , int)
- * and the array isSpecialTextASCII[] with the opposite values
- * (all in the name of performance!)
- */
- for (int ch = 0; ch <ASCII_MAX; ch++)
- if((((0x20 <= ch || (0x0A == ch || 0x0D == ch || 0x09 == ch)))
- && (!get(ch))) || ('"' == ch))
- {
- isCleanTextASCII[ch] = true;
- isSpecialTextASCII[ch] = false;
- }
- else {
- isCleanTextASCII[ch] = false;
- isSpecialTextASCII[ch] = true;
- }
-
-
-
- onlyQuotAmpLtGt = noExtraEntities;
-
- // initialize the array with a cache of the BitSet values
- for (int i=0; i<ASCII_MAX; i++)
- isSpecialAttrASCII[i] = get(i);
-
- /* Now that we've used get(ch) just above to initialize the
- * two arrays we will change by adding a tab to the set of
- * special chars for XML (but not HTML!).
- * We do this because a tab is always a
- * special character in an XML attribute,
- * but only a special character in XML text
- * if it has an entity defined for it.
- * This is the reason for this delay.
- */
- if (Method.XML.equals(method))
- {
- isSpecialAttrASCII[S_HORIZONAL_TAB] = true;
- }
- }
-
- /**
- * Defines a new character reference. The reference's name and value are
- * supplied. Nothing happens if the character reference is already defined.
- * <p>Unlike internal entities, character references are a string to single
- * character mapping. They are used to map non-ASCII characters both on
- * parsing and printing, primarily for HTML documents. '<amp;' is an
- * example of a character reference.</p>
- *
- * @param name The entity's name
- * @param value The entity's value
- */
- private void defineEntity(String name, char value)
- {
- StringBuffer sb = new StringBuffer("&");
- sb.append(name);
- sb.append(';');
- String entityString = sb.toString();
-
- defineChar2StringMapping(entityString, value);
- }
-
- private CharKey m_charKey = new CharKey();
-
- /**
- * Map a character to a String. For example given
- * the character '>' this method would return the fully decorated
- * entity name "<".
- * Strings for entity references are loaded from a properties file,
- * but additional mappings defined through calls to defineChar2String()
- * are possible. Such entity reference mappings could be over-ridden.
- *
- * This is reusing a stored key object, in an effort to avoid
- * heap activity. Unfortunately, that introduces a threading risk.
- * Simplest fix for now is to make it a synchronized method, or to give
- * up the reuse; I see very little performance difference between them.
- * Long-term solution would be to replace the hashtable with a sparse array
- * keyed directly from the character's integer value; see DTM's
- * string pool for a related solution.
- *
- * @param value The character that should be resolved to
- * a String, e.g. resolve '>' to "<".
- *
- * @return The String that the character is mapped to, or null if not found.
- * @xsl.usage internal
- */
- synchronized String getOutputStringForChar(char value)
- {
- // CharKey m_charKey = new CharKey(); //Alternative to synchronized
- m_charKey.setChar(value);
- return (String) m_charToString.get(m_charKey);
- }
-
- /**
- * Tell if the character argument that is from
- * an attribute value should have special treatment.
- *
- * @param value the value of a character that is in an attribute value
- * @return true if the character should have any special treatment,
- * such as when writing out attribute values,
- * or entity references.
- * @xsl.usage internal
- */
- final boolean isSpecialAttrChar(int value)
- {
- // for performance try the values in the boolean array first,
- // this is faster access than the BitSet for common ASCII values
-
- if (value < ASCII_MAX)
- return isSpecialAttrASCII[value];
-
- // rather than java.util.BitSet, our private
- // implementation is faster (and less general).
- return get(value);
- }
-
- /**
- * Tell if the character argument that is from a
- * text node should have special treatment.
- *
- * @param value the value of a character that is in a text node
- * @return true if the character should have any special treatment,
- * such as when writing out attribute values,
- * or entity references.
- * @xsl.usage internal
- */
- final boolean isSpecialTextChar(int value)
- {
- // for performance try the values in the boolean array first,
- // this is faster access than the BitSet for common ASCII values
-
- if (value < ASCII_MAX)
- return isSpecialTextASCII[value];
-
- // rather than java.util.BitSet, our private
- // implementation is faster (and less general).
- return get(value);
- }
-
- /**
- * This method is used to determine if an ASCII character in
- * a text node (not an attribute value) is "clean".
- * @param value the character to check (0 to 127).
- * @return true if the character can go to the writer as-is
- * @xsl.usage internal
- */
- final boolean isTextASCIIClean(int value)
- {
- return isCleanTextASCII[value];
- }
-
-// In the future one might want to use the array directly and avoid
-// the method call, but I think the JIT alreay inlines this well enough
-// so don't do it (for now) - bjm
-// public final boolean[] getASCIIClean()
-// {
-// return isCleanTextASCII;
-// }
-
-
- private static CharInfo getCharInfoBasedOnPrivilege(
- final String entitiesFileName, final String method,
- final boolean internal){
- return (CharInfo) AccessController.doPrivileged(
- new PrivilegedAction() {
- public Object run() {
- return new CharInfo(entitiesFileName,
- method, internal);}
- });
- }
-
- /**
- * Factory that reads in a resource file that describes the mapping of
- * characters to entity references.
- *
- * Resource files must be encoded in UTF-8 and have a format like:
- * <pre>
- * # First char # is a comment
- * Entity numericValue
- * quot 34
- * amp 38
- * </pre>
- * (Note: Why don't we just switch to .properties files? Oct-01 -sc)
- *
- * @param entitiesResource Name of entities resource file that should
- * be loaded, which describes that mapping of characters to entity references.
- * @param method the output method type, which should be one of "xml", "html", "text"...
- *
- * @xsl.usage internal
- */
- static CharInfo getCharInfo(String entitiesFileName, String method)
- {
- CharInfo charInfo = (CharInfo) m_getCharInfoCache.get(entitiesFileName);
- if (charInfo != null) {
- return charInfo;
- }
-
- // try to load it internally - cache
- try {
- charInfo = getCharInfoBasedOnPrivilege(entitiesFileName,
- method, true);
- m_getCharInfoCache.put(entitiesFileName, charInfo);
- return charInfo;
- } catch (Exception e) {}
-
- // try to load it externally - do not cache
- try {
- return getCharInfoBasedOnPrivilege(entitiesFileName,
- method, false);
- } catch (Exception e) {}
-
- String absoluteEntitiesFileName;
-
- if (entitiesFileName.indexOf(':') < 0) {
- absoluteEntitiesFileName =
- SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
- } else {
- try {
- absoluteEntitiesFileName =
- SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
- } catch (TransformerException te) {
- throw new WrappedRuntimeException(te);
- }
- }
-
- return getCharInfoBasedOnPrivilege(entitiesFileName,
- method, false);
- }
-
- /** Table of user-specified char infos. */
- private static Hashtable m_getCharInfoCache = new Hashtable();
-
- /**
- * Returns the array element holding the bit value for the
- * given integer
- * @param i the integer that might be in the set of integers
- *
- */
- private static int arrayIndex(int i) {
- return (i >> SHIFT_PER_WORD);
- }
-
- /**
- * For a given integer in the set it returns the single bit
- * value used within a given word that represents whether
- * the integer is in the set or not.
- */
- private static int bit(int i) {
- int ret = (1 << (i & LOW_ORDER_BITMASK));
- return ret;
- }
-
- /**
- * Creates a new empty set of integers (characters)
- * @param max the maximum integer to be in the set.
- */
- private int[] createEmptySetOfIntegers(int max) {
- firstWordNotUsed = 0; // an optimization
-
- int[] arr = new int[arrayIndex(max - 1) + 1];
- return arr;
-
- }
-
- /**
- * Adds the integer (character) to the set of integers.
- * @param i the integer to add to the set, valid values are
- * 0, 1, 2 ... up to the maximum that was specified at
- * the creation of the set.
- */
- private final void set(int i) {
- setASCIIdirty(i);
-
- int j = (i >> SHIFT_PER_WORD); // this word is used
- int k = j + 1;
-
- if(firstWordNotUsed < k) // for optimization purposes.
- firstWordNotUsed = k;
-
- array_of_bits[j] |= (1 << (i & LOW_ORDER_BITMASK));
- }
-
-
- /**
- * Return true if the integer (character)is in the set of integers.
- *
- * This implementation uses an array of integers with 32 bits per
- * integer. If a bit is set to 1 the corresponding integer is
- * in the set of integers.
- *
- * @param i an integer that is tested to see if it is the
- * set of integers, or not.
- */
- private final boolean get(int i) {
-
- boolean in_the_set = false;
- int j = (i >> SHIFT_PER_WORD); // wordIndex(i)
- // an optimization here, ... a quick test to see
- // if this integer is beyond any of the words in use
- if(j < firstWordNotUsed)
- in_the_set = (array_of_bits[j] &
- (1 << (i & LOW_ORDER_BITMASK))
- ) != 0; // 0L for 64 bit words
- return in_the_set;
- }
-
- // record if there are any entities other than
- // quot, amp, lt, gt (probably user defined)
- /**
- * @return true if the entity
- * @param code The value of the character that has an entity defined
- * for it.
- */
- private boolean extraEntity(int entityValue)
- {
- boolean extra = false;
- if (entityValue < 128)
- {
- switch (entityValue)
- {
- case 34 : // quot
- case 38 : // amp
- case 60 : // lt
- case 62 : // gt
- break;
- default : // other entity in range 0 to 127
- extra = true;
- }
- }
- return extra;
- }
-
- /**
- * If the character is a printable ASCII character then
- * mark it as not clean and needing replacement with
- * a String on output.
- * @param ch
- */
- private void setASCIIdirty(int j)
- {
- if (0 <= j && j < ASCII_MAX)
- {
- isCleanTextASCII[j] = false;
- isSpecialTextASCII[j] = true;
- }
- }
-
- /**
- * If the character is a printable ASCII character then
- * mark it as and not needing replacement with
- * a String on output.
- * @param ch
- */
- private void setASCIIclean(int j)
- {
- if (0 <= j && j < ASCII_MAX)
- {
- isCleanTextASCII[j] = true;
- isSpecialTextASCII[j] = false;
- }
- }
-
- private void defineChar2StringMapping(String outputString, char inputChar)
- {
- CharKey character = new CharKey(inputChar);
- m_charToString.put(character, outputString);
- set(inputChar);
- }
-
- /**
- * Simple class for fast lookup of char values, when used with
- * hashtables. You can set the char, then use it as a key.
- *
- * This class is a copy of the one in org.apache.xml.utils.
- * It exists to cut the serializers dependancy on that package.
- *
- * @xsl.usage internal
- */
- private static class CharKey extends Object
- {
-
- /** String value */
- private char m_char;
-
- /**
- * Constructor CharKey
- *
- * @param key char value of this object.
- */
- public CharKey(char key)
- {
- m_char = key;
- }
-
- /**
- * Default constructor for a CharKey.
- *
- * @param key char value of this object.
- */
- public CharKey()
- {
- }
-
- /**
- * Get the hash value of the character.
- *
- * @return hash value of the character.
- */
- public final void setChar(char c)
- {
- m_char = c;
- }
-
-
-
- /**
- * Get the hash value of the character.
- *
- * @return hash value of the character.
- */
- public final int hashCode()
- {
- return (int)m_char;
- }
-
- /**
- * Override of equals() for this object
- *
- * @param obj to compare to
- *
- * @return True if this object equals this string value
- */
- public final boolean equals(Object obj)
- {
- return ((CharKey)obj).m_char == m_char;
- }
- }
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/DOMSerializer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/DOMSerializer.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/DOMSerializer.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,64 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: DOMSerializer.java,v 1.1.2.1 2007/01/09 18:57:29 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-
-import org.w3c.dom.Node;
-
-/**
- * Interface for a DOM serializer implementation.
- * <p>
- * The DOMSerializer is a facet of a serializer and is obtained from the
- * asDOMSerializer() method of the Serializer interface.
- * A serializer may or may not support a DOM serializer, if it does not then the
- * return value from asDOMSerializer() is null.
- * <p>
- * Example:
- * <pre>
- * Document doc;
- * Serializer ser;
- * OutputStream os;
- *
- * ser = ...;
- * os = ...;
- *
- * ser.setOutputStream( os );
- * DOMSerialzier dser = ser.asDOMSerializer();
- * dser.serialize(doc);
- * </pre>
- *
- * @see Serializer
- *
- * @xsl.usage general
- *
- */
-public interface DOMSerializer
-{
- /**
- * Serializes the DOM node. Throws an exception only if an I/O
- * exception occured while serializing.
- *
- * This interface is a public API.
- *
- * @param node the DOM node to serialize
- * @throws IOException if an I/O exception occured while serializing
- */
- public void serialize(Node node) throws IOException;
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemContext.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemContext.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemContext.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,217 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ElemContext.java,v 1.1.2.1 2007/01/09 18:57:13 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-/**
- * This class is a stack frame that consists of
- * information about the element currently being processed
- * by a serializer. Consider this example:
- * <pre>
- * <A>
- * <B1>
- * </B1>
- * <B2>
- * </B2>
- * <A>
- * </pre>
- *
- * A stack frame will be pushed for "A" at depth 1,
- * then another one for "B1" at depth 2.
- * Then "B1" stackframe is popped. When the stack frame for "B2" is
- * pushed, this implementation re-uses the old stack fram object used
- * by "B1" to be efficient at not creating too many of these object.
- *
- * This is by no means a public class, and neither are its fields or methods,
- * they are all helper fields for a serializer.
- *
- * The purpose of this class is to be more consistent with pushing information
- * when a new element is being serialized and more quickly restoring the old
- * information about the parent element with a simple pop() when the
- * child element is done. Previously there was some redundant and error-prone
- * calculations going on to retore information.
- *
- * @xsl.usage internal
- */
-final class ElemContext
-{
- // Fields that form the context of the element
-
- /**
- * The nesting depth of the element inside other elements.
- */
- final int m_currentElemDepth;
-
- /** HTML field, the element description of the HTML element */
- ElemDesc m_elementDesc = null;
-
- /**
- * The local name of the element.
- */
- String m_elementLocalName = null;
-
- /**
- * The fully qualified name of the element (with prefix, if any).
- */
- String m_elementName = null;
-
- /**
- * The URI of the element.
- */
- String m_elementURI = null;
-
- /** If the element is in the cdata-section-names list
- * then the value is true. If it is true the text children of the element
- * should be output in CDATA section blocks.
- */
- boolean m_isCdataSection;
-
- /** True if the current element has output escaping disabled.
- * This is true for SCRIPT and STYLE elements.
- */
- boolean m_isRaw = false;
-
- /** The next element "stack frame". This value will only be
- * set once as deeper stack frames are not deleted when popped off,
- * but are rather re-used when a push is required.
- *
- * This makes for very fast pushing and popping of stack frames
- * because very few stack frame objects are ever created, they are
- * mostly re-used. This re-use saves object creation but it also means
- * that connections between the frames via m_next and m_prev
- * never changes either. Just the contents of the frames change
- * as they are re-used. Only the reference to the current stack frame, which
- * is held by the serializer is changed via a quick pop() or push().
- */
- private ElemContext m_next;
-
- /** The previous element "stack frame". */
- final ElemContext m_prev;
-
- /**
- * Set to true when a start tag is started, or open, but not all the
- * attributes or namespace information is yet collected.
- */
- boolean m_startTagOpen = false;
-
- /**
- * Constructor to create the root of the element contexts.
- *
- */
- ElemContext()
- {
- // this assignment means can never pop this context off
- m_prev = this;
- // depth 0 because it doesn't correspond to any element
- m_currentElemDepth = 0;
- }
-
- /**
- * Constructor to create the "stack frame" for a given element depth.
- *
- * This implementation will re-use the context at each depth. If
- * a documents deepest element depth is N then there will be (N+1)
- * such objects created, no more than that.
- *
- * @param previous The "stack frame" corresponding to the new
- * elements parent element.
- */
- private ElemContext(final ElemContext previous)
- {
- m_prev = previous;
- m_currentElemDepth = previous.m_currentElemDepth + 1;
- }
-
- /**
- * Pop the current "stack frame".
- * @return Returns the parent "stack frame" of the one popped.
- */
- final ElemContext pop()
- {
- /* a very simple pop. No clean up is done of the deeper
- * stack frame. All deeper stack frames are still attached
- * but dormant, just waiting to be re-used.
- */
- return this.m_prev;
- }
-
- /**
- * This method pushes an element "stack frame"
- * but with no initialization of values in that frame.
- * This method is used for optimization purposes, like when pushing
- * a stack frame for an HTML "IMG" tag which has no children and
- * the stack frame will almost immediately be popped.
- */
- final ElemContext push()
- {
- ElemContext frame = this.m_next;
- if (frame == null)
- {
- /* We have never been at this depth yet, and there is no
- * stack frame to re-use, so we now make a new one.
- */
- frame = new ElemContext(this);
- this.m_next = frame;
- }
- /*
- * We shouldn't need to set this true because we should just
- * be pushing a dummy stack frame that will be instantly popped.
- * Yet we need to be ready in case this element does have
- * unexpected children.
- */
- frame.m_startTagOpen = true;
- return frame;
- }
-
- /**
- * Push an element context on the stack. This context keeps track of
- * information gathered about the element.
- * @param uri The URI for the namespace for the element name,
- * can be null if it is not yet known.
- * @param localName The local name of the element (no prefix),
- * can be null.
- * @param qName The qualified name (with prefix, if any)
- * of the element, this parameter is required.
- */
- final ElemContext push(
- final String uri,
- final String localName,
- final String qName)
- {
- ElemContext frame = this.m_next;
- if (frame == null)
- {
- /* We have never been at this depth yet, and there is no
- * stack frame to re-use, so we now make a new one.
- */
- frame = new ElemContext(this);
- this.m_next = frame;
- }
-
- // Initialize, or reset values in the new or re-used stack frame.
- frame.m_elementName = qName;
- frame.m_elementLocalName = localName;
- frame.m_elementURI = uri;
- frame.m_isCdataSection = false;
- frame.m_startTagOpen = true;
-
- // is_Raw is already set in the HTML startElement() method
- // frame.m_isRaw = false;
- return frame;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemDesc.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemDesc.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ElemDesc.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,176 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ElemDesc.java,v 1.1.2.1 2007/01/09 18:57:28 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import org.ajax4jsf.xml.serializer.utils.StringToIntTable;
-
-/**
- * This class has a series of flags (bit values) that describe an HTML element
- *
- * This class is public because XSLTC uses it, it is not a public API.
- *
- * @xsl.usage internal
- */
-public final class ElemDesc
-{
- /** Bit flags to tell about this element type. */
- private int m_flags;
-
- /**
- * Table of attribute names to integers, which contain bit flags telling about
- * the attributes.
- */
- private StringToIntTable m_attrs = null;
-
- /** Bit position if this element type is empty. */
- static final int EMPTY = (1 << 1);
-
- /** Bit position if this element type is a flow. */
- private static final int FLOW = (1 << 2);
-
- /** Bit position if this element type is a block. */
- static final int BLOCK = (1 << 3);
-
- /** Bit position if this element type is a block form. */
- static final int BLOCKFORM = (1 << 4);
-
- /** Bit position if this element type is a block form field set. */
- static final int BLOCKFORMFIELDSET = (1 << 5);
-
- /** Bit position if this element type is CDATA. */
- private static final int CDATA = (1 << 6);
-
- /** Bit position if this element type is PCDATA. */
- private static final int PCDATA = (1 << 7);
-
- /** Bit position if this element type is should be raw characters. */
- static final int RAW = (1 << 8);
-
- /** Bit position if this element type should be inlined. */
- private static final int INLINE = (1 << 9);
-
- /** Bit position if this element type is INLINEA. */
- private static final int INLINEA = (1 << 10);
-
- /** Bit position if this element type is an inline label. */
- static final int INLINELABEL = (1 << 11);
-
- /** Bit position if this element type is a font style. */
- static final int FONTSTYLE = (1 << 12);
-
- /** Bit position if this element type is a phrase. */
- static final int PHRASE = (1 << 13);
-
- /** Bit position if this element type is a form control. */
- static final int FORMCTRL = (1 << 14);
-
- /** Bit position if this element type is ???. */
- static final int SPECIAL = (1 << 15);
-
- /** Bit position if this element type is ???. */
- static final int ASPECIAL = (1 << 16);
-
- /** Bit position if this element type is an odd header element. */
- static final int HEADMISC = (1 << 17);
-
- /** Bit position if this element type is a head element (i.e. H1, H2, etc.) */
- static final int HEAD = (1 << 18);
-
- /** Bit position if this element type is a list. */
- static final int LIST = (1 << 19);
-
- /** Bit position if this element type is a preformatted type. */
- static final int PREFORMATTED = (1 << 20);
-
- /** Bit position if this element type is whitespace sensitive. */
- static final int WHITESPACESENSITIVE = (1 << 21);
-
- /** Bit position if this element type is a header element (i.e. HEAD). */
- static final int HEADELEM = (1 << 22);
-
- /** Bit position if this element is the "HTML" element */
- private static final int HTMLELEM = (1 << 23);
-
- /** Bit position if this attribute type is a URL. */
- public static final int ATTRURL = (1 << 1);
-
- /** Bit position if this attribute type is an empty type. */
- public static final int ATTREMPTY = (1 << 2);
-
- /**
- * Construct an ElemDesc from a set of bit flags.
- *
- *
- * @param flags Bit flags that describe the basic properties of this element type.
- */
- ElemDesc(int flags)
- {
- m_flags = flags;
- }
-
- /**
- * Tell if this element type has the basic bit properties that are passed
- * as an argument.
- *
- * @param flags Bit flags that describe the basic properties of interest.
- *
- * @return true if any of the flag bits are true.
- */
- private boolean is(int flags)
- {
-
- // int which = (m_flags & flags);
- return (m_flags & flags) != 0;
- }
-
- int getFlags() {
- return m_flags;
- }
-
- /**
- * Set an attribute name and it's bit properties.
- *
- *
- * @param name non-null name of attribute, in upper case.
- * @param flags flag bits.
- */
- void setAttr(String name, int flags)
- {
-
- if (null == m_attrs)
- m_attrs = new StringToIntTable();
-
- m_attrs.put(name, flags);
- }
-
- /**
- * Tell if any of the bits of interest are set for a named attribute type.
- *
- * @param name non-null reference to attribute name, in any case.
- * @param flags flag mask.
- *
- * @return true if any of the flags are set for the named attribute.
- */
- public boolean isAttrFlagSet(String name, int flags)
- {
- return (null != m_attrs)
- ? ((m_attrs.getIgnoreCase(name) & flags) != 0)
- : false;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EmptySerializer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EmptySerializer.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EmptySerializer.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,755 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: EmptySerializer.java,v 1.1.2.1 2007/01/09 18:57:13 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Vector;
-
-import javax.xml.transform.SourceLocator;
-import javax.xml.transform.Transformer;
-
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-/**
- * This class is an adapter class. Its only purpose is to be extended and
- * for that extended class to over-ride all methods that are to be used.
- *
- * This class is not a public API, it is only public because it is used
- * across package boundaries.
- *
- * @xsl.usage internal
- */
-public class EmptySerializer implements SerializationHandler
-{
- protected static final String ERR = "EmptySerializer method not over-ridden";
- /**
- * @see SerializationHandler#asContentHandler()
- */
-
- protected void couldThrowIOException() throws IOException
- {
- return; // don't do anything.
- }
-
- protected void couldThrowSAXException() throws SAXException
- {
- return; // don't do anything.
- }
-
- protected void couldThrowSAXException(char[] chars, int off, int len) throws SAXException
- {
- return; // don't do anything.
- }
-
- protected void couldThrowSAXException(String elemQName) throws SAXException
- {
- return; // don't do anything.
- }
-
- protected void couldThrowException() throws Exception
- {
- return; // don't do anything.
- }
-
- void aMethodIsCalled()
- {
-
- // throw new RuntimeException(err);
- return;
- }
-
-
- /**
- * @see SerializationHandler#asContentHandler()
- */
- public ContentHandler asContentHandler() throws IOException
- {
- couldThrowIOException();
- return null;
- }
- /**
- * @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
- */
- public void setContentHandler(ContentHandler ch)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#close()
- */
- public void close()
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#getOutputFormat()
- */
- public Properties getOutputFormat()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see SerializationHandler#getOutputStream()
- */
- public OutputStream getOutputStream()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see SerializationHandler#getWriter()
- */
- public Writer getWriter()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see SerializationHandler#reset()
- */
- public boolean reset()
- {
- aMethodIsCalled();
- return false;
- }
- /**
- * @see SerializationHandler#serialize(org.w3c.dom.Node)
- */
- public void serialize(Node node) throws IOException
- {
- couldThrowIOException();
- }
- /**
- * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
- */
- public void setCdataSectionElements(Vector URI_and_localNames)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape) throws SAXException
- {
- couldThrowSAXException();
- return false;
- }
- /**
- * @see SerializationHandler#setIndent(boolean)
- */
- public void setIndent(boolean indent)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setIndentAmount(int)
- */
- public void setIndentAmount(int spaces)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setOutputFormat(java.util.Properties)
- */
- public void setOutputFormat(Properties format)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setOutputStream(java.io.OutputStream)
- */
- public void setOutputStream(OutputStream output)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setVersion(java.lang.String)
- */
- public void setVersion(String version)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setWriter(java.io.Writer)
- */
- public void setWriter(Writer writer)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#setTransformer(javax.xml.transform.Transformer)
- */
- public void setTransformer(Transformer transformer)
- {
- aMethodIsCalled();
- }
- /**
- * @see SerializationHandler#getTransformer()
- */
- public Transformer getTransformer()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see SerializationHandler#flushPending()
- */
- public void flushPending() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
- */
- public void addAttributes(Attributes atts) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String)
- */
- public void addAttribute(String name, String value)
- {
- aMethodIsCalled();
- }
-
- /**
- * @see ExtendedContentHandler#characters(java.lang.String)
- */
- public void characters(String chars) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#endElement(java.lang.String)
- */
- public void endElement(String elemName) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#startDocument()
- */
- public void startDocument() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String)
- */
- public void startElement(String uri, String localName, String qName)
- throws SAXException
- {
- couldThrowSAXException(qName);
- }
- /**
- * @see ExtendedContentHandler#startElement(java.lang.String)
- */
- public void startElement(String qName) throws SAXException
- {
- couldThrowSAXException(qName);
- }
- /**
- * @see ExtendedContentHandler#namespaceAfterStartElement(java.lang.String, java.lang.String)
- */
- public void namespaceAfterStartElement(String uri, String prefix)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#startPrefixMapping(java.lang.String, java.lang.String, boolean)
- */
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws SAXException
- {
- couldThrowSAXException();
- return false;
- }
- /**
- * @see ExtendedContentHandler#entityReference(java.lang.String)
- */
- public void entityReference(String entityName) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedContentHandler#getNamespaceMappings()
- */
- public NamespaceMappings getNamespaceMappings()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see ExtendedContentHandler#getPrefix(java.lang.String)
- */
- public String getPrefix(String uri)
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
- */
- public String getNamespaceURI(String name, boolean isElement)
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see ExtendedContentHandler#getNamespaceURIFromPrefix(java.lang.String)
- */
- public String getNamespaceURIFromPrefix(String prefix)
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see org.xml.sax.ContentHandler#setDocumentLocator(org.xml.sax.Locator)
- */
- public void setDocumentLocator(Locator arg0)
- {
- aMethodIsCalled();
- }
- /**
- * @see org.xml.sax.ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#startPrefixMapping(java.lang.String, java.lang.String)
- */
- public void startPrefixMapping(String arg0, String arg1)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#endPrefixMapping(java.lang.String)
- */
- public void endPrefixMapping(String arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String, java.lang.String, org.xml.sax.Attributes)
- */
- public void startElement(
- String arg0,
- String arg1,
- String arg2,
- Attributes arg3)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String, java.lang.String)
- */
- public void endElement(String arg0, String arg1, String arg2)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] arg0, int arg1, int arg2) throws SAXException
- {
- couldThrowSAXException(arg0, arg1, arg2);
- }
- /**
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#processingInstruction(java.lang.String, java.lang.String)
- */
- public void processingInstruction(String arg0, String arg1)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ContentHandler#skippedEntity(java.lang.String)
- */
- public void skippedEntity(String arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see ExtendedLexicalHandler#comment(java.lang.String)
- */
- public void comment(String comment) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#startDTD(java.lang.String, java.lang.String, java.lang.String)
- */
- public void startDTD(String arg0, String arg1, String arg2)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#endDTD()
- */
- public void endDTD() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#startEntity(java.lang.String)
- */
- public void startEntity(String arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#endEntity(java.lang.String)
- */
- public void endEntity(String arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#startCDATA()
- */
- public void startCDATA() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
- */
- public void comment(char[] arg0, int arg1, int arg2) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see XSLOutputAttributes#getDoctypePublic()
- */
- public String getDoctypePublic()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#getDoctypeSystem()
- */
- public String getDoctypeSystem()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#getEncoding()
- */
- public String getEncoding()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#getIndent()
- */
- public boolean getIndent()
- {
- aMethodIsCalled();
- return false;
- }
- /**
- * @see XSLOutputAttributes#getIndentAmount()
- */
- public int getIndentAmount()
- {
- aMethodIsCalled();
- return 0;
- }
- /**
- * @see XSLOutputAttributes#getMediaType()
- */
- public String getMediaType()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#getOmitXMLDeclaration()
- */
- public boolean getOmitXMLDeclaration()
- {
- aMethodIsCalled();
- return false;
- }
- /**
- * @see XSLOutputAttributes#getStandalone()
- */
- public String getStandalone()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#getVersion()
- */
- public String getVersion()
- {
- aMethodIsCalled();
- return null;
- }
- /**
- * @see XSLOutputAttributes#setCdataSectionElements
- */
- public void setCdataSectionElements(Hashtable h) throws Exception
- {
- couldThrowException();
- }
- /**
- * @see XSLOutputAttributes#setDoctype(java.lang.String, java.lang.String)
- */
- public void setDoctype(String system, String pub)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setDoctypePublic(java.lang.String)
- */
- public void setDoctypePublic(String doctype)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setDoctypeSystem(java.lang.String)
- */
- public void setDoctypeSystem(String doctype)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setEncoding(java.lang.String)
- */
- public void setEncoding(String encoding)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setMediaType(java.lang.String)
- */
- public void setMediaType(String mediatype)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
- */
- public void setOmitXMLDeclaration(boolean b)
- {
- aMethodIsCalled();
- }
- /**
- * @see XSLOutputAttributes#setStandalone(java.lang.String)
- */
- public void setStandalone(String standalone)
- {
- aMethodIsCalled();
- }
- /**
- * @see org.xml.sax.ext.DeclHandler#elementDecl(java.lang.String, java.lang.String)
- */
- public void elementDecl(String arg0, String arg1) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void attributeDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3,
- String arg4)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(java.lang.String, java.lang.String)
- */
- public void internalEntityDecl(String arg0, String arg1)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- public void externalEntityDecl(String arg0, String arg1, String arg2)
- throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
- */
- public void warning(SAXParseException arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
- */
- public void error(SAXParseException arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
- */
- public void fatalError(SAXParseException arg0) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see Serializer#asDOMSerializer()
- */
- public DOMSerializer asDOMSerializer() throws IOException
- {
- couldThrowIOException();
- return null;
- }
-
- /**
- * @see SerializationHandler#setNamespaceMappings(NamespaceMappings)
- */
- public void setNamespaceMappings(NamespaceMappings mappings) {
- aMethodIsCalled();
- }
-
- /**
- * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
- */
- public void setSourceLocator(SourceLocator locator)
- {
- aMethodIsCalled();
- }
-
- /**
- * @see ExtendedContentHandler#addUniqueAttribute(java.lang.String, java.lang.String, int)
- */
- public void addUniqueAttribute(String name, String value, int flags)
- throws SAXException
- {
- couldThrowSAXException();
- }
-
- /**
- * @see ExtendedContentHandler#characters(org.w3c.dom.Node)
- */
- public void characters(Node node) throws SAXException
- {
- couldThrowSAXException();
- }
-
- /**
- * @see ExtendedContentHandler#addXSLAttribute(java.lang.String, java.lang.String, java.lang.String)
- */
- public void addXSLAttribute(String qName, String value, String uri)
- {
- aMethodIsCalled();
- }
-
- /**
- * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
- {
- couldThrowSAXException();
- }
- /**
- * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- public void notationDecl(String arg0, String arg1, String arg2) throws SAXException
- {
- couldThrowSAXException();
- }
-
- /**
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void unparsedEntityDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3)
- throws SAXException {
- couldThrowSAXException();
- }
-
- /**
- * @see SerializationHandler#setDTDEntityExpansion(boolean)
- */
- public void setDTDEntityExpansion(boolean expand) {
- aMethodIsCalled();
-
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EncodingInfo.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EncodingInfo.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/EncodingInfo.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,507 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: EncodingInfo.java,v 1.1.2.1 2007/01/09 18:57:25 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-
-/**
- * Holds information about a given encoding, which is the Java name for the
- * encoding, the equivalent ISO name.
- * <p>
- * An object of this type has two useful methods
- * <pre>
- * isInEncoding(char ch);
- * </pre>
- * which can be called if the character is not the high one in
- * a surrogate pair and:
- * <pre>
- * isInEncoding(char high, char low);
- * </pre>
- * which can be called if the two characters from a high/low surrogate pair.
- * <p>
- * An EncodingInfo object is a node in a binary search tree. Such a node
- * will answer if a character is in the encoding, and do so for a given
- * range of unicode values (<code>m_first</code> to
- * <code>m_last</code>). It will handle a certain range of values
- * explicitly (<code>m_explFirst</code> to <code>m_explLast</code>).
- * If the unicode point is before that explicit range, that is it
- * is in the range <code>m_first <= value < m_explFirst</code>, then it will delegate to another EncodingInfo object for The root
- * of such a tree, m_before. Likewise for values in the range
- * <code>m_explLast < value <= m_last</code>, but delgating to <code>m_after</code>
- * <p>
- * Actually figuring out if a code point is in the encoding is expensive. So the
- * purpose of this tree is to cache such determinations, and not to build the
- * entire tree of information at the start, but only build up as much of the
- * tree as is used during the transformation.
- * <p>
- * This Class is not a public API, and should only be used internally within
- * the serializer.
- *
- * @xsl.usage internal
- */
-public final class EncodingInfo extends Object
-{
-
- /**
- * The ISO encoding name.
- */
- final String name;
-
- /**
- * The name used by the Java convertor.
- */
- final String javaName;
-
- /**
- * A helper object that we can ask if a
- * single char, or a surrogate UTF-16 pair
- * of chars that form a single character,
- * is in this encoding.
- */
- private InEncoding m_encoding;
-
- /**
- * This is not a public API. It returns true if the
- * char in question is in the encoding.
- * @param ch the char in question.
- * @xsl.usage internal
- */
- public boolean isInEncoding(char ch) {
- if (m_encoding == null) {
- m_encoding = new EncodingImpl();
-
- // One could put alternate logic in here to
- // instantiate another object that implements the
- // InEncoding interface. For example if the JRE is 1.4 or up
- // we could have an object that uses JRE 1.4 methods
- }
- return m_encoding.isInEncoding(ch);
- }
-
- /**
- * This is not a public API. It returns true if the
- * character formed by the high/low pair is in the encoding.
- * @param high a char that the a high char of a high/low surrogate pair.
- * @param low a char that is the low char of a high/low surrogate pair.
- * @xsl.usage internal
- */
- public boolean isInEncoding(char high, char low) {
- if (m_encoding == null) {
- m_encoding = new EncodingImpl();
-
- // One could put alternate logic in here to
- // instantiate another object that implements the
- // InEncoding interface. For example if the JRE is 1.4 or up
- // we could have an object that uses JRE 1.4 methods
- }
- return m_encoding.isInEncoding(high, low);
- }
-
- /**
- * Create an EncodingInfo object based on the ISO name and Java name.
- * If both parameters are null any character will be considered to
- * be in the encoding. This is useful for when the serializer is in
- * temporary output state, and has no assciated encoding.
- *
- * @param name reference to the ISO name.
- * @param javaName reference to the Java encoding name.
- */
- public EncodingInfo(String name, String javaName)
- {
-
- this.name = name;
- this.javaName = javaName;
- }
-
-
-
- /**
- * A simple interface to isolate the implementation.
- * We could also use some new JRE 1.4 methods in another implementation
- * provided we use reflection with them.
- * <p>
- * This interface is not a public API,
- * and should only be used internally within the serializer.
- * @xsl.usage internal
- */
- private interface InEncoding {
- /**
- * Returns true if the char is in the encoding
- */
- public boolean isInEncoding(char ch);
- /**
- * Returns true if the high/low surrogate pair forms
- * a character that is in the encoding.
- */
- public boolean isInEncoding(char high, char low);
- }
-
- /**
- * This class implements the
- */
- private class EncodingImpl implements InEncoding {
-
-
-
- public boolean isInEncoding(char ch1) {
- final boolean ret;
- int codePoint = Encodings.toCodePoint(ch1);
- if (codePoint < m_explFirst) {
- // The unicode value is before the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_before object to delegate to, make one.
- if (m_before == null)
- m_before =
- new EncodingImpl(
- m_encoding,
- m_first,
- m_explFirst - 1,
- codePoint);
- ret = m_before.isInEncoding(ch1);
- } else if (m_explLast < codePoint) {
- // The unicode value is after the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_after object to delegate to, make one.
- if (m_after == null)
- m_after =
- new EncodingImpl(
- m_encoding,
- m_explLast + 1,
- m_last,
- codePoint);
- ret = m_after.isInEncoding(ch1);
- } else {
- // The unicode value is in the range we explitly handle
- final int idx = codePoint - m_explFirst;
-
- // If we already know the answer, just return it.
- if (m_alreadyKnown[idx])
- ret = m_isInEncoding[idx];
- else {
- // We don't know the answer, so find out,
- // which may be expensive, then cache the answer
- ret = inEncoding(ch1, m_encoding);
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = ret;
- }
- }
- return ret;
- }
-
- public boolean isInEncoding(char high, char low) {
- final boolean ret;
- int codePoint = Encodings.toCodePoint(high,low);
- if (codePoint < m_explFirst) {
- // The unicode value is before the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_before object to delegate to, make one.
- if (m_before == null)
- m_before =
- new EncodingImpl(
- m_encoding,
- m_first,
- m_explFirst - 1,
- codePoint);
- ret = m_before.isInEncoding(high,low);
- } else if (m_explLast < codePoint) {
- // The unicode value is after the range
- // that we explictly manage, so we delegate the answer.
-
- // If we don't have an m_after object to delegate to, make one.
- if (m_after == null)
- m_after =
- new EncodingImpl(
- m_encoding,
- m_explLast + 1,
- m_last,
- codePoint);
- ret = m_after.isInEncoding(high,low);
- } else {
- // The unicode value is in the range we explitly handle
- final int idx = codePoint - m_explFirst;
-
- // If we already know the answer, just return it.
- if (m_alreadyKnown[idx])
- ret = m_isInEncoding[idx];
- else {
- // We don't know the answer, so find out,
- // which may be expensive, then cache the answer
- ret = inEncoding(high, low, m_encoding);
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = ret;
- }
- }
- return ret;
- }
-
- /**
- * The encoding.
- */
- final private String m_encoding;
- /**
- * m_first through m_last is the range of unicode
- * values that this object will return an answer on.
- * It may delegate to a similar object with a different
- * range
- */
- final private int m_first;
-
- /**
- * m_explFirst through m_explLast is the range of unicode
- * value that this object handles explicitly and does not
- * delegate to a similar object.
- */
- final private int m_explFirst;
- final private int m_explLast;
- final private int m_last;
-
- /**
- * The object, of the same type as this one,
- * that handles unicode values in a range before
- * the range explictly handled by this object, and
- * to which this object may delegate.
- */
- private InEncoding m_before;
- /**
- * The object, of the same type as this one,
- * that handles unicode values in a range after
- * the range explictly handled by this object, and
- * to which this object may delegate.
- */
- private InEncoding m_after;
-
- /**
- * The number of unicode values explicitly handled
- * by a single EncodingInfo object. This value is
- * tuneable, but is set to 128 because that covers the
- * entire low range of ASCII type chars within a single
- * object.
- */
- private static final int RANGE = 128;
-
- /**
- * A flag to record if we already know the answer
- * for the given unicode value.
- */
- final private boolean m_alreadyKnown[] = new boolean[RANGE];
- /**
- * A table holding the answer on whether the given unicode
- * value is in the encoding.
- */
- final private boolean m_isInEncoding[] = new boolean[RANGE];
-
- private EncodingImpl() {
- // This object will answer whether any unicode value
- // is in the encoding, it handles values 0 through Integer.MAX_VALUE
- this(javaName, 0, Integer.MAX_VALUE, (char) 0);
- }
-
- private EncodingImpl(String encoding, int first, int last, int codePoint) {
- // Set the range of unicode values that this object manages
- // either explicitly or implicitly.
- m_first = first;
- m_last = last;
-
- // Set the range of unicode values that this object
- // explicitly manages
- m_explFirst = codePoint;
- m_explLast = codePoint + (RANGE-1);
-
- m_encoding = encoding;
-
- if (javaName != null)
- {
- // Some optimization.
- if (0 <= m_explFirst && m_explFirst <= 127) {
- // This particular EncodingImpl explicitly handles
- // characters in the low range.
- if ("UTF8".equals(javaName)
- || "UTF-16".equals(javaName)
- || "ASCII".equals(javaName)
- || "US-ASCII".equals(javaName)
- || "Unicode".equals(javaName)
- || "UNICODE".equals(javaName)
- || javaName.startsWith("ISO8859")) {
-
- // Not only does this EncodingImpl object explicitly
- // handle chracters in the low range, it is
- // also one that we know something about, without
- // needing to call inEncoding(char ch, String encoding)
- // for this low range
- //
- // By initializing the table ahead of time
- // for these low values, we prevent the expensive
- // inEncoding(char ch, String encoding)
- // from being called, at least for these common
- // encodings.
- for (int unicode = 1; unicode < 127; unicode++) {
- final int idx = unicode - m_explFirst;
- if (0 <= idx && idx < RANGE) {
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = true;
- }
- }
- }
- }
-
- /* A little bit more than optimization.
- *
- * We will say that any character is in the encoding if
- * we don't have an encoding.
- * This is meaningful when the serializer is being used
- * in temporary output state, where we are not writing to
- * the final output tree. It is when writing to the
- * final output tree that we need to worry about the output
- * encoding
- */
- if (javaName == null) {
- for (int idx = 0; idx < m_alreadyKnown.length; idx++) {
- m_alreadyKnown[idx] = true;
- m_isInEncoding[idx] = true;
- }
- }
- }
- }
- }
-
- /**
- * This is heart of the code that determines if a given character
- * is in the given encoding. This method is probably expensive,
- * and the answer should be cached.
- * <p>
- * This method is not a public API,
- * and should only be used internally within the serializer.
- * @param ch the char in question, that is not a high char of
- * a high/low surrogate pair.
- * @param encoding the Java name of the enocding.
- *
- * @xsl.usage internal
- *
- */
- private static boolean inEncoding(char ch, String encoding) {
- boolean isInEncoding;
- try {
- char cArray[] = new char[1];
- cArray[0] = ch;
- // Construct a String from the char
- String s = new String(cArray);
- // Encode the String into a sequence of bytes
- // using the given, named charset.
- byte[] bArray = s.getBytes(encoding);
- isInEncoding = inEncoding(ch, bArray);
-
- } catch (Exception e) {
- isInEncoding = false;
-
- // If for some reason the encoding is null, e.g.
- // for a temporary result tree, we should just
- // say that every character is in the encoding.
- if (encoding == null)
- isInEncoding = true;
- }
- return isInEncoding;
- }
-
- /**
- * This is heart of the code that determines if a given high/low
- * surrogate pair forms a character that is in the given encoding.
- * This method is probably expensive, and the answer should be cached.
- * <p>
- * This method is not a public API,
- * and should only be used internally within the serializer.
- * @param high the high char of
- * a high/low surrogate pair.
- * @param low the low char of a high/low surrogate pair.
- * @param encoding the Java name of the encoding.
- *
- * @xsl.usage internal
- *
- */
- private static boolean inEncoding(char high, char low, String encoding) {
- boolean isInEncoding;
- try {
- char cArray[] = new char[2];
- cArray[0] = high;
- cArray[1] = low;
- // Construct a String from the char
- String s = new String(cArray);
- // Encode the String into a sequence of bytes
- // using the given, named charset.
- byte[] bArray = s.getBytes(encoding);
- isInEncoding = inEncoding(high,bArray);
- } catch (Exception e) {
- isInEncoding = false;
- }
-
- return isInEncoding;
- }
-
- /**
- * This method is the core of determining if character
- * is in the encoding. The method is not foolproof, because
- * s.getBytes(encoding) has specified behavior only if the
- * characters are in the specified encoding. However this
- * method tries it's best.
- * @param ch the char that was converted using getBytes, or
- * the first char of a high/low pair that was converted.
- * @param data the bytes written out by the call to s.getBytes(encoding);
- * @return true if the character is in the encoding.
- */
- private static boolean inEncoding(char ch, byte[] data) {
- final boolean isInEncoding;
- // If the string written out as data is not in the encoding,
- // the output is not specified according to the documentation
- // on the String.getBytes(encoding) method,
- // but we do our best here.
- if (data==null || data.length == 0) {
- isInEncoding = false;
- }
- else {
- if (data[0] == 0)
- isInEncoding = false;
- else if (data[0] == '?' && ch != '?')
- isInEncoding = false;
- /*
- * else if (isJapanese) {
- * // isJapanese is really
- * // ( "EUC-JP".equals(javaName)
- * // || "EUC_JP".equals(javaName)
- * // || "SJIS".equals(javaName) )
- *
- * // Work around some bugs in JRE for Japanese
- * if(data[0] == 0x21)
- * isInEncoding = false;
- * else if (ch == 0xA5)
- * isInEncoding = false;
- * else
- * isInEncoding = true;
- * }
- */
-
- else {
- // We don't know for sure, but it looks like it is in the encoding
- isInEncoding = true;
- }
- }
- return isInEncoding;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Encodings.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Encodings.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Encodings.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,451 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: Encodings.java,v 1.1.2.1 2007/01/09 18:57:26 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-
-/**
- * Provides information about encodings. Depends on the Java runtime
- * to provides writers for the different encodings.
- *
- * This class is only for internal use within Xalan. However, it is used directly
- * by org.apache.xalan.xsltc.compiler.Output.
- *
- * @xsl.usage internal
- */
-
-public final class Encodings extends Object
-{
- /**
- * Standard filename for properties file with encodings data.
- */
- private static final String ENCODINGS_FILE = "org/ajax4jsf/xml/serializer/Encodings.properties";
-
- /**
- * Standard filename for properties file with encodings data.
- */
- private static final String ENCODINGS_PROP = "org.apache.xalan.serialize.encodings";
-
- /**
- * Returns a writer for the specified encoding based on
- * an output stream.
- * <p>
- * This is not a public API.
- * @param output The output stream
- * @param encoding The encoding
- * @return A suitable writer
- * @throws UnsupportedEncodingException There is no convertor
- * to support this encoding
- * @xsl.usage internal
- */
- static Writer getWriter(OutputStream output, String encoding)
- throws UnsupportedEncodingException
- {
-
- for (int i = 0; i < _encodings.length; ++i)
- {
- if (_encodings[i].name.equalsIgnoreCase(encoding))
- {
- try
- {
- return new OutputStreamWriter(
- output,
- _encodings[i].javaName);
- }
- catch (java.lang.IllegalArgumentException iae) // java 1.1.8
- {
- // keep trying
- }
- catch (UnsupportedEncodingException usee)
- {
-
- // keep trying
- }
- }
- }
-
- try
- {
- return new OutputStreamWriter(output, encoding);
- }
- catch (java.lang.IllegalArgumentException iae) // java 1.1.8
- {
- throw new UnsupportedEncodingException(encoding);
- }
- }
-
- /**
- * Returns the EncodingInfo object for the specified
- * encoding.
- * <p>
- * This is not a public API.
- *
- * @param encoding The encoding
- * @return The object that is used to determine if
- * characters are in the given encoding.
- * @xsl.usage internal
- */
- static EncodingInfo getEncodingInfo(String encoding)
- {
- EncodingInfo ei;
-
- String normalizedEncoding = toUpperCaseFast(encoding);
- ei = (EncodingInfo) _encodingTableKeyJava.get(normalizedEncoding);
- if (ei == null)
- ei = (EncodingInfo) _encodingTableKeyMime.get(normalizedEncoding);
- if (ei == null) {
- // We shouldn't have to do this, but just in case.
- ei = new EncodingInfo(null,null);
- }
-
- return ei;
- }
-
- /**
- * A fast and cheap way to uppercase a String that is
- * only made of printable ASCII characters.
- * <p>
- * This is not a public API.
- * @param s a String of ASCII characters
- * @return an uppercased version of the input String,
- * possibly the same String.
- * @xsl.usage internal
- */
- static private String toUpperCaseFast(final String s) {
-
- boolean different = false;
- final int mx = s.length();
- char[] chars = new char[mx];
- for (int i=0; i < mx; i++) {
- char ch = s.charAt(i);
- // is the character a lower case ASCII one?
- if ('a' <= ch && ch <= 'z') {
- // a cheap and fast way to uppercase that is good enough
- ch = (char) (ch + ('A' - 'a'));
- different = true; // the uppercased String is different
- }
- chars[i] = ch;
- }
-
- // A little optimization, don't call String.valueOf() if
- // the uppercased string is the same as the input string.
- final String upper;
- if (different)
- upper = String.valueOf(chars);
- else
- upper = s;
-
- return upper;
- }
-
- /** The default encoding, ISO style, ISO style. */
- static final String DEFAULT_MIME_ENCODING = "UTF-8";
-
- /**
- * Get the proper mime encoding. From the XSLT recommendation: "The encoding
- * attribute specifies the preferred encoding to use for outputting the result
- * tree. XSLT processors are required to respect values of UTF-8 and UTF-16.
- * For other values, if the XSLT processor does not support the specified
- * encoding it may signal an error; if it does not signal an error it should
- * use UTF-8 or UTF-16 instead. The XSLT processor must not use an encoding
- * whose name does not match the EncName production of the XML Recommendation
- * [XML]. If no encoding attribute is specified, then the XSLT processor should
- * use either UTF-8 or UTF-16."
- * <p>
- * This is not a public API.
- *
- * @param encoding Reference to java-style encoding string, which may be null,
- * in which case a default will be found.
- *
- * @return The ISO-style encoding string, or null if failure.
- * @xsl.usage internal
- */
- static String getMimeEncoding(String encoding)
- {
-
- if (null == encoding)
- {
- try
- {
-
- // Get the default system character encoding. This may be
- // incorrect if they passed in a writer, but right now there
- // seems to be no way to get the encoding from a writer.
- encoding = System.getProperty("file.encoding", "UTF8");
-
- if (null != encoding)
- {
-
- /*
- * See if the mime type is equal to UTF8. If you don't
- * do that, then convertJava2MimeEncoding will convert
- * 8859_1 to "ISO-8859-1", which is not what we want,
- * I think, and I don't think I want to alter the tables
- * to convert everything to UTF-8.
- */
- String jencoding =
- (encoding.equalsIgnoreCase("Cp1252")
- || encoding.equalsIgnoreCase("ISO8859_1")
- || encoding.equalsIgnoreCase("8859_1")
- || encoding.equalsIgnoreCase("UTF8"))
- ? DEFAULT_MIME_ENCODING
- : convertJava2MimeEncoding(encoding);
-
- encoding =
- (null != jencoding) ? jencoding : DEFAULT_MIME_ENCODING;
- }
- else
- {
- encoding = DEFAULT_MIME_ENCODING;
- }
- }
- catch (SecurityException se)
- {
- encoding = DEFAULT_MIME_ENCODING;
- }
- }
- else
- {
- encoding = convertJava2MimeEncoding(encoding);
- }
-
- return encoding;
- }
-
- /**
- * Try the best we can to convert a Java encoding to a XML-style encoding.
- * <p>
- * This is not a public API.
- * @param encoding non-null reference to encoding string, java style.
- *
- * @return ISO-style encoding string.
- * @xsl.usage internal
- */
- private static String convertJava2MimeEncoding(String encoding)
- {
- EncodingInfo enc =
- (EncodingInfo) _encodingTableKeyJava.get(toUpperCaseFast(encoding));
- if (null != enc)
- return enc.name;
- return encoding;
- }
-
- /**
- * Try the best we can to convert a Java encoding to a XML-style encoding.
- * <p>
- * This is not a public API.
- *
- * @param encoding non-null reference to encoding string, java style.
- *
- * @return ISO-style encoding string.
- *
- * @xsl.usage internal
- */
- public static String convertMime2JavaEncoding(String encoding)
- {
-
- for (int i = 0; i < _encodings.length; ++i)
- {
- if (_encodings[i].name.equalsIgnoreCase(encoding))
- {
- return _encodings[i].javaName;
- }
- }
-
- return encoding;
- }
-
- /**
- * Load a list of all the supported encodings.
- *
- * System property "encodings" formatted using URL syntax may define an
- * external encodings list. Thanks to Sergey Ushakov for the code
- * contribution!
- * @xsl.usage internal
- */
- private static EncodingInfo[] loadEncodingInfo()
- {
- URL url = null;
- try
- {
- String urlString = null;
- InputStream is = null;
-
- try
- {
- urlString = System.getProperty(ENCODINGS_PROP, "");
- }
- catch (SecurityException e)
- {
- }
-
- if (urlString != null && urlString.length() > 0) {
- url = new URL(urlString);
- is = url.openStream();
- }
-
- if (is == null) {
- SecuritySupport ss = SecuritySupport.getInstance();
- is = ss.getResourceAsStream(ObjectFactory.findClassLoader(),
- ENCODINGS_FILE);
- }
-
- Properties props = new Properties();
- if (is != null) {
- props.load(is);
- is.close();
- } else {
- // Seems to be no real need to force failure here, let the
- // system do its best... The issue is not really very critical,
- // and the output will be in any case _correct_ though maybe not
- // always human-friendly... :)
- // But maybe report/log the resource problem?
- // Any standard ways to report/log errors (in static context)?
- }
-
- int totalEntries = props.size();
- int totalMimeNames = 0;
- Enumeration keys = props.keys();
- for (int i = 0; i < totalEntries; ++i)
- {
- String javaName = (String) keys.nextElement();
- String val = props.getProperty(javaName);
- totalMimeNames++;
- int pos = val.indexOf(' ');
- for (int j = 0; j < pos; ++j)
- if (val.charAt(j) == ',')
- totalMimeNames++;
- }
- EncodingInfo[] ret = new EncodingInfo[totalMimeNames];
- int j = 0;
- keys = props.keys();
- for (int i = 0; i < totalEntries; ++i)
- {
- String javaName = (String) keys.nextElement();
- String val = props.getProperty(javaName);
- int pos = val.indexOf(' ');
- String mimeName;
- //int lastPrintable;
- if (pos < 0)
- {
- // Maybe report/log this problem?
- // "Last printable character not defined for encoding " +
- // mimeName + " (" + val + ")" ...
- mimeName = val;
- // lastPrintable = 0x00FF;
- }
- else
- {
-// lastPrintable =
-// Integer.decode(val.substring(pos).trim()).intValue();
- StringTokenizer st =
- new StringTokenizer(val.substring(0, pos), ",");
- for (boolean first = true;
- st.hasMoreTokens();
- first = false)
- {
- mimeName = st.nextToken();
- ret[j] =
- new EncodingInfo(mimeName, javaName);
- _encodingTableKeyMime.put(
- mimeName.toUpperCase(),
- ret[j]);
- if (first)
- _encodingTableKeyJava.put(
- javaName.toUpperCase(),
- ret[j]);
- j++;
- }
- }
- }
- return ret;
- }
- catch (java.net.MalformedURLException mue)
- {
- throw new org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException(mue);
- }
- catch (java.io.IOException ioe)
- {
- throw new org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException(ioe);
- }
- }
-
- /**
- * Return true if the character is the high member of a surrogate pair.
- * <p>
- * This is not a public API.
- * @param ch the character to test
- * @xsl.usage internal
- */
- static boolean isHighUTF16Surrogate(char ch) {
- return ('\uD800' <= ch && ch <= '\uDBFF');
- }
- /**
- * Return true if the character is the low member of a surrogate pair.
- * <p>
- * This is not a public API.
- * @param ch the character to test
- * @xsl.usage internal
- */
- static boolean isLowUTF16Surrogate(char ch) {
- return ('\uDC00' <= ch && ch <= '\uDFFF');
- }
- /**
- * Return the unicode code point represented by the high/low surrogate pair.
- * <p>
- * This is not a public API.
- * @param highSurrogate the high char of the high/low pair
- * @param lowSurrogate the low char of the high/low pair
- * @xsl.usage internal
- */
- static int toCodePoint(char highSurrogate, char lowSurrogate) {
- int codePoint =
- ((highSurrogate - 0xd800) << 10)
- + (lowSurrogate - 0xdc00)
- + 0x10000;
- return codePoint;
- }
- /**
- * Return the unicode code point represented by the char.
- * A bit of a dummy method, since all it does is return the char,
- * but as an int value.
- * <p>
- * This is not a public API.
- * @param ch the char.
- * @xsl.usage internal
- */
- static int toCodePoint(char ch) {
- int codePoint = ch;
- return codePoint;
- }
-
- private static final Hashtable _encodingTableKeyJava = new Hashtable();
- private static final Hashtable _encodingTableKeyMime = new Hashtable();
- private static final EncodingInfo[] _encodings = loadEncodingInfo();
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedContentHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedContentHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedContentHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,269 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ExtendedContentHandler.java,v 1.1.2.1 2007/01/09 18:57:26 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import javax.xml.transform.SourceLocator;
-
-import org.xml.sax.SAXException;
-
-/**
- * This interface describes extensions to the SAX ContentHandler interface.
- * It is intended to be used by a serializer. The methods on this interface will
- * implement SAX- like behavior. This allows the gradual collection of
- * information rather than having it all up front. For example the call
- * <pre>
- * startElement(namespaceURI,localName,qName,atts)
- * </pre>
- * could be replaced with the calls
- * <pre>
- * startElement(namespaceURI,localName,qName)
- * addAttributes(atts)
- * </pre>
- * If there are no attributes the second call can be dropped. If attributes are
- * to be added one at a time with calls to
- * <pre>
- * addAttribute(namespaceURI, localName, qName, type, value)
- * </pre>
- * @xsl.usage internal
- */
-abstract interface ExtendedContentHandler extends org.xml.sax.ContentHandler
-{
- /**
- * Add at attribute to the current element
- * @param uri the namespace URI of the attribute name
- * @param localName the local name of the attribute (without prefix)
- * @param rawName the qualified name of the attribute
- * @param type the attribute type typically character data (CDATA)
- * @param value the value of the attribute
- * @param XSLAttribute true if the added attribute is coming from an xsl:attribute element
- * @throws SAXException
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- throws SAXException;
- /**
- * Add attributes to the current element
- * @param atts the attributes to add.
- * @throws SAXException
- */
- public void addAttributes(org.xml.sax.Attributes atts)
- throws org.xml.sax.SAXException;
- /**
- * Add an attribute to the current element. The namespace URI of the
- * attribute will be calculated from the prefix of qName. The local name
- * will be derived from qName and the type will be assumed to be "CDATA".
- * @param qName
- * @param value
- */
- public void addAttribute(String qName, String value);
-
- /**
- * This method is used to notify of a character event, but passing the data
- * as a character String rather than the standard character array.
- * @param chars the character data
- * @throws SAXException
- */
- public void characters(String chars) throws SAXException;
-
- /**
- * This method is used to notify of a character event, but passing the data
- * as a DOM Node rather than the standard character array.
- * @param node a DOM Node containing text.
- * @throws SAXException
- */
- public void characters(org.w3c.dom.Node node) throws org.xml.sax.SAXException;
- /**
- * This method is used to notify that an element has ended. Unlike the
- * standard SAX method
- * <pre>
- * endElement(namespaceURI,localName,qName)
- * </pre>
- * only the last parameter is passed. If needed the serializer can derive
- * the localName from the qualified name and derive the namespaceURI from
- * its implementation.
- * @param elemName the fully qualified element name.
- * @throws SAXException
- */
- public void endElement(String elemName) throws SAXException;
-
- /**
- * This method is used to notify that an element is starting.
- * This method is just like the standard SAX method
- * <pre>
- * startElement(uri,localName,qname,atts)
- * </pre>
- * but without the attributes.
- * @param uri the namespace URI of the element
- * @param localName the local name (without prefix) of the element
- * @param qName the qualified name of the element
- *
- * @throws SAXException
- */
- public void startElement(String uri, String localName, String qName)
- throws org.xml.sax.SAXException;
-
- /**
- * This method is used to notify of the start of an element
- * @param qName the fully qualified name of the element
- * @throws SAXException
- */
- public void startElement(String qName) throws SAXException;
- /**
- * This method is used to notify that a prefix mapping is to start, but
- * after an element is started. The SAX method call
- * <pre>
- * startPrefixMapping(prefix,uri)
- * </pre>
- * is used just before an element starts and applies to the element to come,
- * not to the current element. This method applies to the current element.
- * For example one could make the calls in this order:
- * <pre>
- * startElement("prfx8:elem9")
- * namespaceAfterStartElement("http://namespace8","prfx8")
- * </pre>
- *
- * @param uri the namespace URI being declared
- * @param prefix the prefix that maps to the given namespace
- * @throws SAXException
- */
- public void namespaceAfterStartElement(String uri, String prefix)
- throws SAXException;
-
- /**
- * This method is used to notify that a prefix maping is to start, which can
- * be for the current element, or for the one to come.
- * @param prefix the prefix that maps to the given URI
- * @param uri the namespace URI of the given prefix
- * @param shouldFlush if true this call is like the SAX
- * startPrefixMapping(prefix,uri) call and the mapping applies to the
- * element to come. If false the mapping applies to the current element.
- * @return boolean false if the prefix mapping was already in effect (in
- * other words we are just re-declaring), true if this is a new, never
- * before seen mapping for the element.
- * @throws SAXException
- */
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws SAXException;
- /**
- * Notify of an entity reference.
- * @param entityName the name of the entity
- * @throws SAXException
- */
- public void entityReference(String entityName) throws SAXException;
-
- /**
- * This method returns an object that has the current namespace mappings in
- * effect.
- *
- * @return NamespaceMappings an object that has the current namespace
- * mappings in effect.
- */
- public NamespaceMappings getNamespaceMappings();
- /**
- * This method returns the prefix that currently maps to the given namespace
- * URI.
- * @param uri the namespace URI
- * @return String the prefix that currently maps to the given URI.
- */
- public String getPrefix(String uri);
- /**
- * This method gets the prefix associated with a current element or
- * attribute name.
- * @param name the qualified name of an element, or attribute
- * @param isElement true if it is an element name, false if it is an
- * atttribute name
- * @return String the namespace URI associated with the element or
- * attribute.
- */
- public String getNamespaceURI(String name, boolean isElement);
- /**
- * This method returns the namespace URI currently associated with the
- * prefix.
- * @param prefix a prefix of an element or attribute.
- * @return String the namespace URI currently associated with the prefix.
- */
- public String getNamespaceURIFromPrefix(String prefix);
-
- /**
- * This method is used to set the source locator, which might be used to
- * generated an error message.
- * @param locator the source locator
- */
- public void setSourceLocator(SourceLocator locator);
-
- // Bit constants for addUniqueAttribute().
-
- // The attribute value contains no bad characters. A "bad" character is one which
- // is greater than 126 or it is one of '<', '>', '&' or '"'.
- public static final int NO_BAD_CHARS = 0x1;
-
- // An HTML empty attribute (e.g. <OPTION selected>).
- public static final int HTML_ATTREMPTY = 0x2;
-
- // An HTML URL attribute
- public static final int HTML_ATTRURL = 0x4;
-
- /**
- * Add a unique attribute to the current element.
- * The attribute is guaranteed to be unique here. The serializer can write
- * it out immediately without saving it in a table first. The integer
- * flag contains information about the attribute, which helps the serializer
- * to decide whether a particular processing is needed.
- *
- * @param qName the fully qualified attribute name.
- * @param value the attribute value
- * @param flags a bitwise flag
- */
- public void addUniqueAttribute(String qName, String value, int flags)
- throws SAXException;
-
- /**
- * Add an attribute from an xsl:attribute element.
- * @param qName the qualified attribute name (prefix:localName)
- * @param value the attributes value
- * @param uri the uri that the prefix of the qName is mapped to.
- */
- public void addXSLAttribute(String qName, final String value, final String uri);
-
- /**
- * Add at attribute to the current element, not from an xsl:attribute
- * element.
- * @param uri the namespace URI of the attribute name
- * @param localName the local name of the attribute (without prefix)
- * @param rawName the qualified name of the attribute
- * @param type the attribute type typically character data (CDATA)
- * @param value the value of the attribute
- * @throws SAXException
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value)
- throws SAXException;
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedLexicalHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedLexicalHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ExtendedLexicalHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,37 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ExtendedLexicalHandler.java,v 1.1.2.1 2007/01/09 18:57:17 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import org.xml.sax.SAXException;
-
-/**
- * This interface has extensions to the standard SAX LexicalHandler interface.
- * This interface is intended to be used by a serializer.
- * @xsl.usage internal
- */
-abstract interface ExtendedLexicalHandler extends org.xml.sax.ext.LexicalHandler
-{
- /**
- * This method is used to notify of a comment
- * @param comment the comment, but unlike the SAX comment() method this
- * method takes a String rather than a character array.
- * @throws SAXException
- */
- public void comment(String comment) throws SAXException;
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Method.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Method.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Method.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,74 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: Method.java,v 1.1.2.1 2007/01/09 18:57:27 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-/**
- * This class defines the constants which are the names of the four default
- * output methods.
- * <p>
- * Three default output methods are defined: XML, HTML, and TEXT.
- * These constants can be used as an argument to the
- * OutputPropertiesFactory.getDefaultMethodProperties() method to get
- * the properties to create a serializer.
- *
- * This class is a public API.
- *
- * @see OutputPropertiesFactory
- * @see Serializer
- *
- * @xsl.usage general
- */
-public final class Method
-{
- /**
- * A private constructor to prevent the creation of such a class.
- */
- private Method() {
-
- }
-
- /**
- * The output method type for XML documents: <tt>xml</tt>.
- */
- public static final String XML = "xml";
-
- /**
- * The output method type for HTML documents: <tt>html</tt>.
- */
- public static final String HTML = "html";
-
- /**
- * The output method for XHTML documents,
- * this method type is not currently supported: <tt>xhtml</tt>.
- */
- public static final String XHTML = "xhtml";
-
- /**
- * The output method type for text documents: <tt>text</tt>.
- */
- public static final String TEXT = "text";
-
- /**
- * The "internal" method, just used when no method is
- * specified in the style sheet, and a serializer of this type wraps either an
- * XML or HTML type (depending on the first tag in the output being html or
- * not)
- */
- public static final String UNKNOWN = "";
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/NamespaceMappings.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,327 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: NamespaceMappings.java,v 1.1.2.1 2007/01/09 18:57:19 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Stack;
-
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-/**
- * This class keeps track of the currently defined namespaces. Conceptually the
- * prefix/uri/depth triplets are pushed on a stack pushed on a stack. The depth
- * indicates the nesting depth of the element for which the mapping was made.
- *
- * <p>For example:
- * <pre>
- * <chapter xmlns:p1="def">
- * <paragraph xmlns:p2="ghi">
- * <sentance xmlns:p3="jkl">
- * </sentance>
- * </paragraph>
- * <paragraph xlmns:p4="mno">
- * </paragraph>
- * </chapter>
- * </pre>
- *
- * When the <chapter> element is encounted the prefix "p1" associated with uri
- * "def" is pushed on the stack with depth 1.
- * When the first <paragraph> is encountered "p2" and "ghi" are pushed with
- * depth 2.
- * When the <sentance> is encountered "p3" and "jkl" are pushed with depth 3.
- * When </sentance> occurs the popNamespaces(3) will pop "p3"/"jkl" off the
- * stack. Of course popNamespaces(2) would pop anything with depth 2 or
- * greater.
- *
- * So prefix/uri pairs are pushed and poped off the stack as elements are
- * processed. At any given moment of processing the currently visible prefixes
- * are on the stack and a prefix can be found given a uri, or a uri can be found
- * given a prefix.
- *
- * This class is public only because it is used by Xalan. It is not a public API
- *
- * @xsl.usage internal
- */
-public class NamespaceMappings
-{
- /**
- * This member is continually incremented when new prefixes need to be
- * generated. ("ns0" "ns1" ...)
- */
- private int count = 0;
-
- /**
- * Each entry (prefix) in this hashtable points to a Stack of URIs
- * This table maps a prefix (String) to a Stack of prefix mappings.
- * All mappings in that retrieved stack have the same prefix,
- * though possibly different URI's or depths. Such a stack must have
- * mappings at deeper depths push later on such a stack. Mappings pushed
- * earlier on the stack will have smaller values for MappingRecord.m_declarationDepth.
- */
- private Hashtable m_namespaces = new Hashtable();
-
- /**
- * The top of this stack contains the MapRecord
- * of the last declared a namespace.
- * Used to know how many prefix mappings to pop when leaving
- * the current element depth.
- * For every prefix mapping the current element depth is
- * pushed on this stack.
- * That way all prefixes pushed at the current depth can be
- * removed at the same time.
- * Used to ensure prefix/uri map scopes are closed correctly
- *
- */
- private Stack m_nodeStack = new Stack();
-
- private static final String EMPTYSTRING = "";
- private static final String XML_PREFIX = "xml"; // was "xmlns"
-
- /**
- * Default constructor
- * @see java.lang.Object#Object()
- */
- public NamespaceMappings()
- {
- initNamespaces();
- }
-
- /**
- * This method initializes the namespace object with appropriate stacks
- * and predefines a few prefix/uri pairs which always exist.
- */
- private void initNamespaces()
- {
-
-
- // Define the default namespace (initially maps to "" uri)
- Stack stack;
- m_namespaces.put(EMPTYSTRING, stack = new Stack());
- stack.push(new MappingRecord(EMPTYSTRING,EMPTYSTRING,0));
-
- m_namespaces.put(XML_PREFIX, stack = new Stack());
- stack.push(new MappingRecord( XML_PREFIX,
- "http://www.w3.org/XML/1998/namespace",0));
-
- m_nodeStack.push(new MappingRecord(null,null,-1));
-
- }
-
- /**
- * Use a namespace prefix to lookup a namespace URI.
- *
- * @param prefix String the prefix of the namespace
- * @return the URI corresponding to the prefix
- */
- public String lookupNamespace(String prefix)
- {
- final Stack stack = (Stack) m_namespaces.get(prefix);
- return stack != null && !stack.isEmpty() ?
- ((MappingRecord) stack.peek()).m_uri : null;
- }
-
- MappingRecord getMappingFromPrefix(String prefix) {
- final Stack stack = (Stack) m_namespaces.get(prefix);
- return stack != null && !stack.isEmpty() ?
- ((MappingRecord) stack.peek()) : null;
- }
-
- /**
- * Given a namespace uri, and the namespaces mappings for the
- * current element, return the current prefix for that uri.
- *
- * @param uri the namespace URI to be search for
- * @return an existing prefix that maps to the given URI, null if no prefix
- * maps to the given namespace URI.
- */
- public String lookupPrefix(String uri)
- {
- String foundPrefix = null;
- Enumeration prefixes = m_namespaces.keys();
- while (prefixes.hasMoreElements())
- {
- String prefix = (String) prefixes.nextElement();
- String uri2 = lookupNamespace(prefix);
- if (uri2 != null && uri2.equals(uri))
- {
- foundPrefix = prefix;
- break;
- }
- }
- return foundPrefix;
- }
-
- MappingRecord getMappingFromURI(String uri)
- {
- MappingRecord foundMap = null;
- Enumeration prefixes = m_namespaces.keys();
- while (prefixes.hasMoreElements())
- {
- String prefix = (String) prefixes.nextElement();
- MappingRecord map2 = getMappingFromPrefix(prefix);
- if (map2 != null && (map2.m_uri).equals(uri))
- {
- foundMap = map2;
- break;
- }
- }
- return foundMap;
- }
-
- /**
- * Undeclare the namespace that is currently pointed to by a given prefix
- */
- boolean popNamespace(String prefix)
- {
- // Prefixes "xml" and "xmlns" cannot be redefined
- if (prefix.startsWith(XML_PREFIX))
- {
- return false;
- }
-
- Stack stack;
- if ((stack = (Stack) m_namespaces.get(prefix)) != null)
- {
- if (!stack.isEmpty()) {
- stack.pop();
- }
- return true;
- }
- return false;
- }
-
- /**
- * Declare a mapping of a prefix to namespace URI at the given element depth.
- * @param prefix a String with the prefix for a qualified name
- * @param uri a String with the uri to which the prefix is to map
- * @param elemDepth the depth of current declaration
- */
- boolean pushNamespace(String prefix, String uri, int elemDepth)
- {
- // Prefixes "xml" and "xmlns" cannot be redefined
- if (prefix.startsWith(XML_PREFIX))
- {
- return false;
- }
-
- Stack stack;
- // Get the stack that contains URIs for the specified prefix
- if ((stack = (Stack) m_namespaces.get(prefix)) == null)
- {
- m_namespaces.put(prefix, stack = new Stack());
- }
-
- if (!stack.empty() && uri.equals(((MappingRecord)stack.peek()).m_uri))
- {
- return false;
- }
- MappingRecord map = new MappingRecord(prefix,uri,elemDepth);
- stack.push(map);
- m_nodeStack.push(map);
- return true;
- }
-
- /**
- * Pop, or undeclare all namespace definitions that are currently
- * declared at the given element depth, or deepter.
- * @param elemDepth the element depth for which mappings declared at this
- * depth or deeper will no longer be valid
- * @param saxHandler The ContentHandler to notify of any endPrefixMapping()
- * calls. This parameter can be null.
- */
- void popNamespaces(int elemDepth, ContentHandler saxHandler)
- {
- while (true)
- {
- if (m_nodeStack.isEmpty())
- return;
- MappingRecord map = (MappingRecord)(m_nodeStack.peek());
- int depth = map.m_declarationDepth;
- if (depth < elemDepth)
- return;
- /* the depth of the declared mapping is elemDepth or deeper
- * so get rid of it
- */
-
- map = (MappingRecord) m_nodeStack.pop();
- final String prefix = map.m_prefix;
- popNamespace(prefix);
- if (saxHandler != null)
- {
- try
- {
- saxHandler.endPrefixMapping(prefix);
- }
- catch (SAXException e)
- {
- // not much we can do if they aren't willing to listen
- }
- }
-
- }
- }
-
- /**
- * Generate a new namespace prefix ( ns0, ns1 ...) not used before
- * @return String a new namespace prefix ( ns0, ns1, ns2 ...)
- */
- public String generateNextPrefix()
- {
- return "ns" + (count++);
- }
-
-
- /**
- * This method makes a clone of this object.
- *
- */
- public Object clone() throws CloneNotSupportedException {
- NamespaceMappings clone = new NamespaceMappings();
- clone.m_nodeStack = (Stack) m_nodeStack.clone();
- clone.m_namespaces = (Hashtable) m_namespaces.clone();
-
- clone.count = count;
- return clone;
-
- }
-
- final void reset()
- {
- this.count = 0;
- this.m_namespaces.clear();
- this.m_nodeStack.clear();
- initNamespaces();
- }
-
- class MappingRecord {
- final String m_prefix; // the prefix
- final String m_uri; // the uri
- // the depth of the element where declartion was made
- final int m_declarationDepth;
- MappingRecord(String prefix, String uri, int depth) {
- m_prefix = prefix;
- m_uri = uri;
- m_declarationDepth = depth;
-
- }
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ObjectFactory.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ObjectFactory.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ObjectFactory.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,658 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ObjectFactory.java,v 1.1.2.1 2007/01/09 18:57:30 alexsmirnov Exp $
- */
-
-package org.ajax4jsf.xml.serializer;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Properties;
-
-/**
- * This class is duplicated for each JAXP subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the JAXP
- * API.
- * <p>
- * This code is designed to implement the JAXP 1.1 spec pluggability
- * feature and is designed to run on JDK version 1.1 and
- * later, and to compile on JDK 1.2 and onward.
- * The code also runs both as part of an unbundled jar file and
- * when bundled as part of the JDK.
- * <p>
- * This class was moved from the <code>javax.xml.parsers.ObjectFactory</code>
- * class and modified to be used as a general utility for creating objects
- * dynamically.
- *
- * @xsl.usage internal
- */
-class ObjectFactory {
-
- //
- // Constants
- //
-
- // name of default properties file to look for in JDK's jre/lib directory
- private static final String DEFAULT_PROPERTIES_FILENAME =
- "xalan.properties";
-
- private static final String SERVICES_PATH = "META-INF/services/";
-
- /** Set to true for debugging */
- private static final boolean DEBUG = false;
-
- /** cache the contents of the xalan.properties file.
- * Until an attempt has been made to read this file, this will
- * be null; if the file does not exist or we encounter some other error
- * during the read, this will be empty.
- */
- private static Properties fXalanProperties = null;
-
- /***
- * Cache the time stamp of the xalan.properties file so
- * that we know if it's been modified and can invalidate
- * the cache when necessary.
- */
- private static long fLastModified = -1;
-
- //
- // Public static methods
- //
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return instance of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static Object createObject(String factoryId, String fallbackClassName)
- throws ConfigurationError {
- return createObject(factoryId, null, fallbackClassName);
- } // createObject(String,String):Object
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return instance of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static Object createObject(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- throws ConfigurationError
- {
- Class factoryClass = lookUpFactoryClass(factoryId,
- propertiesFilename,
- fallbackClassName);
-
- if (factoryClass == null) {
- throw new ConfigurationError(
- "Provider for " + factoryId + " cannot be found", null);
- }
-
- try{
- Object instance = factoryClass.newInstance();
- debugPrintln("created new instance of factory " + factoryId);
- return instance;
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider for factory " + factoryId
- + " could not be instantiated: " + x, x);
- }
- } // createObject(String,String,String):Object
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object of factory, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static Class lookUpFactoryClass(String factoryId)
- throws ConfigurationError
- {
- return lookUpFactoryClass(factoryId, null, null);
- } // lookUpFactoryClass(String):Class
-
- /**
- * Finds the implementation Class object in the specified order. The
- * specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return Class object that provides factory service, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static Class lookUpFactoryClass(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- throws ConfigurationError
- {
- String factoryClassName = lookUpFactoryClassName(factoryId,
- propertiesFilename,
- fallbackClassName);
- ClassLoader cl = findClassLoader();
-
- if (factoryClassName == null) {
- factoryClassName = fallbackClassName;
- }
-
- // assert(className != null);
- try{
- Class providerClass = findProviderClass(factoryClassName,
- cl,
- true);
- debugPrintln("created new instance of " + providerClass +
- " using ClassLoader: " + cl);
- return providerClass;
- } catch (ClassNotFoundException x) {
- throw new ConfigurationError(
- "Provider " + factoryClassName + " not found", x);
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider "+factoryClassName+" could not be instantiated: "+x,
- x);
- }
- } // lookUpFactoryClass(String,String,String):Class
-
- /**
- * Finds the name of the required implementation class in the specified
- * order. The specified order is the following:
- * <ol>
- * <li>query the system property using <code>System.getProperty</code>
- * <li>read <code>$java.home/lib/<i>propertiesFilename</i></code> file
- * <li>read <code>META-INF/services/<i>factoryId</i></code> file
- * <li>use fallback classname
- * </ol>
- *
- * @return name of class that provides factory service, never null
- *
- * @param factoryId Name of the factory to find, same as
- * a property name
- * @param propertiesFilename The filename in the $java.home/lib directory
- * of the properties file. If none specified,
- * ${java.home}/lib/xalan.properties will be used.
- * @param fallbackClassName Implementation class name, if nothing else
- * is found. Use null to mean no fallback.
- *
- * @exception ObjectFactory.ConfigurationError
- */
- static String lookUpFactoryClassName(String factoryId,
- String propertiesFilename,
- String fallbackClassName)
- {
- SecuritySupport ss = SecuritySupport.getInstance();
-
- // Use the system property first
- try {
- String systemProp = ss.getSystemProperty(factoryId);
- if (systemProp != null) {
- debugPrintln("found system property, value=" + systemProp);
- return systemProp;
- }
- } catch (SecurityException se) {
- // Ignore and continue w/ next location
- }
-
- // Try to read from propertiesFilename, or
- // $java.home/lib/xalan.properties
- String factoryClassName = null;
- // no properties file name specified; use
- // $JAVA_HOME/lib/xalan.properties:
- if (propertiesFilename == null) {
- File propertiesFile = null;
- boolean propertiesFileExists = false;
- try {
- String javah = ss.getSystemProperty("java.home");
- propertiesFilename = javah + File.separator +
- "lib" + File.separator + DEFAULT_PROPERTIES_FILENAME;
- propertiesFile = new File(propertiesFilename);
- propertiesFileExists = ss.getFileExists(propertiesFile);
- } catch (SecurityException e) {
- // try again...
- fLastModified = -1;
- fXalanProperties = null;
- }
-
- synchronized (ObjectFactory.class) {
- boolean loadProperties = false;
- FileInputStream fis = null;
- try {
- // file existed last time
- if(fLastModified >= 0) {
- if(propertiesFileExists &&
- (fLastModified < (fLastModified = ss.getLastModified(propertiesFile)))) {
- loadProperties = true;
- } else {
- // file has stopped existing...
- if(!propertiesFileExists) {
- fLastModified = -1;
- fXalanProperties = null;
- } // else, file wasn't modified!
- }
- } else {
- // file has started to exist:
- if(propertiesFileExists) {
- loadProperties = true;
- fLastModified = ss.getLastModified(propertiesFile);
- } // else, nothing's changed
- }
- if(loadProperties) {
- // must never have attempted to read xalan.properties
- // before (or it's outdeated)
- fXalanProperties = new Properties();
- fis = ss.getFileInputStream(propertiesFile);
- fXalanProperties.load(fis);
- }
- } catch (Exception x) {
- fXalanProperties = null;
- fLastModified = -1;
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
- finally {
- // try to close the input stream if one was opened.
- if (fis != null) {
- try {
- fis.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
- }
- }
- if(fXalanProperties != null) {
- factoryClassName = fXalanProperties.getProperty(factoryId);
- }
- } else {
- FileInputStream fis = null;
- try {
- fis = ss.getFileInputStream(new File(propertiesFilename));
- Properties props = new Properties();
- props.load(fis);
- factoryClassName = props.getProperty(factoryId);
- } catch (Exception x) {
- // assert(x instanceof FileNotFoundException
- // || x instanceof SecurityException)
- // In both cases, ignore and continue w/ next location
- }
- finally {
- // try to close the input stream if one was opened.
- if (fis != null) {
- try {
- fis.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
- }
- }
- if (factoryClassName != null) {
- debugPrintln("found in " + propertiesFilename + ", value="
- + factoryClassName);
- return factoryClassName;
- }
-
- // Try Jar Service Provider Mechanism
- return findJarServiceProviderName(factoryId);
- } // lookUpFactoryClass(String,String):String
-
- //
- // Private static methods
- //
-
- /** Prints a message to standard error if debugging is enabled. */
- private static void debugPrintln(String msg) {
- if (DEBUG) {
- System.err.println("JAXP: " + msg);
- }
- } // debugPrintln(String)
-
- /**
- * Figure out which ClassLoader to use. For JDK 1.2 and later use
- * the context ClassLoader.
- */
- static ClassLoader findClassLoader()
- throws ConfigurationError
- {
- SecuritySupport ss = SecuritySupport.getInstance();
-
- // Figure out which ClassLoader to use for loading the provider
- // class. If there is a Context ClassLoader then use it.
- ClassLoader context = ss.getContextClassLoader();
- ClassLoader system = ss.getSystemClassLoader();
-
- ClassLoader chain = system;
- while (true) {
- if (context == chain) {
- // Assert: we are on JDK 1.1 or we have no Context ClassLoader
- // or any Context ClassLoader in chain of system classloader
- // (including extension ClassLoader) so extend to widest
- // ClassLoader (always look in system ClassLoader if Xalan
- // is in boot/extension/system classpath and in current
- // ClassLoader otherwise); normal classloaders delegate
- // back to system ClassLoader first so this widening doesn't
- // change the fact that context ClassLoader will be consulted
- ClassLoader current = ObjectFactory.class.getClassLoader();
-
- chain = system;
- while (true) {
- if (current == chain) {
- // Assert: Current ClassLoader in chain of
- // boot/extension/system ClassLoaders
- return system;
- }
- if (chain == null) {
- break;
- }
- chain = ss.getParentClassLoader(chain);
- }
-
- // Assert: Current ClassLoader not in chain of
- // boot/extension/system ClassLoaders
- return current;
- }
-
- if (chain == null) {
- // boot ClassLoader reached
- break;
- }
-
- // Check for any extension ClassLoaders in chain up to
- // boot ClassLoader
- chain = ss.getParentClassLoader(chain);
- };
-
- // Assert: Context ClassLoader not in chain of
- // boot/extension/system ClassLoaders
- return context;
- } // findClassLoader():ClassLoader
-
- /**
- * Create an instance of a class using the specified ClassLoader
- */
- static Object newInstance(String className, ClassLoader cl,
- boolean doFallback)
- throws ConfigurationError
- {
- // assert(className != null);
- try{
- Class providerClass = findProviderClass(className, cl, doFallback);
- Object instance = providerClass.newInstance();
- debugPrintln("created new instance of " + providerClass +
- " using ClassLoader: " + cl);
- return instance;
- } catch (ClassNotFoundException x) {
- throw new ConfigurationError(
- "Provider " + className + " not found", x);
- } catch (Exception x) {
- throw new ConfigurationError(
- "Provider " + className + " could not be instantiated: " + x,
- x);
- }
- }
-
- /**
- * Find a Class using the specified ClassLoader
- */
- static Class findProviderClass(String className, ClassLoader cl,
- boolean doFallback)
- throws ClassNotFoundException, ConfigurationError
- {
- //throw security exception if the calling thread is not allowed to access the
- //class. Restrict the access to the package classes as specified in java.security policy.
- SecurityManager security = System.getSecurityManager();
- try{
- if (security != null){
- final int lastDot = className.lastIndexOf(".");
- String packageName = className;
- if (lastDot != -1) packageName = className.substring(0, lastDot);
- security.checkPackageAccess(packageName);
- }
- }catch(SecurityException e){
- throw e;
- }
-
- Class providerClass;
- if (cl == null) {
- // XXX Use the bootstrap ClassLoader. There is no way to
- // load a class using the bootstrap ClassLoader that works
- // in both JDK 1.1 and Java 2. However, this should still
- // work b/c the following should be true:
- //
- // (cl == null) iff current ClassLoader == null
- //
- // Thus Class.forName(String) will use the current
- // ClassLoader which will be the bootstrap ClassLoader.
- providerClass = Class.forName(className);
- } else {
- try {
- providerClass = cl.loadClass(className);
- } catch (ClassNotFoundException x) {
- if (doFallback) {
- // Fall back to current classloader
- ClassLoader current = ObjectFactory.class.getClassLoader();
- if (current == null) {
- providerClass = Class.forName(className);
- } else if (cl != current) {
- cl = current;
- providerClass = cl.loadClass(className);
- } else {
- throw x;
- }
- } else {
- throw x;
- }
- }
- }
-
- return providerClass;
- }
-
- /**
- * Find the name of service provider using Jar Service Provider Mechanism
- *
- * @return instance of provider class if found or null
- */
- private static String findJarServiceProviderName(String factoryId)
- {
- SecuritySupport ss = SecuritySupport.getInstance();
- String serviceId = SERVICES_PATH + factoryId;
- InputStream is = null;
-
- // First try the Context ClassLoader
- ClassLoader cl = findClassLoader();
-
- is = ss.getResourceAsStream(cl, serviceId);
-
- // If no provider found then try the current ClassLoader
- if (is == null) {
- ClassLoader current = ObjectFactory.class.getClassLoader();
- if (cl != current) {
- cl = current;
- is = ss.getResourceAsStream(cl, serviceId);
- }
- }
-
- if (is == null) {
- // No provider found
- return null;
- }
-
- debugPrintln("found jar resource=" + serviceId +
- " using ClassLoader: " + cl);
-
- // Read the service provider name in UTF-8 as specified in
- // the jar spec. Unfortunately this fails in Microsoft
- // VJ++, which does not implement the UTF-8
- // encoding. Theoretically, we should simply let it fail in
- // that case, since the JVM is obviously broken if it
- // doesn't support such a basic standard. But since there
- // are still some users attempting to use VJ++ for
- // development, we have dropped in a fallback which makes a
- // second attempt using the platform's default encoding. In
- // VJ++ this is apparently ASCII, which is a subset of
- // UTF-8... and since the strings we'll be reading here are
- // also primarily limited to the 7-bit ASCII range (at
- // least, in English versions), this should work well
- // enough to keep us on the air until we're ready to
- // officially decommit from VJ++. [Edited comment from
- // jkesselm]
- BufferedReader rd;
- try {
- rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
- } catch (java.io.UnsupportedEncodingException e) {
- rd = new BufferedReader(new InputStreamReader(is));
- }
-
- String factoryClassName = null;
- try {
- // XXX Does not handle all possible input as specified by the
- // Jar Service Provider specification
- factoryClassName = rd.readLine();
- } catch (IOException x) {
- // No provider found
- return null;
- }
- finally {
- try {
- // try to close the reader.
- rd.close();
- }
- // Ignore the exception.
- catch (IOException exc) {}
- }
-
- if (factoryClassName != null &&
- ! "".equals(factoryClassName)) {
- debugPrintln("found in resource, value="
- + factoryClassName);
-
- // Note: here we do not want to fall back to the current
- // ClassLoader because we want to avoid the case where the
- // resource file was found using one ClassLoader and the
- // provider class was instantiated using a different one.
- return factoryClassName;
- }
-
- // No provider found
- return null;
- }
-
- //
- // Classes
- //
-
- /**
- * A configuration error.
- */
- static class ConfigurationError
- extends Error {
- static final long serialVersionUID = 8859254254255146542L;
- //
- // Data
- //
-
- /** Exception. */
- private Exception exception;
-
- //
- // Constructors
- //
-
- /**
- * Construct a new instance with the specified detail string and
- * exception.
- */
- ConfigurationError(String msg, Exception x) {
- super(msg);
- this.exception = x;
- } // <init>(String,Exception)
-
- //
- // Public methods
- //
-
- /** Returns the exception associated to this error. */
- Exception getException() {
- return exception;
- } // getException():Exception
-
- } // class ConfigurationError
-
-} // class ObjectFactory
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertiesFactory.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertiesFactory.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertiesFactory.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,532 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: OutputPropertiesFactory.java,v 1.1.2.1 2007/01/09 18:57:16 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Enumeration;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException;
-
-/**
- * This class is a factory to generate a set of default properties
- * of key/value pairs that are used to create a serializer through the
- * factory {@link SerializerFactory SerilizerFactory}.
- * The properties generated by this factory
- * may be modified to non-default values before the SerializerFactory is used to
- * create a Serializer.
- * <p>
- * The given output types supported are "xml", "text", and "html".
- * These type strings can be obtained from the
- * {@link Method Method} class in this package.
- * <p>
- * Other constants defined in this class are the non-standard property keys
- * that can be used to set non-standard property values on a java.util.Properties object
- * that is used to create or configure a serializer. Here are the non-standard keys:
- * <ul>
- * <li> <b>S_KEY_INDENT_AMOUNT </b> -
- * The non-standard property key to use to set the indentation amount.
- * The "indent" key needs to have a value of "yes", and this
- * properties value is a the number of whitespaces to indent by per
- * indentation level.
- *
- * <li> <b>S_KEY_CONTENT_HANDLER </b> -
- * This non-standard property key is used to set the name of the fully qualified
- * Java class that implements the ContentHandler interface.
- * The output of the serializer will be SAX events sent to this an
- * object of this class.
- *
- * <li> <b>S_KEY_ENTITIES </b> -
- * This non-standard property key is used to specify the name of the property file
- * that specifies character to entity reference mappings. A line in such a
- * file is has the name of the entity and the numeric (base 10) value
- * of the corresponding character, like this one: <br> quot=34 <br>
- *
- * <li> <b>S_USE_URL_ESCAPING </b> -
- * This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should
- * use %xx escaping.
- *
- * <li> <b>S_OMIT_META_TAG </b> -
- * This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would
- * otherwise be supplied.
- * </ul>
- *
- * @see SerializerFactory
- * @see Method
- * @see Serializer
- */
-public final class OutputPropertiesFactory
-{
- /** S_BUILTIN_EXTENSIONS_URL is a mnemonic for the XML Namespace
- *(http://xml.apache.org/xalan) predefined to signify Xalan's
- * built-in XSLT Extensions. When used in stylesheets, this is often
- * bound to the "xalan:" prefix.
- */
- private static final String
- S_BUILTIN_EXTENSIONS_URL = "http://xml.apache.org/xalan";
-
- /**
- * The old built-in extension url. It is still supported for
- * backward compatibility.
- */
- private static final String
- S_BUILTIN_OLD_EXTENSIONS_URL = "http://xml.apache.org/xslt";
-
- //************************************************************
- //* PUBLIC CONSTANTS
- //************************************************************
- /**
- * This is not a public API.
- * This is the built-in extensions namespace,
- * reexpressed in {namespaceURI} syntax
- * suitable for prepending to a localname to produce a "universal
- * name".
- */
- public static final String S_BUILTIN_EXTENSIONS_UNIVERSAL =
- "{" + S_BUILTIN_EXTENSIONS_URL + "}";
-
- // Some special Xalan keys.
-
- /**
- * The non-standard property key to use to set the
- * number of whitepaces to indent by, per indentation level,
- * if indent="yes".
- */
- public static final String S_KEY_INDENT_AMOUNT =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "indent-amount";
-
- /**
- * The non-standard property key to use to set the
- * number of whitepaces to indent by, per indentation level,
- * if indent="yes".
- */
- public static final String S_KEY_LINE_SEPARATOR =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "line-separator";
-
- /** This non-standard property key is used to set the name of the fully qualified
- * Java class that implements the ContentHandler interface.
- * Fully qualified name of class with a default constructor that
- * implements the ContentHandler interface, where the result tree events
- * will be sent to.
- */
-
- public static final String S_KEY_CONTENT_HANDLER =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "content-handler";
-
- /**
- * This non-standard property key is used to specify the name of the property file
- * that specifies character to entity reference mappings.
- */
- public static final String S_KEY_ENTITIES =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "entities";
-
- /**
- * This non-standard property key is used to set a value of "yes" if the href values for HTML serialization should
- * use %xx escaping. */
- public static final String S_USE_URL_ESCAPING =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "use-url-escaping";
-
- /**
- * This non-standard property key is used to set a value of "yes" if the META tag should be omitted where it would
- * otherwise be supplied.
- */
- public static final String S_OMIT_META_TAG =
- S_BUILTIN_EXTENSIONS_UNIVERSAL + "omit-meta-tag";
-
- /**
- * The old built-in extension namespace, this is not a public API.
- */
- public static final String S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL =
- "{" + S_BUILTIN_OLD_EXTENSIONS_URL + "}";
-
- /**
- * This is not a public API, it is only public because it is used
- * by outside of this package,
- * it is the length of the old built-in extension namespace.
- */
- public static final int S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL_LEN =
- S_BUILTIN_OLD_EXTENSIONS_UNIVERSAL.length();
-
- //************************************************************
- //* PRIVATE CONSTANTS
- //************************************************************
-
- private static final String S_XSLT_PREFIX = "xslt.output.";
- private static final int S_XSLT_PREFIX_LEN = S_XSLT_PREFIX.length();
- private static final String S_XALAN_PREFIX = "org.apache.xslt.";
- private static final int S_XALAN_PREFIX_LEN = S_XALAN_PREFIX.length();
-
- /** Synchronization object for lazy initialization of the above tables. */
- private static Integer m_synch_object = new Integer(1);
-
- /** the directory in which the various method property files are located */
- private static final String PROP_DIR = "org/ajax4jsf/xml/serializer/";
- /** property file for default XML properties */
- private static final String PROP_FILE_XML = "output_xml.properties";
- /** property file for default TEXT properties */
- private static final String PROP_FILE_TEXT = "output_text.properties";
- /** property file for default HTML properties */
- private static final String PROP_FILE_HTML = "output_html.properties";
- /** property file for default HTML properties */
- private static final String PROP_FILE_XHTML = "output_xhtml.properties";
- /** property file for default UNKNOWN (Either XML or HTML, to be determined later) properties */
- private static final String PROP_FILE_UNKNOWN = "output_unknown.properties";
-
- //************************************************************
- //* PRIVATE STATIC FIELDS
- //************************************************************
-
- /** The default properties of all output files. */
- private static Properties m_xml_properties = null;
-
- /** The default properties when method="html". */
- private static Properties m_html_properties = null;
-
-
- /** The default properties when method="xhtml". */
- private static Properties m_xhtml_properties = null;
-
- /** The default properties when method="text". */
- private static Properties m_text_properties = null;
-
- /** The properties when method="" for the "unknown" wrapper */
- private static Properties m_unknown_properties = null;
-
- private static final Class
- ACCESS_CONTROLLER_CLASS = findAccessControllerClass();
-
- private static Class findAccessControllerClass() {
- try
- {
- // This Class was introduced in JDK 1.2. With the re-architecture of
- // security mechanism ( starting in JDK 1.2 ), we have option of
- // giving privileges to certain part of code using doPrivileged block.
- // In JDK1.1.X applications won't be having security manager and if
- // there is security manager ( in applets ), code need to be signed
- // and trusted for having access to resources.
-
- return Class.forName("java.security.AccessController");
- }
- catch (Exception e)
- {
- //User may be using older JDK ( JDK <1.2 ). Allow him/her to use it.
- // But don't try to use doPrivileged
- }
-
- return null;
- }
-
- /**
- * Creates an empty OutputProperties with the property key/value defaults specified by
- * a property file. The method argument is used to construct a string of
- * the form output_[method].properties (for instance, output_html.properties).
- * The output_xml.properties file is always used as the base.
- *
- * <p>Anything other than 'text', 'xml', and 'html', will
- * use the output_xml.properties file.</p>
- *
- * @param method non-null reference to method name.
- *
- * @return Properties object that holds the defaults for the given method.
- */
- static public final Properties getDefaultMethodProperties(String method)
- {
- String fileName = null;
- Properties defaultProperties = null;
- // According to this article : Double-check locking does not work
- // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
- try
- {
- synchronized (m_synch_object)
- {
- if (null == m_xml_properties) // double check
- {
- fileName = PROP_FILE_XML;
- m_xml_properties = loadPropertiesFile(fileName, null);
- }
- }
-
- if (method.equals(Method.XML))
- {
- defaultProperties = m_xml_properties;
- }
- else if (method.equals(Method.HTML))
- {
- if (null == m_html_properties) // double check
- {
- fileName = PROP_FILE_HTML;
- m_html_properties =
- loadPropertiesFile(fileName, m_xml_properties);
- }
-
- defaultProperties = m_html_properties;
- }
- else if (method.equals(Method.XHTML))
- {
- if (null == m_xhtml_properties) // double check
- {
- fileName = PROP_FILE_XHTML;
- m_xhtml_properties =
- loadPropertiesFile(fileName, m_xml_properties);
- }
-
- defaultProperties = m_xhtml_properties;
- }
- else if (method.equals(Method.TEXT))
- {
- if (null == m_text_properties) // double check
- {
- fileName = PROP_FILE_TEXT;
- m_text_properties =
- loadPropertiesFile(fileName, m_xml_properties);
- if (null
- == m_text_properties.getProperty(OutputKeys.ENCODING))
- {
- String mimeEncoding = Encodings.getMimeEncoding(null);
- m_text_properties.put(
- OutputKeys.ENCODING,
- mimeEncoding);
- }
- }
-
- defaultProperties = m_text_properties;
- }
- else if (method.equals(org.ajax4jsf.xml.serializer.Method.UNKNOWN))
- {
- if (null == m_unknown_properties) // double check
- {
- fileName = PROP_FILE_UNKNOWN;
- m_unknown_properties =
- loadPropertiesFile(fileName, m_xml_properties);
- }
-
- defaultProperties = m_unknown_properties;
- }
- else
- {
- // TODO: Calculate res file from name.
- defaultProperties = m_xml_properties;
- }
- }
- catch (IOException ioe)
- {
- throw new WrappedRuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
- new Object[] { fileName, method }),
- ioe);
- }
- // wrap these cached defaultProperties in a new Property object just so
- // that the caller of this method can't modify the default values
- return new Properties(defaultProperties);
- }
-
- /**
- * Load the properties file from a resource stream. If a
- * key name such as "org.apache.xslt.xxx", fix up the start of
- * string to be a curly namespace. If a key name starts with
- * "xslt.output.xxx", clip off "xslt.output.". If a key name *or* a
- * key value is discovered, check for \u003a in the text, and
- * fix it up to be ":", since earlier versions of the JDK do not
- * handle the escape sequence (at least in key names).
- *
- * @param resourceName non-null reference to resource name.
- * @param defaults Default properties, which may be null.
- */
- static private Properties loadPropertiesFile(
- final String resourceName,
- Properties defaults)
- throws IOException
- {
-
- // This static method should eventually be moved to a thread-specific class
- // so that we can cache the ContextClassLoader and bottleneck all properties file
- // loading throughout Xalan.
-
- Properties props = new Properties(defaults);
-
- InputStream is = null;
- BufferedInputStream bis = null;
-
- try
- {
- if (ACCESS_CONTROLLER_CLASS != null)
- {
- is = (InputStream) AccessController
- .doPrivileged(new PrivilegedAction() {
- public Object run()
- {
- return URLToStreamHelper.urlToStreamSafe(OutputPropertiesFactory.class
- .getResource(resourceName));
- }
- });
- }
- else
- {
- // User may be using older JDK ( JDK < 1.2 )
- is = URLToStreamHelper.urlToStreamSafe(OutputPropertiesFactory.class
- .getResource(resourceName));
- }
-
- bis = new BufferedInputStream(is);
- props.load(bis);
- }
- catch (IOException ioe)
- {
- if (defaults == null)
- {
- throw ioe;
- }
- else
- {
- throw new WrappedRuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_COULD_NOT_LOAD_RESOURCE,
- new Object[] { resourceName }),
- ioe);
- //"Could not load '"+resourceName+"' (check CLASSPATH), now using just the defaults ", ioe);
- }
- }
- catch (SecurityException se)
- {
- // Repeat IOException handling for sandbox/applet case -sc
- if (defaults == null)
- {
- throw se;
- }
- else
- {
- throw new WrappedRuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_COULD_NOT_LOAD_RESOURCE,
- new Object[] { resourceName }),
- se);
- //"Could not load '"+resourceName+"' (check CLASSPATH, applet security), now using just the defaults ", se);
- }
- }
- finally
- {
- if (bis != null)
- {
- bis.close();
- }
- if (is != null)
- {
- is.close();
- }
- }
-
- // Note that we're working at the HashTable level here,
- // and not at the Properties level! This is important
- // because we don't want to modify the default properties.
- // NB: If fixupPropertyString ends up changing the property
- // name or value, we need to remove the old key and re-add
- // with the new key and value. However, then our Enumeration
- // could lose its place in the HashTable. So, we first
- // clone the HashTable and enumerate over that since the
- // clone will not change. When we migrate to Collections,
- // this code should be revisited and cleaned up to use
- // an Iterator which may (or may not) alleviate the need for
- // the clone. Many thanks to Padraig O'hIceadha
- // <padraig(a)gradient.ie> for finding this problem. Bugzilla 2000.
-
- Enumeration keys = ((Properties) props.clone()).keys();
- while (keys.hasMoreElements())
- {
- String key = (String) keys.nextElement();
- // Now check if the given key was specified as a
- // System property. If so, the system property
- // overides the default value in the propery file.
- String value = null;
- try
- {
- value = System.getProperty(key);
- }
- catch (SecurityException se)
- {
- // No-op for sandbox/applet case, leave null -sc
- }
- if (value == null)
- value = (String) props.get(key);
-
- String newKey = fixupPropertyString(key, true);
- String newValue = null;
- try
- {
- newValue = System.getProperty(newKey);
- }
- catch (SecurityException se)
- {
- // No-op for sandbox/applet case, leave null -sc
- }
- if (newValue == null)
- newValue = fixupPropertyString(value, false);
- else
- newValue = fixupPropertyString(newValue, false);
-
- if (key != newKey || value != newValue)
- {
- props.remove(key);
- props.put(newKey, newValue);
- }
-
- }
-
- return props;
- }
-
- /**
- * Fix up a string in an output properties file according to
- * the rules of {@link #loadPropertiesFile}.
- *
- * @param s non-null reference to string that may need to be fixed up.
- * @return A new string if fixup occured, otherwise the s argument.
- */
- static private String fixupPropertyString(String s, boolean doClipping)
- {
- int index;
- if (doClipping && s.startsWith(S_XSLT_PREFIX))
- {
- s = s.substring(S_XSLT_PREFIX_LEN);
- }
- if (s.startsWith(S_XALAN_PREFIX))
- {
- s =
- S_BUILTIN_EXTENSIONS_UNIVERSAL
- + s.substring(S_XALAN_PREFIX_LEN);
- }
- if ((index = s.indexOf("\\u003a")) > 0)
- {
- String temp = s.substring(index + 6);
- s = s.substring(0, index) + ":" + temp;
-
- }
- return s;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertyUtils.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertyUtils.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/OutputPropertyUtils.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,81 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: OutputPropertyUtils.java,v 1.1.2.1 2007/01/09 18:57:15 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Properties;
-
-/**
- * This class contains some static methods that act as helpers when parsing a
- * Java Property object.
- *
- * This class is not a public API.
- * It is only public because it is used outside of this package.
- *
- * @see java.util.Properties
- * @xsl.usage internal
- */
-public final class OutputPropertyUtils
-{
- /**
- * Searches for the boolean property with the specified key in the property list.
- * If the key is not found in this property list, the default property list,
- * and its defaults, recursively, are then checked. The method returns
- * <code>false</code> if the property is not found, or if the value is other
- * than "yes".
- *
- * @param key the property key.
- * @param props the list of properties that will be searched.
- * @return the value in this property list as a boolean value, or false
- * if null or not "yes".
- */
- public static boolean getBooleanProperty(String key, Properties props)
- {
-
- String s = props.getProperty(key);
-
- if (null == s || !s.equals("yes"))
- return false;
- else
- return true;
- }
-
- /**
- * Searches for the int property with the specified key in the property list.
- * If the key is not found in this property list, the default property list,
- * and its defaults, recursively, are then checked. The method returns
- * <code>false</code> if the property is not found, or if the value is other
- * than "yes".
- *
- * @param key the property key.
- * @param props the list of properties that will be searched.
- * @return the value in this property list as a int value, or 0
- * if null or not a number.
- */
- public static int getIntProperty(String key, Properties props)
- {
-
- String s = props.getProperty(key);
-
- if (null == s)
- return 0;
- else
- return Integer.parseInt(s);
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,123 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SecuritySupport.java,v 1.1.2.1 2007/01/09 18:57:20 alexsmirnov Exp $
- */
-
-package org.ajax4jsf.xml.serializer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-
-/**
- * This class is duplicated for each Xalan-Java subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the Xalan-Java
- * API.
- *
- * Base class with security related methods that work on JDK 1.1.
- */
-class SecuritySupport {
-
- /*
- * Make this of type Object so that the verifier won't try to
- * prove its type, thus possibly trying to load the SecuritySupport12
- * class.
- */
- private static final Object securitySupport;
-
- static {
- SecuritySupport ss = null;
- try {
- Class c = Class.forName("java.security.AccessController");
- // if that worked, we're on 1.2.
- /*
- // don't reference the class explicitly so it doesn't
- // get dragged in accidentally.
- c = Class.forName("javax.mail.SecuritySupport12");
- Constructor cons = c.getConstructor(new Class[] { });
- ss = (SecuritySupport)cons.newInstance(new Object[] { });
- */
- /*
- * Unfortunately, we can't load the class using reflection
- * because the class is package private. And the class has
- * to be package private so the APIs aren't exposed to other
- * code that could use them to circumvent security. Thus,
- * we accept the risk that the direct reference might fail
- * on some JDK 1.1 JVMs, even though we would never execute
- * this code in such a case. Sigh...
- */
- ss = new SecuritySupport12();
- } catch (Exception ex) {
- // ignore it
- } finally {
- if (ss == null)
- ss = new SecuritySupport();
- securitySupport = ss;
- }
- }
-
- /**
- * Return an appropriate instance of this class, depending on whether
- * we're on a JDK 1.1 or J2SE 1.2 (or later) system.
- */
- static SecuritySupport getInstance() {
- return (SecuritySupport)securitySupport;
- }
-
- ClassLoader getContextClassLoader() {
- return null;
- }
-
- ClassLoader getSystemClassLoader() {
- return null;
- }
-
- ClassLoader getParentClassLoader(ClassLoader cl) {
- return null;
- }
-
- String getSystemProperty(String propName) {
- return System.getProperty(propName);
- }
-
- FileInputStream getFileInputStream(File file)
- throws FileNotFoundException
- {
- return new FileInputStream(file);
- }
-
- InputStream getResourceAsStream(ClassLoader cl, String name) {
- InputStream ris;
- if (cl == null) {
- ris = URLToStreamHelper.urlToStreamSafe(ClassLoader.getSystemResource(name));
- } else {
- ris = URLToStreamHelper.urlToStreamSafe(cl.getResource(name));
- }
- return ris;
- }
-
- boolean getFileExists(File f) {
- return f.exists();
- }
-
- long getLastModified(File f) {
- return f.lastModified();
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport12.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport12.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SecuritySupport12.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,143 +0,0 @@
-/*
- * Copyright 2002-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SecuritySupport12.java,v 1.1.2.1 2007/01/09 18:57:18 alexsmirnov Exp $
- */
-
-package org.ajax4jsf.xml.serializer;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.PrivilegedActionException;
-import java.security.PrivilegedExceptionAction;
-
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-
-/**
- * This class is duplicated for each Xalan-Java subpackage so keep it in sync.
- * It is package private and therefore is not exposed as part of the Xalan-Java
- * API.
- *
- * Security related methods that only work on J2SE 1.2 and newer.
- */
-class SecuritySupport12 extends SecuritySupport {
-
- ClassLoader getContextClassLoader() {
- return (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- ClassLoader cl = null;
- try {
- cl = Thread.currentThread().getContextClassLoader();
- } catch (SecurityException ex) { }
- return cl;
- }
- });
- }
-
- ClassLoader getSystemClassLoader() {
- return (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- ClassLoader cl = null;
- try {
- cl = ClassLoader.getSystemClassLoader();
- } catch (SecurityException ex) {}
- return cl;
- }
- });
- }
-
- ClassLoader getParentClassLoader(final ClassLoader cl) {
- return (ClassLoader)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- ClassLoader parent = null;
- try {
- parent = cl.getParent();
- } catch (SecurityException ex) {}
-
- // eliminate loops in case of the boot
- // ClassLoader returning itself as a parent
- return (parent == cl) ? null : parent;
- }
- });
- }
-
- String getSystemProperty(final String propName) {
- return (String)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return System.getProperty(propName);
- }
- });
- }
-
- FileInputStream getFileInputStream(final File file)
- throws FileNotFoundException
- {
- try {
- return (FileInputStream)
- AccessController.doPrivileged(new PrivilegedExceptionAction() {
- public Object run() throws FileNotFoundException {
- return new FileInputStream(file);
- }
- });
- } catch (PrivilegedActionException e) {
- throw (FileNotFoundException)e.getException();
- }
- }
-
- InputStream getResourceAsStream(final ClassLoader cl,
- final String name)
- {
- return (InputStream)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- InputStream ris;
- if (cl == null) {
- ris = URLToStreamHelper.urlToStreamSafe(ClassLoader.getSystemResource(name));
- } else {
- ris = URLToStreamHelper.urlToStreamSafe(cl.getResource(name));
- }
- return ris;
- }
- });
- }
-
- boolean getFileExists(final File f) {
- return ((Boolean)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Boolean(f.exists());
- }
- })).booleanValue();
- }
-
- long getLastModified(final File f) {
- return ((Long)
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
- return new Long(f.lastModified());
- }
- })).longValue();
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializationHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializationHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializationHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,124 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializationHandler.java,v 1.1.2.1 2007/01/09 18:57:23 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-
-import javax.xml.transform.Transformer;
-
-import org.w3c.dom.Node;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.DeclHandler;
-
-/**
- * This interface is the one that a serializer implements. It is a group of
- * other interfaces, such as ExtendedContentHandler, ExtendedLexicalHandler etc.
- * In addition there are other methods, such as reset().
- *
- * This class is public only because it is used in another package,
- * it is not a public API.
- *
- * @xsl.usage internal
- */
-public interface SerializationHandler
- extends
- ExtendedContentHandler,
- ExtendedLexicalHandler,
- XSLOutputAttributes,
- DeclHandler,
- org.xml.sax.DTDHandler,
- ErrorHandler,
- DOMSerializer,
- Serializer
-{
- /**
- * Set the SAX Content handler that the serializer sends its output to. This
- * method only applies to a ToSAXHandler, not to a ToStream serializer.
- *
- * @see Serializer#asContentHandler()
- * @see ToSAXHandler
- */
- public void setContentHandler(ContentHandler ch);
-
- public void close();
-
- /**
- * Notify that the serializer should take this DOM node as input to be
- * serialized.
- *
- * @param node the DOM node to be serialized.
- * @throws IOException
- */
- public void serialize(Node node) throws IOException;
- /**
- * Turns special character escaping on/off.
- *
- * Note that characters will
- * never, even if this option is set to 'true', be escaped within
- * CDATA sections in output XML documents.
- *
- * @param escape true if escaping is to be set on.
- */
- public boolean setEscaping(boolean escape) throws SAXException;
-
- /**
- * Set the number of spaces to indent for each indentation level.
- * @param spaces the number of spaces to indent for each indentation level.
- */
- public void setIndentAmount(int spaces);
-
- /**
- * Set the transformer associated with the serializer.
- * @param transformer the transformer associated with the serializer.
- */
- public void setTransformer(Transformer transformer);
-
- /**
- * Get the transformer associated with the serializer.
- * @return Transformer the transformer associated with the serializer.
- */
- public Transformer getTransformer();
-
- /**
- * Used only by TransformerSnapshotImpl to restore the serialization
- * to a previous state.
- *
- * @param mappings NamespaceMappings
- */
- public void setNamespaceMappings(NamespaceMappings mappings);
-
- /**
- * Flush any pending events currently queued up in the serializer. This will
- * flush any input that the serializer has which it has not yet sent as
- * output.
- */
- public void flushPending() throws SAXException;
-
- /**
- * Default behavior is to expand DTD entities,
- * that is the initall default value is true.
- * @param expand true if DTD entities are to be expanded,
- * false if they are to be left as DTD entity references.
- */
- public void setDTDEntityExpansion(boolean expand);
-
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Serializer.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Serializer.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Serializer.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,220 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: Serializer.java,v 1.1.2.1 2007/01/09 18:57:28 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-
-import org.xml.sax.ContentHandler;
-
-/**
- * The Serializer interface is implemented by a serializer to enable users to:
- * <ul>
- * <li>get and set streams or writers
- * <li>configure the serializer with key/value properties
- * <li>get an org.xml.sax.ContentHandler or a DOMSerializer to provide input to
- * </ul>
- *
- * <p>
- * Here is an example using the asContentHandler() method:
- * <pre>
- * java.util.Properties props =
- * OutputPropertiesFactory.getDefaultMethodProperties(Method.TEXT);
- * Serializer ser = SerializerFactory.getSerializer(props);
- * java.io.PrintStream ostream = System.out;
- * ser.setOutputStream(ostream);
- *
- * // Provide the SAX input events
- * ContentHandler handler = ser.asContentHandler();
- * handler.startDocument();
- * char[] chars = { 'a', 'b', 'c' };
- * handler.characters(chars, 0, chars.length);
- * handler.endDocument();
- *
- * ser.reset(); // get ready to use the serializer for another document
- * // of the same output method (TEXT).
- * </pre>
- *
- * <p>
- * As an alternate to supplying a series of SAX events as input through the
- * ContentHandler interface, the input to serialize may be given as a DOM.
- * <p>
- * For example:
- * <pre>
- * org.w3c.dom.Document inputDoc;
- * org.ajax4jsf.xml.serializer.Serializer ser;
- * java.io.Writer owriter;
- *
- * java.util.Properties props =
- * OutputPropertiesFactory.getDefaultMethodProperties(Method.XML);
- * Serializer ser = SerializerFactory.getSerializer(props);
- * owriter = ...; // create a writer to serialize the document to
- * ser.setWriter( owriter );
- *
- * inputDoc = ...; // create the DOM document to be serialized
- * DOMSerializer dser = ser.asDOMSerializer(); // a DOM will be serialized
- * dser.serialize(inputDoc); // serialize the DOM, sending output to owriter
- *
- * ser.reset(); // get ready to use the serializer for another document
- * // of the same output method.
- * </pre>
- *
- * This interface is a public API.
- *
- * @see Method
- * @see OutputPropertiesFactory
- * @see SerializerFactory
- * @see DOMSerializer
- * @see ContentHandler
- *
- * @xsl.usage general
- */
-public interface Serializer {
-
- /**
- * Specifies an output stream to which the document should be
- * serialized. This method should not be called while the
- * serializer is in the process of serializing a document.
- * <p>
- * The encoding specified in the output {@link Properties} is used, or
- * if no encoding was specified, the default for the selected
- * output method.
- * <p>
- * Only one of setWriter() or setOutputStream() should be called.
- *
- * @param output The output stream
- */
- public void setOutputStream(OutputStream output);
-
- /**
- * Get the output stream where the events will be serialized to.
- *
- * @return reference to the result stream, or null if only a writer was
- * set.
- */
- public OutputStream getOutputStream();
-
- /**
- * Specifies a writer to which the document should be serialized.
- * This method should not be called while the serializer is in
- * the process of serializing a document.
- * <p>
- * The encoding specified for the output {@link Properties} must be
- * identical to the output format used with the writer.
- *
- * <p>
- * Only one of setWriter() or setOutputStream() should be called.
- *
- * @param writer The output writer stream
- */
- public void setWriter(Writer writer);
-
- /**
- * Get the character stream where the events will be serialized to.
- *
- * @return Reference to the result Writer, or null.
- */
- public Writer getWriter();
-
- /**
- * Specifies an output format for this serializer. It the
- * serializer has already been associated with an output format,
- * it will switch to the new format. This method should not be
- * called while the serializer is in the process of serializing
- * a document.
- * <p>
- * The standard property keys supported are: "method", "version", "encoding",
- * "omit-xml-declaration", "standalone", doctype-public",
- * "doctype-system", "cdata-section-elements", "indent", "media-type".
- * These property keys and their values are described in the XSLT recommendation,
- * see {@link <a href="http://www.w3.org/TR/1999/REC-xslt-19991116"> XSLT 1.0 recommendation</a>}
- * <p>
- * The non-standard property keys supported are defined in {@link OutputPropertiesFactory}.
- *
- * <p>
- * This method can be called multiple times before a document is serialized. Each
- * time it is called more, or over-riding property values, can be specified. One
- * property value that can not be changed is that of the "method" property key.
- * <p>
- * The value of the "cdata-section-elements" property key is a whitespace
- * separated list of elements. If the element is in a namespace then
- * value is passed in this format: {uri}localName
- * <p>
- * If the "cdata-section-elements" key is specified on multiple calls
- * to this method the set of elements specified in the value
- * is not replaced from one call to the
- * next, but it is cumulative across the calls.
- *
- * @param format The output format to use, as a set of key/value pairs.
- */
- public void setOutputFormat(Properties format);
-
- /**
- * Returns the output format properties for this serializer.
- *
- * @return The output format key/value pairs in use.
- */
- public Properties getOutputFormat();
-
- /**
- * Return a {@link ContentHandler} interface to provide SAX input to.
- * Through the returned object the document to be serailized,
- * as a series of SAX events, can be provided to the serialzier.
- * If the serializer does not support the {@link ContentHandler}
- * interface, it will return null.
- * <p>
- * In principle only one of asDOMSerializer() or asContentHander()
- * should be called.
- *
- * @return A {@link ContentHandler} interface into this serializer,
- * or null if the serializer is not SAX 2 capable
- * @throws IOException An I/O exception occured
- */
- public ContentHandler asContentHandler() throws IOException;
-
- /**
- * Return a {@link DOMSerializer} interface into this serializer.
- * Through the returned object the document to be serialized,
- * a DOM, can be provided to the serializer.
- * If the serializer does not support the {@link DOMSerializer}
- * interface, it should return null.
- * <p>
- * In principle only one of asDOMSerializer() or asContentHander()
- * should be called.
- *
- * @return A {@link DOMSerializer} interface into this serializer,
- * or null if the serializer is not DOM capable
- * @throws IOException An I/O exception occured
- */
- public DOMSerializer asDOMSerializer() throws IOException;
-
- /**
- * This method resets the serializer.
- * If this method returns true, the
- * serializer may be used for subsequent serialization of new
- * documents. It is possible to change the output format and
- * output stream prior to serializing, or to reuse the existing
- * output format and output stream or writer.
- *
- * @return True if serializer has been reset and can be reused
- */
- public boolean reset();
-}
-
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerBase.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerBase.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,1362 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializerBase.java,v 1.1.2.1 2007/01/09 18:57:22 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.util.Vector;
-
-import javax.xml.transform.SourceLocator;
-import javax.xml.transform.Transformer;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-
-/**
- * This class acts as a base class for the XML "serializers"
- * and the stream serializers.
- * It contains a number of common fields and methods.
- *
- * @xsl.usage internal
- */
-public abstract class SerializerBase
- implements SerializationHandler, SerializerConstants
-{
-
-
- /**
- * To fire off the end element trace event
- * @param name Name of element
- */
- protected void fireEndElem(String name)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDELEMENT,name, (Attributes)null);
- }
- }
-
- /**
- * Report the characters trace event
- * @param chars content of characters
- * @param start starting index of characters to output
- * @param length number of characters to output
- */
- protected void fireCharEvent(char[] chars, int start, int length)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CHARACTERS, chars, start,length);
- }
- }
-
- /**
- * true if we still need to call startDocumentInternal()
- */
- protected boolean m_needToCallStartDocument = true;
-
- /** True if a trailing "]]>" still needs to be written to be
- * written out. Used to merge adjacent CDATA sections
- */
- protected boolean m_cdataTagOpen = false;
-
- /**
- * All the attributes of the current element, collected from
- * startPrefixMapping() calls, or addAddtribute() calls, or
- * from the SAX attributes in a startElement() call.
- */
- protected AttributesImplSerializer m_attributes = new AttributesImplSerializer();
-
- /**
- * Tells if we're in an EntityRef event.
- */
- protected boolean m_inEntityRef = false;
-
- /** This flag is set while receiving events from the external DTD */
- protected boolean m_inExternalDTD = false;
-
- /**
- * The System ID for the doc type.
- */
- private String m_doctypeSystem;
-
- /**
- * The public ID for the doc type.
- */
- private String m_doctypePublic;
-
- /**
- * Flag to tell that we need to add the doctype decl, which we can't do
- * until the first element is encountered.
- */
- boolean m_needToOutputDocTypeDecl = true;
-
- /**
- * The character encoding. Must match the encoding used for the
- * printWriter.
- */
- private String m_encoding = null;
-
- /**
- * Tells if we should write the XML declaration.
- */
- private boolean m_shouldNotWriteXMLHeader = false;
-
- /**
- * The standalone value for the doctype.
- */
- private String m_standalone;
-
- /**
- * True if standalone was specified.
- */
- protected boolean m_standaloneWasSpecified = false;
-
- /**
- * Flag to tell if indenting (pretty-printing) is on.
- */
- protected boolean m_doIndent = false;
- /**
- * Amount to indent.
- */
- protected int m_indentAmount = 0;
-
- /**
- * Tells the XML version, for writing out to the XML decl.
- */
- private String m_version = null;
-
- /**
- * The mediatype. Not used right now.
- */
- private String m_mediatype;
-
- /**
- * The transformer that was around when this output handler was created (if
- * any).
- */
- private Transformer m_transformer;
-
- /**
- * Pairs of local names and corresponding URIs of CDATA sections. This list
- * comes from the cdata-section-elements attribute. Every second one is a
- * local name, and every other second one is the URI for the local name.
- */
- protected Vector m_cdataSectionElements = null;
-
- /**
- * Namespace support, that keeps track of currently defined
- * prefix/uri mappings. As processed elements come and go, so do
- * the associated mappings for that element.
- */
- protected NamespaceMappings m_prefixMap;
-
- /**
- * Handle for firing generate events. This interface may be implemented
- * by the referenced transformer object.
- */
- protected SerializerTrace m_tracer;
-
- protected SourceLocator m_sourceLocator;
-
-
- /**
- * The writer to send output to. This field is only used in the ToStream
- * serializers, but exists here just so that the fireStartDoc() and
- * other fire... methods can flush this writer when tracing.
- */
- protected java.io.Writer m_writer = null;
-
- /**
- * A reference to "stack frame" corresponding to
- * the current element. Such a frame is pushed at a startElement()
- * and popped at an endElement(). This frame contains information about
- * the element, such as its namespace URI.
- */
- protected ElemContext m_elemContext = new ElemContext();
-
- /**
- * A utility buffer for converting Strings passed to
- * character() methods to character arrays.
- * Reusing this buffer means not creating a new character array
- * everytime and it runs faster.
- */
- protected char[] m_charsBuff = new char[60];
-
- /**
- * A utility buffer for converting Strings passed to
- * attribute methods to character arrays.
- * Reusing this buffer means not creating a new character array
- * everytime and it runs faster.
- */
- protected char[] m_attrBuff = new char[30];
-
- /**
- * Receive notification of a comment.
- *
- * @see ExtendedLexicalHandler#comment(String)
- */
- public void comment(String data) throws SAXException
- {
- final int length = data.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length * 2 + 1];
- }
- data.getChars(0, length, m_charsBuff, 0);
- comment(m_charsBuff, 0, length);
- }
-
- /**
- * If at runtime, when the qname of the attribute is
- * known, another prefix is specified for the attribute, then we can
- * patch or hack the name with this method. For
- * a qname of the form "ns?:otherprefix:name", this function patches the
- * qname by simply ignoring "otherprefix".
- * TODO: This method is a HACK! We do not have access to the
- * XML file, it sometimes generates a NS prefix of the form "ns?" for
- * an attribute.
- */
- protected String patchName(String qname)
- {
-
-
- final int lastColon = qname.lastIndexOf(':');
-
- if (lastColon > 0) {
- final int firstColon = qname.indexOf(':');
- final String prefix = qname.substring(0, firstColon);
- final String localName = qname.substring(lastColon + 1);
-
- // If uri is "" then ignore prefix
- final String uri = m_prefixMap.lookupNamespace(prefix);
- if (uri != null && uri.length() == 0) {
- return localName;
- }
- else if (firstColon != lastColon) {
- return prefix + ':' + localName;
- }
- }
- return qname;
- }
-
- /**
- * Returns the local name of a qualified name. If the name has no prefix,
- * then it works as the identity (SAX2).
- * @param qname the qualified name
- * @return the name, but excluding any prefix and colon.
- */
- protected static String getLocalName(String qname)
- {
- final int col = qname.lastIndexOf(':');
- return (col > 0) ? qname.substring(col + 1) : qname;
- }
-
- /**
- * Receive an object for locating the origin of SAX document events.
- *
- * @param locator An object that can return the location of any SAX document
- * event.
- *
- * Receive an object for locating the origin of SAX document events.
- *
- * <p>SAX parsers are strongly encouraged (though not absolutely
- * required) to supply a locator: if it does so, it must supply
- * the locator to the application by invoking this method before
- * invoking any of the other methods in the DocumentHandler
- * interface.</p>
- *
- * <p>The locator allows the application to determine the end
- * position of any document-related event, even if the parser is
- * not reporting an error. Typically, the application will
- * use this information for reporting its own errors (such as
- * character content that does not match an application's
- * business rules). The information returned by the locator
- * is probably not sufficient for use with a search engine.</p>
- *
- * <p>Note that the locator will return correct information only
- * during the invocation of the events in this interface. The
- * application should not attempt to use it at any other time.</p>
- */
- public void setDocumentLocator(Locator locator)
- {
- return;
-
- // I don't do anything with this yet.
- }
-
- /**
- * Adds the given attribute to the set of collected attributes , but only if
- * there is a currently open element.
- *
- * An element is currently open if a startElement() notification has
- * occured but the start of the element has not yet been written to the
- * output. In the stream case this means that we have not yet been forced
- * to close the elements opening tag by another notification, such as a
- * character notification.
- *
- * @param uri the URI of the attribute
- * @param localName the local name of the attribute
- * @param rawName the qualified name of the attribute
- * @param type the type of the attribute (probably CDATA)
- * @param value the value of the attribute
- * @param XSLAttribute true if this attribute is coming from an xsl:attriute element
- * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- throws SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
- addAttributeAlways(uri, localName, rawName, type, value, XSLAttribute);
- }
-
- }
-
- /**
- * Adds the given attribute to the set of attributes, even if there is
- * no currently open element. This is useful if a SAX startPrefixMapping()
- * should need to add an attribute before the element name is seen.
- *
- * @param uri the URI of the attribute
- * @param localName the local name of the attribute
- * @param rawName the qualified name of the attribute
- * @param type the type of the attribute (probably CDATA)
- * @param value the value of the attribute
- * @param XSLAttribute true if this attribute is coming from an xsl:attribute element
- * @return true if the attribute was added,
- * false if an existing value was replaced.
- */
- public boolean addAttributeAlways(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- {
- boolean was_added;
-// final int index =
-// (localName == null || uri == null) ?
-// m_attributes.getIndex(rawName):m_attributes.getIndex(uri, localName);
- int index;
-// if (localName == null || uri == null){
-// index = m_attributes.getIndex(rawName);
-// }
-// else {
-// index = m_attributes.getIndex(uri, localName);
-// }
- if (localName == null || uri == null || uri.length() == 0)
- index = m_attributes.getIndex(rawName);
- else {
- index = m_attributes.getIndex(uri,localName);
- }
- if (index >= 0)
- {
- /* We've seen the attribute before.
- * We may have a null uri or localName, but all
- * we really want to re-set is the value anyway.
- */
- m_attributes.setValue(index,value);
- was_added = false;
- }
- else
- {
- // the attribute doesn't exist yet, create it
- m_attributes.addAttribute(uri, localName, rawName, type, value);
- was_added = true;
- }
- return was_added;
-
- }
-
-
- /**
- * Adds the given attribute to the set of collected attributes,
- * but only if there is a currently open element.
- *
- * @param name the attribute's qualified name
- * @param value the value of the attribute
- */
- public void addAttribute(String name, final String value)
- {
- if (m_elemContext.m_startTagOpen)
- {
- final String patchedName = patchName(name);
- final String localName = getLocalName(patchedName);
- final String uri = getNamespaceURI(patchedName, false);
-
- addAttributeAlways(uri,localName, patchedName, "CDATA", value, false);
- }
- }
-
- /**
- * Adds the given xsl:attribute to the set of collected attributes,
- * but only if there is a currently open element.
- *
- * @param name the attribute's qualified name (prefix:localName)
- * @param value the value of the attribute
- * @param uri the URI that the prefix of the name points to
- */
- public void addXSLAttribute(String name, final String value, final String uri)
- {
- if (m_elemContext.m_startTagOpen)
- {
- final String patchedName = patchName(name);
- final String localName = getLocalName(patchedName);
-
- addAttributeAlways(uri,localName, patchedName, "CDATA", value, true);
- }
- }
-
- /**
- * Add the given attributes to the currently collected ones. These
- * attributes are always added, regardless of whether on not an element
- * is currently open.
- * @param atts List of attributes to add to this list
- */
- public void addAttributes(Attributes atts) throws SAXException
- {
-
- int nAtts = atts.getLength();
-
- for (int i = 0; i < nAtts; i++)
- {
- String uri = atts.getURI(i);
-
- if (null == uri)
- uri = "";
-
- addAttributeAlways(
- uri,
- atts.getLocalName(i),
- atts.getQName(i),
- atts.getType(i),
- atts.getValue(i),
- false);
-
- }
- }
-
- /**
- * Return a {@link ContentHandler} interface into this serializer.
- * If the serializer does not support the {@link ContentHandler}
- * interface, it should return null.
- *
- * @return A {@link ContentHandler} interface into this serializer,
- * or null if the serializer is not SAX 2 capable
- * @throws IOException An I/O exception occured
- */
- public ContentHandler asContentHandler() throws IOException
- {
- return this;
- }
-
- /**
- * Report the end of an entity.
- *
- * @param name The name of the entity that is ending.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #startEntity
- */
- public void endEntity(String name) throws org.xml.sax.SAXException
- {
- if (name.equals("[dtd]"))
- m_inExternalDTD = false;
- m_inEntityRef = false;
-
- if (m_tracer != null)
- this.fireEndEntity(name);
- }
-
- /**
- * Flush and close the underlying java.io.Writer. This method applies to
- * ToStream serializers, not ToSAXHandler serializers.
- * @see ToStream
- */
- public void close()
- {
- // do nothing (base behavior)
- }
-
- /**
- * Initialize global variables
- */
- protected void initCDATA()
- {
- // CDATA stack
- // _cdataStack = new Stack();
- // _cdataStack.push(new Integer(-1)); // push dummy value
- }
-
- /**
- * Returns the character encoding to be used in the output document.
- * @return the character encoding to be used in the output document.
- */
- public String getEncoding()
- {
- return m_encoding;
- }
-
- /**
- * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
- * @param m_encoding the character encoding
- */
- public void setEncoding(String m_encoding)
- {
- this.m_encoding = m_encoding;
- }
-
- /**
- * Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
- * @param b true if the XML declaration is to be omitted from the output
- * document.
- */
- public void setOmitXMLDeclaration(boolean b)
- {
- this.m_shouldNotWriteXMLHeader = b;
- }
-
-
- /**
- * @return true if the XML declaration is to be omitted from the output
- * document.
- */
- public boolean getOmitXMLDeclaration()
- {
- return m_shouldNotWriteXMLHeader;
- }
-
- /**
- * Returns the previously set value of the value to be used as the public
- * identifier in the document type declaration (DTD).
- *
- *@return the public identifier to be used in the DOCTYPE declaration in the
- * output document.
- */
- public String getDoctypePublic()
- {
- return m_doctypePublic;
- }
-
- /** Set the value coming from the xsl:output doctype-public stylesheet attribute.
- * @param doctypePublic the public identifier to be used in the DOCTYPE
- * declaration in the output document.
- */
- public void setDoctypePublic(String doctypePublic)
- {
- this.m_doctypePublic = doctypePublic;
- }
-
-
- /**
- * Returns the previously set value of the value to be used
- * as the system identifier in the document type declaration (DTD).
- * @return the system identifier to be used in the DOCTYPE declaration in
- * the output document.
- *
- */
- public String getDoctypeSystem()
- {
- return m_doctypeSystem;
- }
-
- /** Set the value coming from the xsl:output doctype-system stylesheet attribute.
- * @param doctypeSystem the system identifier to be used in the DOCTYPE
- * declaration in the output document.
- */
- public void setDoctypeSystem(String doctypeSystem)
- {
- this.m_doctypeSystem = doctypeSystem;
- }
-
- /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
- * @param doctypeSystem the system identifier to be used in the DOCTYPE
- * declaration in the output document.
- * @param doctypePublic the public identifier to be used in the DOCTYPE
- * declaration in the output document.
- */
- public void setDoctype(String doctypeSystem, String doctypePublic)
- {
- this.m_doctypeSystem = doctypeSystem;
- this.m_doctypePublic = doctypePublic;
- }
-
- /**
- * Sets the value coming from the xsl:output standalone stylesheet attribute.
- * @param standalone a value of "yes" indicates that the
- * <code>standalone</code> delaration is to be included in the output
- * document. This method remembers if the value was explicitly set using
- * this method, verses if the value is the default value.
- */
- public void setStandalone(String standalone)
- {
- if (standalone != null)
- {
- m_standaloneWasSpecified = true;
- setStandaloneInternal(standalone);
- }
- }
- /**
- * Sets the XSL standalone attribute, but does not remember if this is a
- * default or explicite setting.
- * @param standalone "yes" | "no"
- */
- protected void setStandaloneInternal(String standalone)
- {
- if ("yes".equals(standalone))
- m_standalone = "yes";
- else
- m_standalone = "no";
-
- }
-
- /**
- * Gets the XSL standalone attribute
- * @return a value of "yes" if the <code>standalone</code> delaration is to
- * be included in the output document.
- * @see XSLOutputAttributes#getStandalone()
- */
- public String getStandalone()
- {
- return m_standalone;
- }
-
- /**
- * @return true if the output document should be indented to visually
- * indicate its structure.
- */
- public boolean getIndent()
- {
- return m_doIndent;
- }
- /**
- * Gets the mediatype the media-type or MIME type associated with the output
- * document.
- * @return the mediatype the media-type or MIME type associated with the
- * output document.
- */
- public String getMediaType()
- {
- return m_mediatype;
- }
-
- /**
- * Gets the version of the output format.
- * @return the version of the output format.
- */
- public String getVersion()
- {
- return m_version;
- }
-
- /**
- * Sets the value coming from the xsl:output version attribute.
- * @param version the version of the output format.
- * @see SerializationHandler#setVersion(String)
- */
- public void setVersion(String version)
- {
- m_version = version;
- }
-
- /**
- * Sets the value coming from the xsl:output media-type stylesheet attribute.
- * @param mediaType the non-null media-type or MIME type associated with the
- * output document.
- * @see javax.xml.transform.OutputKeys#MEDIA_TYPE
- * @see SerializationHandler#setMediaType(String)
- */
- public void setMediaType(String mediaType)
- {
- m_mediatype = mediaType;
- }
-
- /**
- * @return the number of spaces to indent for each indentation level.
- */
- public int getIndentAmount()
- {
- return m_indentAmount;
- }
-
- /**
- * Sets the indentation amount.
- * @param m_indentAmount The m_indentAmount to set
- */
- public void setIndentAmount(int m_indentAmount)
- {
- this.m_indentAmount = m_indentAmount;
- }
-
- /**
- * Sets the value coming from the xsl:output indent stylesheet
- * attribute.
- * @param doIndent true if the output document should be indented to
- * visually indicate its structure.
- * @see XSLOutputAttributes#setIndent(boolean)
- */
- public void setIndent(boolean doIndent)
- {
- m_doIndent = doIndent;
- }
-
- /**
- * This method is used when a prefix/uri namespace mapping
- * is indicated after the element was started with a
- * startElement() and before and endElement().
- * startPrefixMapping(prefix,uri) would be used before the
- * startElement() call.
- * @param uri the URI of the namespace
- * @param prefix the prefix associated with the given URI.
- *
- * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
- */
- public void namespaceAfterStartElement(String uri, String prefix)
- throws SAXException
- {
- // default behavior is to do nothing
- }
-
- /**
- * Return a {@link DOMSerializer} interface into this serializer. If the
- * serializer does not support the {@link DOMSerializer} interface, it should
- * return null.
- *
- * @return A {@link DOMSerializer} interface into this serializer, or null
- * if the serializer is not DOM capable
- * @throws IOException An I/O exception occured
- * @see Serializer#asDOMSerializer()
- */
- public DOMSerializer asDOMSerializer() throws IOException
- {
- return this;
- }
-
- /**
- * Push a boolean state based on if the name of the current element
- * is found in the list of qnames. A state is only pushed if
- * there were some cdata-section-names were specified.
- * <p>
- * Hidden parameters are the vector of qualified elements specified in
- * cdata-section-names attribute, and the m_cdataSectionStates stack
- * onto which whether the current element is in the list is pushed (true or
- * false). Other hidden parameters are the current elements namespaceURI,
- * localName and qName
- */
- protected boolean isCdataSection()
- {
-
- boolean b = false;
-
- if (null != m_cdataSectionElements)
- {
- if (m_elemContext.m_elementLocalName == null)
- m_elemContext.m_elementLocalName =
- getLocalName(m_elemContext.m_elementName);
- if (m_elemContext.m_elementURI == null)
- {
- String prefix = getPrefixPart(m_elemContext.m_elementName);
- if (prefix != null)
- m_elemContext.m_elementURI =
- m_prefixMap.lookupNamespace(prefix);
-
- }
-
- if ((null != m_elemContext.m_elementURI)
- && m_elemContext.m_elementURI.length() == 0)
- m_elemContext.m_elementURI = null;
-
- int nElems = m_cdataSectionElements.size();
-
- // loop through 2 at a time, as these are pairs of URI and localName
- for (int i = 0; i < nElems; i += 2)
- {
- String uri = (String) m_cdataSectionElements.elementAt(i);
- String loc = (String) m_cdataSectionElements.elementAt(i + 1);
- if (loc.equals(m_elemContext.m_elementLocalName)
- && subPartMatch(m_elemContext.m_elementURI, uri))
- {
- b = true;
-
- break;
- }
- }
- }
- return b;
- }
-
- /**
- * Tell if two strings are equal, without worry if the first string is null.
- *
- * @param p String reference, which may be null.
- * @param t String reference, which may be null.
- *
- * @return true if strings are equal.
- */
- private static final boolean subPartMatch(String p, String t)
- {
- return (p == t) || ((null != p) && (p.equals(t)));
- }
-
- /**
- * Returns the local name of a qualified name.
- * If the name has no prefix,
- * then it works as the identity (SAX2).
- *
- * @param qname a qualified name
- * @return returns the prefix of the qualified name,
- * or null if there is no prefix.
- */
- protected static final String getPrefixPart(String qname)
- {
- final int col = qname.indexOf(':');
- return (col > 0) ? qname.substring(0, col) : null;
- //return (col > 0) ? qname.substring(0,col) : "";
- }
-
- /**
- * Some users of the serializer may need the current namespace mappings
- * @return the current namespace mappings (prefix/uri)
- * @see ExtendedContentHandler#getNamespaceMappings()
- */
- public NamespaceMappings getNamespaceMappings()
- {
- return m_prefixMap;
- }
-
- /**
- * Returns the prefix currently pointing to the given URI (if any).
- * @param namespaceURI the uri of the namespace in question
- * @return a prefix pointing to the given URI (if any).
- * @see ExtendedContentHandler#getPrefix(String)
- */
- public String getPrefix(String namespaceURI)
- {
- String prefix = m_prefixMap.lookupPrefix(namespaceURI);
- return prefix;
- }
-
- /**
- * Returns the URI of an element or attribute. Note that default namespaces
- * do not apply directly to attributes.
- * @param qname a qualified name
- * @param isElement true if the qualified name is the name of
- * an element.
- * @return returns the namespace URI associated with the qualified name.
- */
- public String getNamespaceURI(String qname, boolean isElement)
- {
- String uri = EMPTYSTRING;
- int col = qname.lastIndexOf(':');
- final String prefix = (col > 0) ? qname.substring(0, col) : EMPTYSTRING;
-
- if (!EMPTYSTRING.equals(prefix) || isElement)
- {
- if (m_prefixMap != null)
- {
- uri = m_prefixMap.lookupNamespace(prefix);
- if (uri == null && !prefix.equals(XMLNS_PREFIX))
- {
- throw new RuntimeException(
- Utils.messages.createMessage(
- MsgKey.ER_NAMESPACE_PREFIX,
- new Object[] { qname.substring(0, col) } ));
- }
- }
- }
- return uri;
- }
-
- /**
- * Returns the URI of prefix (if any)
- *
- * @param prefix the prefix whose URI is searched for
- * @return the namespace URI currently associated with the
- * prefix, null if the prefix is undefined.
- */
- public String getNamespaceURIFromPrefix(String prefix)
- {
- String uri = null;
- if (m_prefixMap != null)
- uri = m_prefixMap.lookupNamespace(prefix);
- return uri;
- }
-
- /**
- * Entity reference event.
- *
- * @param name Name of entity
- *
- * @throws org.xml.sax.SAXException
- */
- public void entityReference(String name) throws org.xml.sax.SAXException
- {
-
- flushPending();
-
- startEntity(name);
- endEntity(name);
-
- if (m_tracer != null)
- fireEntityReference(name);
- }
-
- /**
- * Sets the transformer associated with this serializer
- * @param t the transformer associated with this serializer.
- * @see SerializationHandler#setTransformer(Transformer)
- */
- public void setTransformer(Transformer t)
- {
- m_transformer = t;
-
- // If this transformer object implements the SerializerTrace interface
- // then assign m_tracer to the transformer object so it can be used
- // to fire trace events.
- if ((m_transformer instanceof SerializerTrace) &&
- (((SerializerTrace) m_transformer).hasTraceListeners())) {
- m_tracer = (SerializerTrace) m_transformer;
- } else {
- m_tracer = null;
- }
- }
- /**
- * Gets the transformer associated with this serializer
- * @return returns the transformer associated with this serializer.
- * @see SerializationHandler#getTransformer()
- */
- public Transformer getTransformer()
- {
- return m_transformer;
- }
-
- /**
- * This method gets the nodes value as a String and uses that String as if
- * it were an input character notification.
- * @param node the Node to serialize
- * @throws org.xml.sax.SAXException
- */
- public void characters(org.w3c.dom.Node node)
- throws org.xml.sax.SAXException
- {
- flushPending();
- String data = node.getNodeValue();
- if (data != null)
- {
- final int length = data.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length * 2 + 1];
- }
- data.getChars(0, length, m_charsBuff, 0);
- characters(m_charsBuff, 0, length);
- }
- }
-
-
- /**
- * @see org.xml.sax.ErrorHandler#error(SAXParseException)
- */
- public void error(SAXParseException exc) throws SAXException {
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
- */
- public void fatalError(SAXParseException exc) throws SAXException {
-
- m_elemContext.m_startTagOpen = false;
-
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#warning(SAXParseException)
- */
- public void warning(SAXParseException exc) throws SAXException
- {
- }
-
- /**
- * To fire off start entity trace event
- * @param name Name of entity
- */
- protected void fireStartEntity(String name)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENTITYREF, name);
- }
- }
-
- /**
- * Report the characters event
- * @param chars content of characters
- * @param start starting index of characters to output
- * @param length number of characters to output
- */
-// protected void fireCharEvent(char[] chars, int start, int length)
-// throws org.xml.sax.SAXException
-// {
-// if (m_tracer != null)
-// m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CHARACTERS, chars, start,length);
-// }
-//
-
- /**
- * This method is only used internally when flushing the writer from the
- * various fire...() trace events. Due to the writer being wrapped with
- * SerializerTraceWriter it may cause the flush of these trace events:
- * EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS
- * EVENTTYPE_OUTPUT_CHARACTERS
- * which trace the output written to the output stream.
- *
- */
- private void flushMyWriter()
- {
- if (m_writer != null)
- {
- try
- {
- m_writer.flush();
- }
- catch(IOException ioe)
- {
-
- }
- }
- }
- /**
- * Report the CDATA trace event
- * @param chars content of CDATA
- * @param start starting index of characters to output
- * @param length number of characters to output
- */
- protected void fireCDATAEvent(char[] chars, int start, int length)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_CDATA, chars, start,length);
- }
- }
-
- /**
- * Report the comment trace event
- * @param chars content of comment
- * @param start starting index of comment to output
- * @param length number of characters to output
- */
- protected void fireCommentEvent(char[] chars, int start, int length)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_COMMENT, new String(chars, start, length));
- }
- }
-
-
- /**
- * To fire off end entity trace event
- * @param name Name of entity
- */
- public void fireEndEntity(String name)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- flushMyWriter();
- // we do not need to handle this.
- }
-
- /**
- * To fire off start document trace event
- */
- protected void fireStartDoc()
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_STARTDOCUMENT);
- }
- }
-
-
- /**
- * To fire off end document trace event
- */
- protected void fireEndDoc()
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDDOCUMENT);
- }
- }
-
- /**
- * Report the start element trace event. This trace method needs to be
- * called just before the attributes are cleared.
- *
- * @param elemName the qualified name of the element
- *
- */
- protected void fireStartElem(String elemName)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_STARTELEMENT,
- elemName, m_attributes);
- }
- }
-
-
- /**
- * To fire off the end element event
- * @param name Name of element
- */
-// protected void fireEndElem(String name)
-// throws org.xml.sax.SAXException
-// {
-// if (m_tracer != null)
-// m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENDELEMENT,name, (Attributes)null);
-// }
-
-
- /**
- * To fire off the PI trace event
- * @param name Name of PI
- */
- protected void fireEscapingEvent(String name, String data)
- throws org.xml.sax.SAXException
- {
-
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_PI,name, data);
- }
- }
-
-
- /**
- * To fire off the entity reference trace event
- * @param name Name of entity reference
- */
- protected void fireEntityReference(String name)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- {
- flushMyWriter();
- m_tracer.fireGenerateEvent(SerializerTrace.EVENTTYPE_ENTITYREF,name, (Attributes)null);
- }
- }
-
- /**
- * Receive notification of the beginning of a document.
- * This method is never a self generated call,
- * but only called externally.
- *
- * <p>The SAX parser will invoke this method only once, before any
- * other methods in this interface or in DTDHandler (except for
- * setDocumentLocator).</p>
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void startDocument() throws org.xml.sax.SAXException
- {
-
- // if we do get called with startDocument(), handle it right away
- startDocumentInternal();
- m_needToCallStartDocument = false;
- return;
- }
-
- /**
- * This method handles what needs to be done at a startDocument() call,
- * whether from an external caller, or internally called in the
- * serializer. For historical reasons the serializer is flexible to
- * startDocument() not always being called.
- * Even if no external call is
- * made into startDocument() this method will always be called as a self
- * generated internal startDocument, it handles what needs to be done at a
- * startDocument() call.
- *
- * This method exists just to make sure that startDocument() is only ever
- * called from an external caller, which in principle is just a matter of
- * style.
- *
- * @throws SAXException
- */
- protected void startDocumentInternal() throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- this.fireStartDoc();
- }
- /**
- * This method is used to set the source locator, which might be used to
- * generated an error message.
- * @param locator the source locator
- *
- * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
- */
- public void setSourceLocator(SourceLocator locator)
- {
- m_sourceLocator = locator;
- }
-
-
- /**
- * Used only by TransformerSnapshotImpl to restore the serialization
- * to a previous state.
- *
- * @param mappings NamespaceMappings
- */
- public void setNamespaceMappings(NamespaceMappings mappings) {
- m_prefixMap = mappings;
- }
-
- public boolean reset()
- {
- resetSerializerBase();
- return true;
- }
-
- /**
- * Reset all of the fields owned by SerializerBase
- *
- */
- private void resetSerializerBase()
- {
- this.m_attributes.clear();
- this.m_cdataSectionElements = null;
- this.m_elemContext = new ElemContext();
- this.m_doctypePublic = null;
- this.m_doctypeSystem = null;
- this.m_doIndent = false;
- this.m_encoding = null;
- this.m_indentAmount = 0;
- this.m_inEntityRef = false;
- this.m_inExternalDTD = false;
- this.m_mediatype = null;
- this.m_needToCallStartDocument = true;
- this.m_needToOutputDocTypeDecl = false;
- if (this.m_prefixMap != null)
- this.m_prefixMap.reset();
- this.m_shouldNotWriteXMLHeader = false;
- this.m_sourceLocator = null;
- this.m_standalone = null;
- this.m_standaloneWasSpecified = false;
- this.m_tracer = null;
- this.m_transformer = null;
- this.m_version = null;
- // don't set writer to null, so that it might be re-used
- //this.m_writer = null;
- }
-
- /**
- * Returns true if the serializer is used for temporary output rather than
- * final output.
- *
- * This concept is made clear in the XSLT 2.0 draft.
- */
- final boolean inTemporaryOutputState()
- {
- /* This is a hack. We should really be letting the serializer know
- * that it is in temporary output state with an explicit call, but
- * from a pragmatic point of view (for now anyways) having no output
- * encoding at all, not even the default UTF-8 indicates that the serializer
- * is being used for temporary RTF.
- */
- return (getEncoding() == null);
-
- }
-
- /**
- * This method adds an attribute the the current element,
- * but should not be used for an xsl:attribute child.
- * @see ExtendedContentHandler#addAttribute(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void addAttribute(String uri, String localName, String rawName, String type, String value) throws SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
- addAttributeAlways(uri, localName, rawName, type, value, false);
- }
- }
-
- /**
- * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- public void notationDecl(String arg0, String arg1, String arg2)
- throws SAXException {
- // This method just provides a definition to satisfy the interface
- // A particular sub-class of SerializerBase provides the implementation (if desired)
- }
-
- /**
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void unparsedEntityDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3)
- throws SAXException {
- // This method just provides a definition to satisfy the interface
- // A particular sub-class of SerializerBase provides the implementation (if desired)
- }
-
- /**
- * If set to false the serializer does not expand DTD entities,
- * but leaves them as is, the default value is true.
- */
- public void setDTDEntityExpansion(boolean expand) {
- // This method just provides a definition to satisfy the interface
- // A particular sub-class of SerializerBase provides the implementation (if desired)
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerConstants.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerConstants.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerConstants.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,57 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializerConstants.java,v 1.1.2.1 2007/01/09 18:57:21 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-/**
- * Constants used in serialization, such as the string "xmlns"
- * @xsl.usage internal
- */
-interface SerializerConstants
-{
-
- /** To insert ]]> in a CDATA section by ending the last CDATA section with
- * ]] and starting the next CDATA section with >
- */
- static final String CDATA_CONTINUE = "]]]]><![CDATA[>";
- /**
- * The constant "]]>"
- */
- static final String CDATA_DELIMITER_CLOSE = "]]>";
- static final String CDATA_DELIMITER_OPEN = "<![CDATA[";
-
- static final String EMPTYSTRING = "";
-
- static final String ENTITY_AMP = "&";
- static final String ENTITY_CRLF = "
";
- static final String ENTITY_GT = ">";
- static final String ENTITY_LT = "<";
- static final String ENTITY_QUOT = """;
-
- static final String XML_PREFIX = "xml";
- static final String XMLNS_PREFIX = "xmlns";
- static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";
-
- public static final String DEFAULT_SAX_SERIALIZER="org.ajax4jsf.xml.serializer.ToXMLSAXHandler";
-
- /**
- * Define the XML version.
- */
- static final String XMLVERSION11 = "1.1";
- static final String XMLVERSION10 = "1.0";
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerFactory.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerFactory.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerFactory.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,184 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializerFactory.java,v 1.1.2.1 2007/01/09 18:57:29 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Hashtable;
-import java.util.Properties;
-
-import javax.xml.transform.OutputKeys;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException;
-import org.xml.sax.ContentHandler;
-
-/**
- * This class is a public API, it is a factory for creating serializers.
- *
- * The properties object passed to the getSerializer() method should be created by
- * the OutputPropertiesFactory. Although the properties object
- * used to create a serializer does not need to be obtained
- * from OutputPropertiesFactory,
- * using this factory ensures that the default key/value properties
- * are set for the given output "method".
- *
- * <p>
- * The standard property keys supported are: "method", "version", "encoding",
- * "omit-xml-declaration", "standalone", doctype-public",
- * "doctype-system", "cdata-section-elements", "indent", "media-type".
- * These property keys and their values are described in the XSLT recommendation,
- * see {@link <a href="http://www.w3.org/TR/1999/REC-xslt-19991116"> XSLT 1.0 recommendation</a>}
- *
- * <p>
- * The value of the "cdata-section-elements" property key is a whitespace
- * separated list of elements. If the element is in a namespace then
- * value is passed in this format: {uri}localName
- *
- * <p>
- * The non-standard property keys supported are defined in {@link OutputPropertiesFactory}.
- *
- * @see OutputPropertiesFactory
- * @see Method
- * @see Serializer
- */
-public final class SerializerFactory
-{
- /**
- * This constructor is private just to prevent the creation of such an object.
- */
-
- private SerializerFactory() {
-
- }
- /**
- * Associates output methods to default output formats.
- */
- private static Hashtable m_formats = new Hashtable();
-
- /**
- * Returns a serializer for the specified output method. The output method
- * is specified by the value of the property associated with the "method" key.
- * If no implementation exists that supports the specified output method
- * an exception of some type will be thrown.
- * For a list of the output "method" key values see {@link Method}.
- *
- * @param format The output format, minimally the "method" property must be set.
- * @return A suitable serializer.
- * @throws IllegalArgumentException if method is
- * null or an appropriate serializer can't be found
- * @throws Exception if the class for the serializer is found but does not
- * implement ContentHandler.
- * @throws WrappedRuntimeException if an exception is thrown while trying to find serializer
- */
- public static Serializer getSerializer(Properties format)
- {
- Serializer ser;
-
- try
- {
- String method = format.getProperty(OutputKeys.METHOD);
-
- if (method == null) {
- String msg = Utils.messages.createMessage(
- MsgKey.ER_FACTORY_PROPERTY_MISSING,
- new Object[] { OutputKeys.METHOD});
- throw new IllegalArgumentException(msg);
- }
-
- String className =
- format.getProperty(OutputPropertiesFactory.S_KEY_CONTENT_HANDLER);
-
-
- if (null == className)
- {
- // Missing Content Handler property, load default using OutputPropertiesFactory
- Properties methodDefaults =
- OutputPropertiesFactory.getDefaultMethodProperties(method);
- className =
- methodDefaults.getProperty(OutputPropertiesFactory.S_KEY_CONTENT_HANDLER);
- if (null == className) {
- String msg = Utils.messages.createMessage(
- MsgKey.ER_FACTORY_PROPERTY_MISSING,
- new Object[] { OutputPropertiesFactory.S_KEY_CONTENT_HANDLER});
- throw new IllegalArgumentException(msg);
- }
-
- }
-
-
-
- ClassLoader loader = ObjectFactory.findClassLoader();
-
- Class cls = ObjectFactory.findProviderClass(className, loader, true);
-
- // _serializers.put(method, cls);
-
- Object obj = cls.newInstance();
-
- if (obj instanceof SerializationHandler)
- {
- // this is one of the supplied serializers
- ser = (Serializer) cls.newInstance();
- ser.setOutputFormat(format);
- }
- else
- {
- /*
- * This must be a user defined Serializer.
- * It had better implement ContentHandler.
- */
- if (obj instanceof ContentHandler)
- {
-
- /*
- * The user defined serializer defines ContentHandler,
- * but we need to wrap it with ToXMLSAXHandler which
- * will collect SAX-like events and emit true
- * SAX ContentHandler events to the users handler.
- */
- className = SerializerConstants.DEFAULT_SAX_SERIALIZER;
- cls = ObjectFactory.findProviderClass(className, loader, true);
- SerializationHandler sh =
- (SerializationHandler) cls.newInstance();
- sh.setContentHandler( (ContentHandler) obj);
- sh.setOutputFormat(format);
-
- ser = sh;
- }
- else
- {
- // user defined serializer does not implement
- // ContentHandler, ... very bad
- throw new Exception(
- Utils.messages.createMessage(
- MsgKey.ER_SERIALIZER_NOT_CONTENTHANDLER,
- new Object[] { className}));
- }
-
- }
- }
- catch (Exception e)
- {
- throw new org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException(e);
- }
-
- // If we make it to here ser is not null.
- return ser;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTrace.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTrace.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTrace.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,151 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializerTrace.java,v 1.1.2.1 2007/01/09 18:57:20 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import org.xml.sax.Attributes;
-
-/**
- * This interface defines a set of integer constants that identify trace event
- * types.
- *
- * @xsl.usage internal
- */
-
-public interface SerializerTrace {
-
- /**
- * Event type generated when a document begins.
- *
- */
- public static final int EVENTTYPE_STARTDOCUMENT = 1;
-
- /**
- * Event type generated when a document ends.
- */
- public static final int EVENTTYPE_ENDDOCUMENT = 2;
-
- /**
- * Event type generated when an element begins (after the attributes have been processed but before the children have been added).
- */
- public static final int EVENTTYPE_STARTELEMENT = 3;
-
- /**
- * Event type generated when an element ends, after it's children have been added.
- */
- public static final int EVENTTYPE_ENDELEMENT = 4;
-
- /**
- * Event type generated for character data (CDATA and Ignorable Whitespace have their own events).
- */
- public static final int EVENTTYPE_CHARACTERS = 5;
-
- /**
- * Event type generated for ignorable whitespace (I'm not sure how much this is actually called.
- */
- public static final int EVENTTYPE_IGNORABLEWHITESPACE = 6;
-
- /**
- * Event type generated for processing instructions.
- */
- public static final int EVENTTYPE_PI = 7;
-
- /**
- * Event type generated after a comment has been added.
- */
- public static final int EVENTTYPE_COMMENT = 8;
-
- /**
- * Event type generate after an entity ref is created.
- */
- public static final int EVENTTYPE_ENTITYREF = 9;
-
- /**
- * Event type generated after CDATA is generated.
- */
- public static final int EVENTTYPE_CDATA = 10;
-
- /**
- * Event type generated when characters might be written to an output stream,
- * but these characters never are. They will ultimately be written out via
- * EVENTTYPE_OUTPUT_CHARACTERS. This type is used as attributes are collected.
- * Whenever the attributes change this event type is fired. At the very end
- * however, when the attributes do not change anymore and are going to be
- * ouput to the document the real characters will be written out using the
- * EVENTTYPE_OUTPUT_CHARACTERS.
- */
- public static final int EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS = 11;
-
- /**
- * Event type generated when characters are written to an output stream.
- */
- public static final int EVENTTYPE_OUTPUT_CHARACTERS = 12;
-
-
- /**
- * Tell if trace listeners are present.
- *
- * @return True if there are trace listeners
- */
- public boolean hasTraceListeners();
-
- /**
- * Fire startDocument, endDocument events.
- *
- * @param eventType One of the EVENTTYPE_XXX constants.
- */
- public void fireGenerateEvent(int eventType);
-
- /**
- * Fire startElement, endElement events.
- *
- * @param eventType One of the EVENTTYPE_XXX constants.
- * @param name The name of the element.
- * @param atts The SAX attribute list.
- */
- public void fireGenerateEvent(int eventType, String name, Attributes atts);
-
- /**
- * Fire characters, cdata events.
- *
- * @param eventType One of the EVENTTYPE_XXX constants.
- * @param ch The char array from the SAX event.
- * @param start The start offset to be used in the char array.
- * @param length The end offset to be used in the chara array.
- */
- public void fireGenerateEvent(int eventType, char ch[], int start, int length);
-
- /**
- * Fire processingInstruction events.
- *
- * @param eventType One of the EVENTTYPE_XXX constants.
- * @param name The name of the processing instruction.
- * @param data The processing instruction data.
- */
- public void fireGenerateEvent(int eventType, String name, String data);
-
-
- /**
- * Fire comment and entity ref events.
- *
- * @param eventType One of the EVENTTYPE_XXX constants.
- * @param data The comment or entity ref data.
- */
- public void fireGenerateEvent(int eventType, String data);
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTraceWriter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTraceWriter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/SerializerTraceWriter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,339 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: SerializerTraceWriter.java,v 1.1.2.1 2007/01/09 18:57:24 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-
-/**
- * This class wraps the real writer, it only purpose is to send
- * CHARACTERTOSTREAM events to the trace listener.
- * Each method immediately sends the call to the wrapped writer unchanged, but
- * in addition it collects characters to be issued to a trace listener.
- *
- * In this way the trace
- * listener knows what characters have been written to the output Writer.
- *
- * There may still be differences in what the trace events say is going to the
- * output writer and what is really going there. These differences will be due
- * to the fact that this class is UTF-8 encoding before emiting the trace event
- * and the underlying writer may not be UTF-8 encoding. There may also be
- * encoding differences. So the main pupose of this class is to provide a
- * resonable facsimile of the true output.
- *
- * @xsl.usage internal
- */
-final class SerializerTraceWriter extends Writer implements WriterChain
-{
-
- /** The real writer to immediately write to.
- * This reference may be null, in which case nothing is written out, but
- * only the trace events are fired for output.
- */
- private final java.io.Writer m_writer;
-
- /** The tracer to send events to */
- private final SerializerTrace m_tracer;
-
- /** The size of the internal buffer, just to keep too many
- * events from being sent to the tracer
- */
- private int buf_length;
-
- /**
- * Internal buffer to collect the characters to go to the trace listener.
- *
- */
- private byte buf[];
-
- /**
- * How many bytes have been collected and still need to go to trace
- * listener.
- */
- private int count;
-
- /**
- * Creates or replaces the internal buffer, and makes sure it has a few
- * extra bytes slight overflow of the last UTF8 encoded character.
- * @param size
- */
- private void setBufferSize(int size)
- {
- buf = new byte[size + 3];
- buf_length = size;
- count = 0;
- }
-
- /**
- * Constructor.
- * If the writer passed in is null, then this SerializerTraceWriter will
- * only signal trace events of what would have been written to that writer.
- * If the writer passed in is not null then the trace events will mirror
- * what is going to that writer. In this way tools, such as a debugger, can
- * gather information on what is being written out.
- *
- * @param out the Writer to write to (possibly null)
- * @param tracer the tracer to inform that characters are being written
- */
- public SerializerTraceWriter(Writer out, SerializerTrace tracer)
- {
- m_writer = out;
- m_tracer = tracer;
- setBufferSize(1024);
- }
-
- /**
- * Flush out the collected characters by sending them to the trace
- * listener. These characters are never written to the real writer
- * (m_writer) because that has already happened with every method
- * call. This method simple informs the listener of what has already
- * happened.
- * @throws IOException
- */
- private void flushBuffer() throws IOException
- {
-
- // Just for tracing purposes
- if (count > 0)
- {
- char[] chars = new char[count];
- for(int i=0; i<count; i++)
- chars[i] = (char) buf[i];
-
- if (m_tracer != null)
- m_tracer.fireGenerateEvent(
- SerializerTrace.EVENTTYPE_OUTPUT_CHARACTERS,
- chars,
- 0,
- chars.length);
-
- count = 0;
- }
- }
-
- /**
- * Flush the internal buffer and flush the Writer
- * @see java.io.Writer#flush()
- */
- public void flush() throws java.io.IOException
- {
- // send to the real writer
- if (m_writer != null)
- m_writer.flush();
-
- // from here on just for tracing purposes
- flushBuffer();
- }
-
- /**
- * Flush the internal buffer and close the Writer
- * @see java.io.Writer#close()
- */
- public void close() throws java.io.IOException
- {
- // send to the real writer
- if (m_writer != null)
- m_writer.close();
-
- // from here on just for tracing purposes
- flushBuffer();
- }
-
-
- /**
- * Write a single character. The character to be written is contained in
- * the 16 low-order bits of the given integer value; the 16 high-order bits
- * are ignored.
- *
- * <p> Subclasses that intend to support efficient single-character output
- * should override this method.
- *
- * @param c int specifying a character to be written.
- * @exception IOException If an I/O error occurs
- */
- public void write(final int c) throws IOException
- {
- // send to the real writer
- if (m_writer != null)
- m_writer.write(c);
-
- // ---------- from here on just collect for tracing purposes
-
- /* If we are close to the end of the buffer then flush it.
- * Remember the buffer can hold a few more characters than buf_length
- */
- if (count >= buf_length)
- flushBuffer();
-
- if (c < 0x80)
- {
- buf[count++] = (byte) (c);
- }
- else if (c < 0x800)
- {
- buf[count++] = (byte) (0xc0 + (c >> 6));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- else
- {
- buf[count++] = (byte) (0xe0 + (c >> 12));
- buf[count++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- }
-
- /**
- * Write a portion of an array of characters.
- *
- * @param chars Array of characters
- * @param start Offset from which to start writing characters
- * @param length Number of characters to write
- *
- * @exception IOException If an I/O error occurs
- *
- * @throws java.io.IOException
- */
- public void write(final char chars[], final int start, final int length)
- throws java.io.IOException
- {
- // send to the real writer
- if (m_writer != null)
- m_writer.write(chars, start, length);
-
- // from here on just collect for tracing purposes
- int lengthx3 = (length << 1) + length;
-
- if (lengthx3 >= buf_length)
- {
-
- /* If the request length exceeds the size of the output buffer,
- * flush the output buffer and make the buffer bigger to handle.
- */
-
- flushBuffer();
- setBufferSize(2 * lengthx3);
-
- }
-
- if (lengthx3 > buf_length - count)
- {
- flushBuffer();
- }
-
- final int n = length + start;
- for (int i = start; i < n; i++)
- {
- final char c = chars[i];
-
- if (c < 0x80)
- buf[count++] = (byte) (c);
- else if (c < 0x800)
- {
- buf[count++] = (byte) (0xc0 + (c >> 6));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- else
- {
- buf[count++] = (byte) (0xe0 + (c >> 12));
- buf[count++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- }
-
- }
-
- /**
- * Write a string.
- *
- * @param s String to be written
- *
- * @exception IOException If an I/O error occurs
- */
- public void write(final String s) throws IOException
- {
- // send to the real writer
- if (m_writer != null)
- m_writer.write(s);
-
- // from here on just collect for tracing purposes
- final int length = s.length();
-
- // We multiply the length by three since this is the maximum length
- // of the characters that we can put into the buffer. It is possible
- // for each Unicode character to expand to three bytes.
-
- int lengthx3 = (length << 1) + length;
-
- if (lengthx3 >= buf_length)
- {
-
- /* If the request length exceeds the size of the output buffer,
- * flush the output buffer and make the buffer bigger to handle.
- */
-
- flushBuffer();
- setBufferSize(2 * lengthx3);
- }
-
- if (lengthx3 > buf_length - count)
- {
- flushBuffer();
- }
-
- for (int i = 0; i < length; i++)
- {
- final char c = s.charAt(i);
-
- if (c < 0x80)
- buf[count++] = (byte) (c);
- else if (c < 0x800)
- {
- buf[count++] = (byte) (0xc0 + (c >> 6));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- else
- {
- buf[count++] = (byte) (0xe0 + (c >> 12));
- buf[count++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- buf[count++] = (byte) (0x80 + (c & 0x3f));
- }
- }
- }
-
- /**
- * Get the writer that this one directly wraps.
- */
- public Writer getWriter()
- {
- return m_writer;
- }
-
- /**
- * Get the OutputStream that is the at the end of the
- * chain of writers.
- */
- public OutputStream getOutputStream()
- {
- OutputStream retval = null;
- if (m_writer instanceof WriterChain)
- retval = ((WriterChain) m_writer).getOutputStream();
- return retval;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLSAXHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLSAXHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLSAXHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,743 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToHTMLSAXHandler.java,v 1.1.2.1 2007/01/09 18:57:22 alexsmirnov Exp $
- */
-
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-
-import javax.xml.transform.Result;
-
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class accepts SAX-like calls, then sends true SAX calls to a
- * wrapped SAX handler. There is optimization done knowing that the ultimate
- * output is HTML.
- *
- * This class is not a public API.
- *
- * @xsl.usage internal
- */
-public final class ToHTMLSAXHandler extends ToSAXHandler
-{
- /**
- * Handle document type declaration (for first element only)
- */
- private boolean m_dtdHandled = false;
-
- /**
- * Keeps track of whether output escaping is currently enabled
- */
- protected boolean m_escapeSetting = false;
-
- /**
- * Returns null.
- * @return null
- * @see Serializer#getOutputFormat()
- */
- public Properties getOutputFormat()
- {
- return null;
- }
-
- /**
- * Reurns null
- * @return null
- * @see Serializer#getOutputStream()
- */
- public OutputStream getOutputStream()
- {
- return null;
- }
-
- /**
- * Returns null
- * @return null
- * @see Serializer#getWriter()
- */
- public Writer getWriter()
- {
- return null;
- }
-
- /**
- * Does nothing.
- *
- */
- public void indent(int n) throws SAXException
- {
- }
-
- /**
- * Does nothing.
- * @see DOMSerializer#serialize(Node)
- */
- public void serialize(Node node) throws IOException
- {
- return;
- }
-
- /**
- * Turns special character escaping on/off.
- *
- *
- * @param escape true if escaping is to be set on.
- *
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape) throws SAXException
- {
- boolean oldEscapeSetting = m_escapeSetting;
- m_escapeSetting = escape;
-
- if (escape) {
- processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, "");
- } else {
- processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
- }
-
- return oldEscapeSetting;
- }
-
- /**
- * Does nothing
- * @param indent the number of spaces to indent per indentation level
- * (ignored)
- * @see SerializationHandler#setIndent(boolean)
- */
- public void setIndent(boolean indent)
- {
- }
-
- /**
- * Does nothing.
- * @param format this parameter is not used
- * @see Serializer#setOutputFormat(Properties)
- */
- public void setOutputFormat(Properties format)
- {
- }
-
- /**
- * Does nothing.
- * @param output this parameter is ignored
- * @see Serializer#setOutputStream(OutputStream)
- */
- public void setOutputStream(OutputStream output)
- {
- }
-
-
- /**
- * Does nothing.
- * @param writer this parameter is ignored.
- * @see Serializer#setWriter(Writer)
- */
- public void setWriter(Writer writer)
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
- */
- /**
- * Does nothing.
- *
- * @param eName this parameter is ignored
- * @param aName this parameter is ignored
- * @param type this parameter is ignored
- * @param valueDefault this parameter is ignored
- * @param value this parameter is ignored
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String,String,String)
- */
- public void attributeDecl(
- String eName,
- String aName,
- String type,
- String valueDefault,
- String value)
- throws SAXException
- {
- }
-
-
- /**
- * Does nothing.
- * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
- */
- public void elementDecl(String name, String model) throws SAXException
- {
- return;
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
- */
- public void externalEntityDecl(String arg0, String arg1, String arg2)
- throws SAXException
- {
- }
-
- /**
- * Does nothing.
- *
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl
- */
- public void internalEntityDecl(String name, String value)
- throws SAXException
- {
- }
-
- /**
- * Receive notification of the end of an element.
- *
- * <p>The SAX parser will invoke this method at the end of every
- * element in the XML document; there will be a corresponding
- * startElement() event for every endElement() event (even when the
- * element is empty).</p>
- *
- * <p>If the element name has a namespace prefix, the prefix will
- * still be attached to the name.</p>
- *
- *
- * @param uri The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param qName The qualified name (with prefix), or the
- * empty string if qualified names are not available.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see org.xml.sax.ContentHandler#endElement(String, String, String)
- */
- public void endElement(String uri, String localName, String qName)
- throws SAXException
- {
- flushPending();
- m_saxHandler.endElement(uri, localName, qName);
-
- // time to fire off endElement event
- if (m_tracer != null)
- super.fireEndElem(qName);
- }
-
- /**
- * Does nothing.
- */
- public void endPrefixMapping(String prefix) throws SAXException
- {
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException
- {
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * <p>The Parser will invoke this method once for each processing
- * instruction found: note that processing instructions may occur
- * before or after the main document element.</p>
- *
- * <p>A SAX parser should never report an XML declaration (XML 1.0,
- * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
- * using this method.</p>
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if
- * none was supplied.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
- */
- public void processingInstruction(String target, String data)
- throws SAXException
- {
- flushPending();
- m_saxHandler.processingInstruction(target,data);
-
- // time to fire off processing instruction event
-
- if (m_tracer != null)
- super.fireEscapingEvent(target,data);
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
- */
- public void setDocumentLocator(Locator arg0)
- {
- // do nothing
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ContentHandler#skippedEntity(String)
- */
- public void skippedEntity(String arg0) throws SAXException
- {
- }
-
- /**
- * Receive notification of the beginning of an element, although this is a
- * SAX method additional namespace or attribute information can occur before
- * or after this call, that is associated with this element.
- *
- *
- * @param namespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param qName The elements name.
- * @param atts The attributes attached to the element, if any.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see org.xml.sax.ContentHandler#startElement
- * @see org.xml.sax.ContentHandler#endElement
- * @see org.xml.sax.AttributeList
- *
- * @throws org.xml.sax.SAXException
- *
- * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String qName,
- Attributes atts)
- throws SAXException
- {
- flushPending();
- super.startElement(namespaceURI, localName, qName, atts);
- m_saxHandler.startElement(namespaceURI, localName, qName, atts);
- m_elemContext.m_startTagOpen = false;
- }
-
- /**
- * Receive notification of a comment anywhere in the document. This callback
- * will be used for comments inside or outside the document element.
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param length The number of characters to use from the array.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- *
- * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
- */
- public void comment(char[] ch, int start, int length) throws SAXException
- {
- flushPending();
- if (m_lexHandler != null)
- m_lexHandler.comment(ch, start, length);
-
- // time to fire off comment event
- if (m_tracer != null)
- super.fireCommentEvent(ch, start, length);
- return;
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
- return;
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ext.LexicalHandler#endDTD()
- */
- public void endDTD() throws SAXException
- {
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ext.LexicalHandler#startCDATA()
- */
- public void startCDATA() throws SAXException
- {
- }
-
- /**
- * Does nothing.
- * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
- */
- public void startEntity(String arg0) throws SAXException
- {
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * <p>The SAX parser will invoke this method only once, and it will
- * be the last method invoked during the parse. The parser shall
- * not invoke this method until it has either abandoned parsing
- * (because of an unrecoverable error) or reached the end of
- * input.</p>
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- *
- *
- */
- public void endDocument() throws SAXException
- {
- flushPending();
-
- // Close output document
- m_saxHandler.endDocument();
-
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * This method is called when all the data needed for a call to the
- * SAX handler's startElement() method has been gathered.
- */
- protected void closeStartTag() throws SAXException
- {
-
- m_elemContext.m_startTagOpen = false;
-
- // Now is time to send the startElement event
- m_saxHandler.startElement(
- EMPTYSTRING,
- m_elemContext.m_elementName,
- m_elemContext.m_elementName,
- m_attributes);
- m_attributes.clear();
-
- }
-
- /**
- * Do nothing.
- * @see SerializationHandler#close()
- */
- public void close()
- {
- return;
- }
-
- /**
- * Receive notification of character data.
- *
- * @param chars The string of characters to process.
- *
- * @throws org.xml.sax.SAXException
- *
- * @see ExtendedContentHandler#characters(String)
- */
- public void characters(final String chars) throws SAXException
- {
- final int length = chars.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length * 2 + 1];
- }
- chars.getChars(0, length, m_charsBuff, 0);
- this.characters(m_charsBuff, 0, length);
- }
-
-
- /**
- * A constructor
- * @param handler the wrapped SAX content handler
- * @param encoding the encoding of the output HTML document
- */
- public ToHTMLSAXHandler(ContentHandler handler, String encoding)
- {
- super(handler,encoding);
- }
- /**
- * A constructor.
- * @param handler the wrapped SAX content handler
- * @param lex the wrapped lexical handler
- * @param encoding the encoding of the output HTML document
- */
- public ToHTMLSAXHandler(
- ContentHandler handler,
- LexicalHandler lex,
- String encoding)
- {
- super(handler,lex,encoding);
- }
-
- /**
- * An element starts, but attributes are not fully known yet.
- *
- * @param elementNamespaceURI the URI of the namespace of the element
- * (optional)
- * @param elementLocalName the element name, but without prefix
- * (optional)
- * @param elementName the element name, with prefix, if any (required)
- *
- * @see ExtendedContentHandler#startElement(String)
- */
- public void startElement(
- String elementNamespaceURI,
- String elementLocalName,
- String elementName) throws SAXException
- {
-
- super.startElement(elementNamespaceURI, elementLocalName, elementName);
-
- flushPending();
-
- // Handle document type declaration (for first element only)
- if (!m_dtdHandled)
- {
- String doctypeSystem = getDoctypeSystem();
- String doctypePublic = getDoctypePublic();
- if ((doctypeSystem != null) || (doctypePublic != null)) {
- if (m_lexHandler != null)
- m_lexHandler.startDTD(
- elementName,
- doctypePublic,
- doctypeSystem);
- }
- m_dtdHandled = true;
- }
- m_elemContext = m_elemContext.push(elementNamespaceURI, elementLocalName, elementName);
- }
- /**
- * An element starts, but attributes are not fully known yet.
- *
- * @param elementName the element name, with prefix, if any
- *
- * @see ExtendedContentHandler#startElement(String)
- */
- public void startElement(String elementName) throws SAXException
- {
- this.startElement(null,null, elementName);
- }
-
- /**
- * Receive notification of the end of an element.
- * @param elementName The element type name
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elementName) throws SAXException
- {
- flushPending();
- m_saxHandler.endElement(EMPTYSTRING, elementName, elementName);
-
- // time to fire off endElement event
- if (m_tracer != null)
- super.fireEndElem(elementName);
- }
-
- /**
- * Receive notification of character data.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param off The start position in the array.
- * @param len The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- *
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] ch, int off, int len) throws SAXException
- {
-
- flushPending();
- m_saxHandler.characters(ch, off, len);
-
- // time to fire off characters event
- if (m_tracer != null)
- super.fireCharEvent(ch, off, len);
- }
-
- /**
- * This method flushes any pending events, which can be startDocument()
- * closing the opening tag of an element, or closing an open CDATA section.
- */
- public void flushPending() throws SAXException
- {
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
- // Close any open element
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- }
- /**
- * Handle a prefix/uri mapping, which is associated with a startElement()
- * that is soon to follow. Need to close any open start tag to make
- * sure than any name space attributes due to this event are associated wih
- * the up comming element, not the current one.
- * @see ExtendedContentHandler#startPrefixMapping
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- * @param shouldFlush true if any open tags need to be closed first, this
- * will impact which element the mapping applies to (open parent, or its up
- * comming child)
- * @return returns true if the call made a change to the current
- * namespace information, false if it did not change anything, e.g. if the
- * prefix/namespace mapping was already in scope from before.
- *
- * @throws org.xml.sax.SAXException The client may throw
- * an exception during processing.
- */
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws SAXException
- {
- // no namespace support for HTML
- if (shouldFlush)
- flushPending();
- m_saxHandler.startPrefixMapping(prefix,uri);
- return false;
- }
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping
- * just before another element is about to start.
- * This call will close any open tags so that the prefix mapping
- * will not apply to the current element, but the up comming child.
- *
- * @see org.xml.sax.ContentHandler#startPrefixMapping
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- *
- * @throws org.xml.sax.SAXException The client may throw
- * an exception during processing.
- *
- */
- public void startPrefixMapping(String prefix, String uri)
- throws org.xml.sax.SAXException
- {
- startPrefixMapping(prefix,uri,true);
- }
-
- /**
- * This method is used when a prefix/uri namespace mapping
- * is indicated after the element was started with a
- * startElement() and before and endElement().
- * startPrefixMapping(prefix,uri) would be used before the
- * startElement() call.
- * @param prefix the prefix associated with the given URI.
- * @param uri the URI of the namespace
- *
- * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
- */
- public void namespaceAfterStartElement(
- final String prefix,
- final String uri)
- throws SAXException
- {
- // hack for XSLTC with finding URI for default namespace
- if (m_elemContext.m_elementURI == null)
- {
- String prefix1 = getPrefixPart(m_elemContext.m_elementName);
- if (prefix1 == null && EMPTYSTRING.equals(prefix))
- {
- // the elements URI is not known yet, and it
- // doesn't have a prefix, and we are currently
- // setting the uri for prefix "", so we have
- // the uri for the element... lets remember it
- m_elemContext.m_elementURI = uri;
- }
- }
- startPrefixMapping(prefix,uri,false);
- }
-
- /**
- * Try's to reset the super class and reset this class for
- * re-use, so that you don't need to create a new serializer
- * (mostly for performance reasons).
- *
- * @return true if the class was successfuly reset.
- * @see Serializer#reset()
- */
- public boolean reset()
- {
- boolean wasReset = false;
- if (super.reset())
- {
- resetToHTMLSAXHandler();
- wasReset = true;
- }
- return wasReset;
- }
-
- /**
- * Reset all of the fields owned by ToHTMLSAXHandler class
- *
- */
- private void resetToHTMLSAXHandler()
- {
- this.m_escapeSetting = false;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToHTMLStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,2305 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToHTMLStream.java,v 1.1.2.1 2007/01/09 18:57:14 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Properties;
-
-import javax.xml.transform.Result;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-import static org.ajax4jsf.xml.serializer.ToXHTMLStream.*;
-
-/**
- * This serializer takes a series of SAX or
- * SAX-like events and writes its output
- * to the given stream.
- *
- * This class is not a public API, it is public
- * because it is used from another package.
- *
- * @xsl.usage internal
- */
-public final class ToHTMLStream extends ToStream
-{
-
- /** This flag is set while receiving events from the DTD */
- protected boolean m_inDTD = false;
-
- /** True if the current element is a block element. (seems like
- * this needs to be a stack. -sb). */
- private boolean m_inBlockElem = false;
-
- /**
- * Map that tells which XML characters should have special treatment, and it
- * provides character to entity name lookup.
- */
- private static final CharInfo m_htmlcharInfo =
-// new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
- CharInfo.getCharInfo(CharInfo.HTML_ENTITIES_RESOURCE, Method.HTML);
-
- /** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
- static final Trie m_elementFlags = new Trie();
-
- static {
- initTagReference(m_elementFlags);
- }
- static void initTagReference(Trie m_elementFlags) {
-
- // HTML 4.0 loose DTD
- m_elementFlags.put("BASEFONT", new ElemDesc(0 | ElemDesc.EMPTY));
- m_elementFlags.put(
- "FRAME",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put("FRAMESET", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("NOFRAMES", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "ISINDEX",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "APPLET",
- new ElemDesc(0 | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put("CENTER", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("DIR", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("MENU", new ElemDesc(0 | ElemDesc.BLOCK));
-
- // HTML 4.0 strict DTD
- m_elementFlags.put("TT", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("I", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("B", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("BIG", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("SMALL", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("EM", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("STRONG", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("DFN", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("CODE", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("SAMP", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("KBD", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("VAR", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("CITE", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("ABBR", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("ACRONYM", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put(
- "SUP",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "SUB",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "SPAN",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BDO",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BR",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.EMPTY
- | ElemDesc.BLOCK));
- m_elementFlags.put("BODY", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "ADDRESS",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put(
- "DIV",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("A", new ElemDesc(0 | ElemDesc.SPECIAL));
- m_elementFlags.put(
- "MAP",
- new ElemDesc(
- 0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL | ElemDesc.BLOCK));
- m_elementFlags.put(
- "AREA",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "LINK",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "IMG",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.EMPTY
- | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put(
- "OBJECT",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.HEADMISC
- | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put("PARAM", new ElemDesc(0 | ElemDesc.EMPTY));
- m_elementFlags.put(
- "HR",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET
- | ElemDesc.EMPTY));
- m_elementFlags.put(
- "P",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put(
- "H1",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H2",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H3",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H4",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H5",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H6",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "PRE",
- new ElemDesc(0 | ElemDesc.PREFORMATTED | ElemDesc.BLOCK));
- m_elementFlags.put(
- "Q",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BLOCKQUOTE",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("INS", new ElemDesc(0));
- m_elementFlags.put("DEL", new ElemDesc(0));
- m_elementFlags.put(
- "DL",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("DT", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("DD", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "OL",
- new ElemDesc(0 | ElemDesc.LIST | ElemDesc.BLOCK));
- m_elementFlags.put(
- "UL",
- new ElemDesc(0 | ElemDesc.LIST | ElemDesc.BLOCK));
- m_elementFlags.put("LI", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("FORM", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("LABEL", new ElemDesc(0 | ElemDesc.FORMCTRL));
- m_elementFlags.put(
- "INPUT",
- new ElemDesc(
- 0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL | ElemDesc.EMPTY));
- m_elementFlags.put(
- "SELECT",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put("OPTGROUP", new ElemDesc(0));
- m_elementFlags.put("OPTION", new ElemDesc(0));
- m_elementFlags.put(
- "TEXTAREA",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put(
- "FIELDSET",
- new ElemDesc(0 | ElemDesc.BLOCK | ElemDesc.BLOCKFORM));
- m_elementFlags.put("LEGEND", new ElemDesc(0));
- m_elementFlags.put(
- "BUTTON",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put(
- "TABLE",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("CAPTION", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("THEAD", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TFOOT", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TBODY", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("COLGROUP", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "COL",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put("TR", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TH", new ElemDesc(0));
- m_elementFlags.put("TD", new ElemDesc(0));
- m_elementFlags.put(
- "HEAD",
- new ElemDesc(0 | ElemDesc.BLOCK | ElemDesc.HEADELEM));
- m_elementFlags.put("TITLE", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "BASE",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "META",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "STYLE",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC | ElemDesc.RAW | ElemDesc.BLOCK));
- m_elementFlags.put(
- "SCRIPT",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.HEADMISC
- | ElemDesc.RAW));
- m_elementFlags.put(
- "NOSCRIPT",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("HTML", new ElemDesc(0 | ElemDesc.BLOCK));
-
- // From "John Ky" <hand(a)syd.speednet.com.au
- // Transitional Document Type Definition ()
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/sgml/loosedtd.html#basefont
- m_elementFlags.put("FONT", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/present/graphics.html#edef-STRIKE
- m_elementFlags.put("S", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("STRIKE", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/present/graphics.html#edef-U
- m_elementFlags.put("U", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // From "John Ky" <hand(a)syd.speednet.com.au
- m_elementFlags.put("NOBR", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // HTML 4.0, section 16.5
- m_elementFlags.put(
- "IFRAME",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
-
- // Netscape 4 extension
- m_elementFlags.put(
- "LAYER",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- // Netscape 4 extension
- m_elementFlags.put(
- "ILAYER",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
-
-
- // NOW FOR ATTRIBUTE INFORMATION . . .
- ElemDesc elemDesc;
-
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("A");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
- elemDesc.setAttr("NAME", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("AREA");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
- elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BASE");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BUTTON");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BLOCKQUOTE");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DEL");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DIR");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
-
- elemDesc = (ElemDesc) m_elementFlags.get("DIV");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("FORM");
- elemDesc.setAttr("ACTION", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Attribution to: "Voytenko, Dimitry" <DVoytenko(a)SECTORBASE.COM>
- elemDesc = (ElemDesc) m_elementFlags.get("FRAME");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
- elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("HEAD");
- elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("HR");
- elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- // HTML 4.0, section 16.5
- elemDesc = (ElemDesc) m_elementFlags.get("IFRAME");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Netscape 4 extension
- elemDesc = (ElemDesc) m_elementFlags.get("ILAYER");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("IMG");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("INPUT");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("INS");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Netscape 4 extension
- elemDesc = (ElemDesc) m_elementFlags.get("LAYER");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("LINK");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("MENU");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OBJECT");
- elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL);
- elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL);
- elemDesc.setAttr("DATA", ElemDesc.ATTRURL);
- elemDesc.setAttr("ARCHIVE", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OPTGROUP");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OPTION");
- elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("Q");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("SCRIPT");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("FOR", ElemDesc.ATTRURL);
- elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("SELECT");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TABLE");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TD");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TEXTAREA");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TH");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- // The nowrap attribute of a tr element is both
- // a Netscape and Internet-Explorer extension
- elemDesc = (ElemDesc) m_elementFlags.get("TR");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("UL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
- }
-
- /**
- * Dummy element for elements not found.
- */
- static private final ElemDesc m_dummy = new ElemDesc(0 | ElemDesc.BLOCK);
-
- /** True if URLs should be specially escaped with the %xx form. */
- private boolean m_specialEscapeURLs = true;
-
- /** True if the META tag should be omitted. */
- private boolean m_omitMetaTag = false;
-
- /**
- * Tells if the formatter should use special URL escaping.
- *
- * @param bool True if URLs should be specially escaped with the %xx form.
- */
- public void setSpecialEscapeURLs(boolean bool)
- {
- m_specialEscapeURLs = bool;
- }
-
- /**
- * Tells if the formatter should omit the META tag.
- *
- * @param bool True if the META tag should be omitted.
- */
- public void setOmitMetaTag(boolean bool)
- {
- m_omitMetaTag = bool;
- }
-
- /**
- * Specifies an output format for this serializer. It the
- * serializer has already been associated with an output format,
- * it will switch to the new format. This method should not be
- * called while the serializer is in the process of serializing
- * a document.
- *
- * This method can be called multiple times before starting
- * the serialization of a particular result-tree. In principle
- * all serialization parameters can be changed, with the exception
- * of method="html" (it must be method="html" otherwise we
- * shouldn't even have a ToHTMLStream object here!)
- *
- * @param format The output format or serialzation parameters
- * to use.
- */
- public void setOutputFormat(Properties format)
- {
-
- m_specialEscapeURLs =
- OutputPropertyUtils.getBooleanProperty(
- OutputPropertiesFactory.S_USE_URL_ESCAPING,
- format);
-
- m_omitMetaTag =
- OutputPropertyUtils.getBooleanProperty(
- OutputPropertiesFactory.S_OMIT_META_TAG,
- format);
-
- super.setOutputFormat(format);
- }
-
- /**
- * Tells if the formatter should use special URL escaping.
- *
- * @return True if URLs should be specially escaped with the %xx form.
- */
- private final boolean getSpecialEscapeURLs()
- {
- return m_specialEscapeURLs;
- }
-
- /**
- * Tells if the formatter should omit the META tag.
- *
- * @return True if the META tag should be omitted.
- */
- private final boolean getOmitMetaTag()
- {
- return m_omitMetaTag;
- }
-
- /**
- * Get a description of the given element.
- *
- * @param name non-null name of element, case insensitive.
- *
- * @return non-null reference to ElemDesc, which may be m_dummy if no
- * element description matches the given name.
- */
- public static final ElemDesc getElemDesc(String name)
- {
- /* this method used to return m_dummy when name was null
- * but now it doesn't check and and requires non-null name.
- */
- Object obj = m_elementFlags.get(name);
- if (null != obj)
- return (ElemDesc)obj;
- return m_dummy;
- }
-
- /**
- * A Trie that is just a copy of the "static" one.
- * We need this one to be able to use the faster, but not thread-safe
- * method Trie.get2(name)
- */
- private Trie m_htmlInfo = new Trie(m_elementFlags);
- /**
- * Calls to this method could be replaced with calls to
- * getElemDesc(name), but this one should be faster.
- */
- private ElemDesc getElemDesc2(String name)
- {
- Object obj = m_htmlInfo.get2(name);
- if (null != obj)
- return (ElemDesc)obj;
- return m_dummy;
- }
-
- /**
- * Default constructor.
- */
- public ToHTMLStream()
- {
-
- super();
- m_charInfo = m_htmlcharInfo;
- // initialize namespaces
- m_prefixMap = new NamespaceMappings();
-
- }
-
- /** The name of the current element. */
-// private String m_currentElementName = null;
-
- /**
- * Receive notification of the beginning of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void startDocumentInternal() throws org.xml.sax.SAXException
- {
- super.startDocumentInternal();
-
- m_needToCallStartDocument = false;
- m_needToOutputDocTypeDecl = true;
- m_startNewLine = false;
- setOmitXMLDeclaration(true);
-
- if (true == m_needToOutputDocTypeDecl)
- {
- String doctypeSystem = getDoctypeSystem();
- String doctypePublic = getDoctypePublic();
- if ((null != doctypeSystem) || (null != doctypePublic))
- {
- final java.io.Writer writer = m_writer;
- try
- {
- writer.write("<!DOCTYPE html");
-
- if (null != doctypePublic)
- {
- writer.write(" PUBLIC \"");
- writer.write(doctypePublic);
- writer.write('"');
- }
-
- if (null != doctypeSystem)
- {
- if (null == doctypePublic)
- writer.write(" SYSTEM \"");
- else
- writer.write(" \"");
-
- writer.write(doctypeSystem);
- writer.write('"');
- }
-
- writer.write('>');
- outputLineSep();
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- }
-
- m_needToOutputDocTypeDecl = false;
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public final void endDocument() throws org.xml.sax.SAXException
- {
-
- flushPending();
- if (m_doIndent && !m_isprevtext)
- {
- try
- {
- outputLineSep();
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- flushWriter();
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * Receive notification of the beginning of an element.
- *
- *
- * @param namespaceURI
- * @param localName
- * @param name The element type name.
- * @param atts The attributes attached to the element, if any.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement
- * @see org.xml.sax.AttributeList
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String name,
- Attributes atts)
- throws org.xml.sax.SAXException
- {
-
- ElemContext elemContext = m_elemContext;
-
- // clean up any pending things first
- if (elemContext.m_startTagOpen)
- {
- closeStartTag();
- elemContext.m_startTagOpen = false;
- }
- else if (m_cdataTagOpen)
- {
- closeCDATA();
- m_cdataTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
-
-
- // if this element has a namespace then treat it like XML
- if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
- {
- super.startElement(namespaceURI, localName, name, atts);
-
- return;
- }
-
- try
- {
- // getElemDesc2(name) is faster than getElemDesc(name)
- ElemDesc elemDesc = getElemDesc2(name);
- int elemFlags = elemDesc.getFlags();
-
- // deal with indentation issues first
- if (m_doIndent)
- {
-
- boolean isBlockElement = (elemFlags & ElemDesc.BLOCK) != 0;
- if (m_ispreserve)
- m_ispreserve = false;
- else if (
- (null != elemContext.m_elementName)
- && (!m_inBlockElem
- || isBlockElement) /* && !isWhiteSpaceSensitive */
- )
- {
- m_startNewLine = true;
-
- indent();
-
- }
- m_inBlockElem = !isBlockElement;
- }
-
- // save any attributes for later processing
- if (atts != null)
- addAttributes(atts);
-
- m_isprevtext = false;
- final java.io.Writer writer = m_writer;
- writer.write('<');
- writer.write(name);
-
-
-
- if (m_tracer != null)
- firePseudoAttributes();
-
- if ((elemFlags & ElemDesc.EMPTY) != 0)
- {
- // an optimization for elements which are expected
- // to be empty.
- m_elemContext = elemContext.push();
- /* XSLTC sometimes calls namespaceAfterStartElement()
- * so we need to remember the name
- */
- m_elemContext.m_elementName = name;
- m_elemContext.m_elementDesc = elemDesc;
- return;
- }
- else
- {
- elemContext = elemContext.push(namespaceURI,localName,name);
- m_elemContext = elemContext;
- elemContext.m_elementDesc = elemDesc;
- elemContext.m_isRaw = (elemFlags & ElemDesc.RAW) != 0;
- }
-
-
- if ((elemFlags & ElemDesc.HEADELEM) != 0)
- {
- // This is the <HEAD> element, do some special processing
- closeStartTag();
- elemContext.m_startTagOpen = false;
- if (!m_omitMetaTag)
- {
- if (m_doIndent)
- indent();
- writer.write(
- "<META http-equiv=\"Content-Type\" content=\"text/html;charset=");
- String encoding = getEncoding();
- String encode = Encodings.getMimeEncoding(encoding);
- writer.write(encode);
- writer.write("\">");
- }
- }
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Receive notification of the end of an element.
- *
- *
- * @param namespaceURI
- * @param localName
- * @param name The element type name
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public final void endElement(
- final String namespaceURI,
- final String localName,
- final String name)
- throws org.xml.sax.SAXException
- {
- // deal with any pending issues
- if (m_cdataTagOpen)
- closeCDATA();
-
- // if the element has a namespace, treat it like XML, not HTML
- if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
- {
- super.endElement(namespaceURI, localName, name);
-
- return;
- }
-
- try
- {
-
- ElemContext elemContext = m_elemContext;
- final ElemDesc elemDesc = elemContext.m_elementDesc;
- final int elemFlags = elemDesc.getFlags();
- final boolean elemEmpty = (elemFlags & ElemDesc.EMPTY) != 0;
-
- // deal with any indentation issues
- if (m_doIndent)
- {
- final boolean isBlockElement = (elemFlags&ElemDesc.BLOCK) != 0;
- boolean shouldIndent = false;
-
- if (m_ispreserve)
- {
- m_ispreserve = false;
- }
- else if (m_doIndent && (!m_inBlockElem || isBlockElement))
- {
- m_startNewLine = true;
- shouldIndent = true;
- }
- if (!elemContext.m_startTagOpen && shouldIndent)
- indent(elemContext.m_currentElemDepth - 1);
- m_inBlockElem = !isBlockElement;
- }
-
- final java.io.Writer writer = m_writer;
- if (!elemContext.m_startTagOpen)
- {
- writer.write("</");
- writer.write(name);
- writer.write('>');
- }
- else
- {
- // the start-tag open when this method was called,
- // so we need to process it now.
-
- if (m_tracer != null)
- super.fireStartElem(name);
-
- // the starting tag was still open when we received this endElement() call
- // so we need to process any gathered attributes NOW, before they go away.
- int nAttrs = m_attributes.getLength();
- if (nAttrs > 0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
- if (!elemEmpty)
- {
- // As per Dave/Paul recommendation 12/06/2000
- // if (shouldIndent)
- // writer.write('>');
- // indent(m_currentIndent);
-
- writer.write("></");
- writer.write(name);
- writer.write('>');
- }
- else
- {
- writer.write('>');
- }
- }
-
- // clean up because the element has ended
- if ((elemFlags & ElemDesc.WHITESPACESENSITIVE) != 0)
- m_ispreserve = true;
- m_isprevtext = false;
-
- // fire off the end element event
- if (m_tracer != null)
- super.fireEndElem(name);
-
- // OPTIMIZE-EMPTY
- if (elemEmpty)
- {
- // a quick exit if the HTML element had no children.
- // This block of code can be removed if the corresponding block of code
- // in startElement() also labeled with "OPTIMIZE-EMPTY" is also removed
- m_elemContext = elemContext.m_prev;
- return;
- }
-
- // some more clean because the element has ended.
- if (!elemContext.m_startTagOpen)
- {
- if (m_doIndent && !m_preserves.isEmpty())
- m_preserves.pop();
- }
- m_elemContext = elemContext.m_prev;
-// m_isRawStack.pop();
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Process an attribute.
- * @param writer The writer to write the processed output to.
- * @param name The name of the attribute.
- * @param value The value of the attribute.
- * @param elemDesc The description of the HTML element
- * that has this attribute.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void processAttribute(
- java.io.Writer writer,
- String name,
- String value,
- ElemDesc elemDesc)
- throws IOException
- {
- writer.write(' ');
-
- if ( ((value.length() == 0) || value.equalsIgnoreCase(name))
- && elemDesc != null
- && elemDesc.isAttrFlagSet(name, ElemDesc.ATTREMPTY))
- {
- writer.write(name);
- }
- else
- {
- // %REVIEW% %OPT%
- // Two calls to single-char write may NOT
- // be more efficient than one to string-write...
- writer.write(name);
- writer.write("=\"");
- if ( elemDesc != null
- && elemDesc.isAttrFlagSet(name, ElemDesc.ATTRURL))
- writeAttrURI(writer, value, m_specialEscapeURLs);
- else
- writeAttrString(writer, value, this.getEncoding());
- writer.write('"');
-
- }
- }
-
- /**
- * Tell if a character is an ASCII digit.
- */
- private boolean isASCIIDigit(char c)
- {
- return (c >= '0' && c <= '9');
- }
-
- /**
- * Make an integer into an HH hex value.
- * Does no checking on the size of the input, since this
- * is only meant to be used locally by writeAttrURI.
- *
- * @param i must be a value less than 255.
- *
- * @return should be a two character string.
- */
- private static String makeHHString(int i)
- {
- String s = Integer.toHexString(i).toUpperCase();
- if (s.length() == 1)
- {
- s = "0" + s;
- }
- return s;
- }
-
- /**
- * Dmitri Ilyin: Makes sure if the String is HH encoded sign.
- * @param str must be 2 characters long
- *
- * @return true or false
- */
- private boolean isHHSign(String str)
- {
- boolean sign = true;
- try
- {
- char r = (char) Integer.parseInt(str, 16);
- }
- catch (NumberFormatException e)
- {
- sign = false;
- }
- return sign;
- }
-
- /**
- * Write the specified <var>string</var> after substituting non ASCII characters,
- * with <CODE>%HH</CODE>, where HH is the hex of the byte value.
- *
- * @param string String to convert to XML format.
- * @param doURLEscaping True if we should try to encode as
- * per http://www.ietf.org/rfc/rfc2396.txt.
- *
- * @throws org.xml.sax.SAXException if a bad surrogate pair is detected.
- */
- public void writeAttrURI(
- final java.io.Writer writer, String string, boolean doURLEscaping)
- throws IOException
- {
- // http://www.ietf.org/rfc/rfc2396.txt says:
- // A URI is always in an "escaped" form, since escaping or unescaping a
- // completed URI might change its semantics. Normally, the only time
- // escape encodings can safely be made is when the URI is being created
- // from its component parts; each component may have its own set of
- // characters that are reserved, so only the mechanism responsible for
- // generating or interpreting that component can determine whether or
- // not escaping a character will change its semantics. Likewise, a URI
- // must be separated into its components before the escaped characters
- // within those components can be safely decoded.
- //
- // ...So we do our best to do limited escaping of the URL, without
- // causing damage. If the URL is already properly escaped, in theory, this
- // function should not change the string value.
-
- final int end = string.length();
- if (end > m_attrBuff.length)
- {
- m_attrBuff = new char[end*2 + 1];
- }
- string.getChars(0,end, m_attrBuff, 0);
- final char[] chars = m_attrBuff;
-
- int cleanStart = 0;
- int cleanLength = 0;
-
-
- char ch = 0;
- for (int i = 0; i < end; i++)
- {
- ch = chars[i];
-
- if ((ch < 32) || (ch > 126))
- {
- if (cleanLength > 0)
- {
- writer.write(chars, cleanStart, cleanLength);
- cleanLength = 0;
- }
- if (doURLEscaping)
- {
- // Encode UTF16 to UTF8.
- // Reference is Unicode, A Primer, by Tony Graham.
- // Page 92.
-
- // Note that Kay doesn't escape 0x20...
- // if(ch == 0x20) // Not sure about this... -sb
- // {
- // writer.write(ch);
- // }
- // else
- if (ch <= 0x7F)
- {
- writer.write('%');
- writer.write(makeHHString(ch));
- }
- else if (ch <= 0x7FF)
- {
- // Clear low 6 bits before rotate, put high 4 bits in low byte,
- // and set two high bits.
- int high = (ch >> 6) | 0xC0;
- int low = (ch & 0x3F) | 0x80;
- // First 6 bits, + high bit
- writer.write('%');
- writer.write(makeHHString(high));
- writer.write('%');
- writer.write(makeHHString(low));
- }
- else if (Encodings.isHighUTF16Surrogate(ch)) // high surrogate
- {
- // I'm sure this can be done in 3 instructions, but I choose
- // to try and do it exactly like it is done in the book, at least
- // until we are sure this is totally clean. I don't think performance
- // is a big issue with this particular function, though I could be
- // wrong. Also, the stuff below clearly does more masking than
- // it needs to do.
-
- // Clear high 6 bits.
- int highSurrogate = ((int) ch) & 0x03FF;
-
- // Middle 4 bits (wwww) + 1
- // "Note that the value of wwww from the high surrogate bit pattern
- // is incremented to make the uuuuu bit pattern in the scalar value
- // so the surrogate pair don't address the BMP."
- int wwww = ((highSurrogate & 0x03C0) >> 6);
- int uuuuu = wwww + 1;
-
- // next 4 bits
- int zzzz = (highSurrogate & 0x003C) >> 2;
-
- // low 2 bits
- int yyyyyy = ((highSurrogate & 0x0003) << 4) & 0x30;
-
- // Get low surrogate character.
- ch = chars[++i];
-
- // Clear high 6 bits.
- int lowSurrogate = ((int) ch) & 0x03FF;
-
- // put the middle 4 bits into the bottom of yyyyyy (byte 3)
- yyyyyy = yyyyyy | ((lowSurrogate & 0x03C0) >> 6);
-
- // bottom 6 bits.
- int xxxxxx = (lowSurrogate & 0x003F);
-
- int byte1 = 0xF0 | (uuuuu >> 2); // top 3 bits of uuuuu
- int byte2 =
- 0x80 | (((uuuuu & 0x03) << 4) & 0x30) | zzzz;
- int byte3 = 0x80 | yyyyyy;
- int byte4 = 0x80 | xxxxxx;
-
- writer.write('%');
- writer.write(makeHHString(byte1));
- writer.write('%');
- writer.write(makeHHString(byte2));
- writer.write('%');
- writer.write(makeHHString(byte3));
- writer.write('%');
- writer.write(makeHHString(byte4));
- }
- else
- {
- int high = (ch >> 12) | 0xE0; // top 4 bits
- int middle = ((ch & 0x0FC0) >> 6) | 0x80;
- // middle 6 bits
- int low = (ch & 0x3F) | 0x80;
- // First 6 bits, + high bit
- writer.write('%');
- writer.write(makeHHString(high));
- writer.write('%');
- writer.write(makeHHString(middle));
- writer.write('%');
- writer.write(makeHHString(low));
- }
-
- }
- else if (escapingNotNeeded(ch))
- {
- writer.write(ch);
- }
- else
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- // In this character range we have first written out any previously accumulated
- // "clean" characters, then processed the current more complicated character,
- // which may have incremented "i".
- // We now we reset the next possible clean character.
- cleanStart = i + 1;
- }
- // Since http://www.ietf.org/rfc/rfc2396.txt refers to the URI grammar as
- // not allowing quotes in the URI proper syntax, nor in the fragment
- // identifier, we believe that it's OK to double escape quotes.
- else if (ch == '"')
- {
- // If the character is a '%' number number, try to avoid double-escaping.
- // There is a question if this is legal behavior.
-
- // Dmitri Ilyin: to check if '%' number number is invalid. It must be checked if %xx is a sign, that would be encoded
- // The encoded signes are in Hex form. So %xx my be in form %3C that is "<" sign. I will try to change here a little.
-
- // if( ((i+2) < len) && isASCIIDigit(stringArray[i+1]) && isASCIIDigit(stringArray[i+2]) )
-
- // We are no longer escaping '%'
-
- if (cleanLength > 0)
- {
- writer.write(chars, cleanStart, cleanLength);
- cleanLength = 0;
- }
-
-
- // Mike Kay encodes this as ", so he may know something I don't?
- if (doURLEscaping)
- writer.write("%22");
- else
- writer.write("""); // we have to escape this, I guess.
-
- // We have written out any clean characters, then the escaped '%' and now we
- // We now we reset the next possible clean character.
- cleanStart = i + 1;
- }
- else
- {
- // no processing for this character, just count how
- // many characters in a row that we have that need no processing
- cleanLength++;
- }
- }
-
- // are there any clean characters at the end of the array
- // that we haven't processed yet?
- if (cleanLength > 1)
- {
- // if the whole string can be written out as-is do so
- // otherwise write out the clean chars at the end of the
- // array
- if (cleanStart == 0)
- writer.write(string);
- else
- writer.write(chars, cleanStart, cleanLength);
- }
- else if (cleanLength == 1)
- {
- // a little optimization for 1 clean character
- // (we could have let the previous if(...) handle them all)
- writer.write(ch);
- }
- }
-
- /**
- * Writes the specified <var>string</var> after substituting <VAR>specials</VAR>,
- * and UTF-16 surrogates for character references <CODE>&#xnn</CODE>.
- *
- * @param string String to convert to XML format.
- * @param encoding CURRENTLY NOT IMPLEMENTED.
- *
- * @throws org.xml.sax.SAXException
- */
- public void writeAttrString(
- final java.io.Writer writer, String string, String encoding)
- throws IOException
- {
- final int end = string.length();
- if (end > m_attrBuff.length)
- {
- m_attrBuff = new char[end * 2 + 1];
- }
- string.getChars(0, end, m_attrBuff, 0);
- final char[] chars = m_attrBuff;
-
-
-
- int cleanStart = 0;
- int cleanLength = 0;
-
- char ch = 0;
- for (int i = 0; i < end; i++)
- {
- ch = chars[i];
-
- // System.out.println("SPECIALSSIZE: "+SPECIALSSIZE);
- // System.out.println("ch: "+(int)ch);
- // System.out.println("m_maxCharacter: "+(int)m_maxCharacter);
- // System.out.println("m_attrCharsMap[ch]: "+(int)m_attrCharsMap[ch]);
- if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch)))
- {
- cleanLength++;
- }
- else if ('<' == ch || '>' == ch)
- {
- cleanLength++; // no escaping in this case, as specified in 15.2
- }
- else if (
- ('&' == ch) && ((i + 1) < end) && ('{' == chars[i + 1]))
- {
- cleanLength++; // no escaping in this case, as specified in 15.2
- }
- else
- {
- if (cleanLength > 0)
- {
- writer.write(chars,cleanStart,cleanLength);
- cleanLength = 0;
- }
- int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true);
-
- if (i != pos)
- {
- i = pos - 1;
- }
- else
- {
- if (Encodings.isHighUTF16Surrogate(ch))
- {
-
- writeUTF16Surrogate(ch, chars, i, end);
- i++; // two input characters processed
- // this increments by one and the for()
- // loop itself increments by another one.
- }
-
- // The next is kind of a hack to keep from escaping in the case
- // of Shift_JIS and the like.
-
- /*
- else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF)
- && (ch != 160))
- {
- writer.write(ch); // no escaping in this case
- }
- else
- */
- String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
- if (null != outputStringForChar)
- {
- writer.write(outputStringForChar);
- }
- else if (escapingNotNeeded(ch))
- {
- writer.write(ch); // no escaping in this case
- }
- else
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- }
- cleanStart = i + 1;
- }
- } // end of for()
-
- // are there any clean characters at the end of the array
- // that we haven't processed yet?
- if (cleanLength > 1)
- {
- // if the whole string can be written out as-is do so
- // otherwise write out the clean chars at the end of the
- // array
- if (cleanStart == 0)
- writer.write(string);
- else
- writer.write(chars, cleanStart, cleanLength);
- }
- else if (cleanLength == 1)
- {
- // a little optimization for 1 clean character
- // (we could have let the previous if(...) handle them all)
- writer.write(ch);
- }
- }
-
-
-
- /**
- * Receive notification of character data.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param chars The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- public final void characters(char chars[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if (m_elemContext.m_isRaw)
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- m_ispreserve = true;
-
-// With m_ispreserve just set true it looks like shouldIndent()
-// will always return false, so drop any possible indentation.
-// if (shouldIndent())
-// indent();
-
- // writer.write("<![CDATA[");
- // writer.write(chars, start, length);
- writeNormalizedChars(chars, start, length, false, m_lineSepUse);
-
- // writer.write("]]>");
-
- // time to generate characters event
- if (m_tracer != null)
- super.fireCharEvent(chars, start, length);
-
- return;
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(
- Utils.messages.createMessage(
- MsgKey.ER_OIERROR,
- null),
- ioe);
- //"IO error", ioe);
- }
- }
- else
- {
- super.characters(chars, start, length);
- }
- }
-
- /**
- * Receive notification of cdata.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- public final void cdata(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if ((null != m_elemContext.m_elementName)
- && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
- || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")))
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- m_ispreserve = true;
-
- if (shouldIndent())
- indent();
-
- // writer.write(ch, start, length);
- writeNormalizedChars(ch, start, length, true, m_lineSepUse);
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(
- Utils.messages.createMessage(
- MsgKey.ER_OIERROR,
- null),
- ioe);
- //"IO error", ioe);
- }
- }
- else
- {
- super.cdata(ch, start, length);
- }
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if
- * none was supplied.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void processingInstruction(String target, String data)
- throws org.xml.sax.SAXException
- {
-
- // Process any pending starDocument and startElement first.
- flushPending();
-
- // Use a fairly nasty hack to tell if the next node is supposed to be
- // unescaped text.
- if (target.equals(Result.PI_DISABLE_OUTPUT_ESCAPING))
- {
- startNonEscaping();
- }
- else if (target.equals(Result.PI_ENABLE_OUTPUT_ESCAPING))
- {
- endNonEscaping();
- }
- else
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- startDocumentInternal();
-
- if (shouldIndent())
- indent();
-
- final java.io.Writer writer = m_writer;
- //writer.write("<?" + target);
- writer.write("<?");
- writer.write(target);
-
- if (data.length() > 0 && !Character.isSpaceChar(data.charAt(0)))
- writer.write(' ');
-
- //writer.write(data + ">"); // different from XML
- writer.write(data); // different from XML
- writer.write('>'); // different from XML
-
- // Always output a newline char if not inside of an
- // element. The whitespace is not significant in that
- // case.
- if (m_elemContext.m_currentElemDepth <= 0)
- outputLineSep();
-
- m_startNewLine = true;
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- // now generate the PI event
- if (m_tracer != null)
- super.fireEscapingEvent(target, data);
- }
-
- /**
- * Receive notivication of a entityReference.
- *
- * @param name non-null reference to entity name string.
- *
- * @throws org.xml.sax.SAXException
- */
- public final void entityReference(String name)
- throws org.xml.sax.SAXException
- {
- try
- {
-
- final java.io.Writer writer = m_writer;
- writer.write('&');
- writer.write(name);
- writer.write(';');
-
- } catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- /**
- * @see ExtendedContentHandler#endElement(String)
- */
- public final void endElement(String elemName) throws SAXException
- {
- endElement(null, null, elemName);
- }
-
- /**
- * Process the attributes, which means to write out the currently
- * collected attributes to the writer. The attributes are not
- * cleared by this method
- *
- * @param writer the writer to write processed attributes to.
- * @param nAttrs the number of attributes in m_attributes
- * to be processed
- *
- * @throws org.xml.sax.SAXException
- */
- public void processAttributes(java.io.Writer writer, int nAttrs)
- throws IOException,SAXException
- {
- /*
- * process the collected attributes
- */
- for (int i = 0; i < nAttrs; i++)
- {
- processAttribute(
- writer,
- m_attributes.getQName(i),
- m_attributes.getValue(i),
- m_elemContext.m_elementDesc);
- }
- }
-
- /**
- * For the enclosing elements starting tag write out out any attributes
- * followed by ">"
- *
- *@throws org.xml.sax.SAXException
- */
- protected void closeStartTag() throws SAXException
- {
- try
- {
-
- // finish processing attributes, time to fire off the start element event
- if (m_tracer != null)
- super.fireStartElem(m_elemContext.m_elementName);
-
- int nAttrs = m_attributes.getLength();
- if (nAttrs>0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
-
- m_writer.write('>');
-
- /* whether Xalan or XSLTC, we have the prefix mappings now, so
- * lets determine if the current element is specified in the cdata-
- * section-elements list.
- */
- if (m_cdataSectionElements != null)
- m_elemContext.m_isCdataSection = isCdataSection();
- if (m_doIndent)
- {
- m_isprevtext = false;
- m_preserves.push(m_ispreserve);
- }
-
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- /**
- * Initialize the serializer with the specified output stream and output
- * format. Must be called before calling any of the serialize methods.
- *
- * @param output The output stream to use
- * @param format The output format
- * @throws UnsupportedEncodingException The encoding specified in the
- * output format is not supported
- */
- protected synchronized void init(OutputStream output, Properties format)
- throws UnsupportedEncodingException
- {
- if (null == format)
- {
- format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
- }
- super.init(output,format, false);
- }
-
- /**
- * Specifies an output stream to which the document should be
- * serialized. This method should not be called while the
- * serializer is in the process of serializing a document.
- * <p>
- * The encoding specified in the output properties is used, or
- * if no encoding was specified, the default for the selected
- * output method.
- *
- * @param output The output stream
- */
- public void setOutputStream(OutputStream output)
- {
-
- try
- {
- Properties format;
- if (null == m_format)
- format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
- else
- format = m_format;
- init(output, format, true);
- }
- catch (UnsupportedEncodingException uee)
- {
-
- // Should have been warned in init, I guess...
- }
- }
- /**
- * This method is used when a prefix/uri namespace mapping
- * is indicated after the element was started with a
- * startElement() and before and endElement().
- * startPrefixMapping(prefix,uri) would be used before the
- * startElement() call.
- * @param uri the URI of the namespace
- * @param prefix the prefix associated with the given URI.
- *
- * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
- */
- public void namespaceAfterStartElement(String prefix, String uri)
- throws SAXException
- {
- // hack for XSLTC with finding URI for default namespace
- if (m_elemContext.m_elementURI == null)
- {
- String prefix1 = getPrefixPart(m_elemContext.m_elementName);
- if (prefix1 == null && EMPTYSTRING.equals(prefix))
- {
- // the elements URI is not known yet, and it
- // doesn't have a prefix, and we are currently
- // setting the uri for prefix "", so we have
- // the uri for the element... lets remember it
- m_elemContext.m_elementURI = uri;
- }
- }
- startPrefixMapping(prefix,uri,false);
- }
-
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException
- {
- m_inDTD = true;
- super.startDTD(name, publicId, systemId);
- }
-
- /**
- * Report the end of DTD declarations.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #startDTD
- */
- public void endDTD() throws org.xml.sax.SAXException
- {
- m_inDTD = false;
- /* for ToHTMLStream the DOCTYPE is entirely output in the
- * startDocumentInternal() method, so don't do anything here
- */
- }
- /**
- * This method does nothing.
- */
- public void attributeDecl(
- String eName,
- String aName,
- String type,
- String valueDefault,
- String value)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
-
- /**
- * This method does nothing.
- */
- public void elementDecl(String name, String model) throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
- /**
- * This method does nothing.
- */
- public void internalEntityDecl(String name, String value)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
- /**
- * This method does nothing.
- */
- public void externalEntityDecl(
- String name,
- String publicId,
- String systemId)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
-
- /**
- * This method is used to add an attribute to the currently open element.
- * The caller has guaranted that this attribute is unique, which means that it
- * not been seen before and will not be seen again.
- *
- * @param name the qualified name of the attribute
- * @param value the value of the attribute which can contain only
- * ASCII printable characters characters in the range 32 to 127 inclusive.
- * @param flags the bit values of this integer give optimization information.
- */
- public void addUniqueAttribute(String name, String value, int flags)
- throws SAXException
- {
- try
- {
- final java.io.Writer writer = m_writer;
- if ((flags & NO_BAD_CHARS) > 0 && m_htmlcharInfo.onlyQuotAmpLtGt)
- {
- // "flags" has indicated that the characters
- // '>' '<' '&' and '"' are not in the value and
- // m_htmlcharInfo has recorded that there are no other
- // entities in the range 0 to 127 so we write out the
- // value directly
- writer.write(' ');
- writer.write(name);
- writer.write("=\"");
- writer.write(value);
- writer.write('"');
- }
- else if (
- (flags & HTML_ATTREMPTY) > 0
- && (value.length() == 0 || value.equalsIgnoreCase(name)))
- {
- writer.write(' ');
- writer.write(name);
- }
- else
- {
- writer.write(' ');
- writer.write(name);
- writer.write("=\"");
- if ((flags & HTML_ATTRURL) > 0)
- {
- writeAttrURI(writer, value, m_specialEscapeURLs);
- }
- else
- {
- writeAttrString(writer, value, this.getEncoding());
- }
- writer.write('"');
- }
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
-
- public void comment(char ch[], int start, int length)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- if (m_inDTD)
- return;
- super.comment(ch, start, length);
- }
-
- public boolean reset()
- {
- boolean ret = super.reset();
- if (!ret)
- return false;
- initToHTMLStream();
- return true;
- }
-
- private void initToHTMLStream()
- {
-// m_elementDesc = null;
- m_inBlockElem = false;
- m_inDTD = false;
-// m_isRawStack.clear();
- m_omitMetaTag = false;
- m_specialEscapeURLs = true;
- }
-
- static class Trie
- {
- /**
- * A digital search trie for 7-bit ASCII text
- * The API is a subset of java.util.Hashtable
- * The key must be a 7-bit ASCII string
- * The value may be any Java Object
- * One can get an object stored in a trie from its key,
- * but the search is either case sensitive or case
- * insensitive to the characters in the key, and this
- * choice of sensitivity or insensitivity is made when
- * the Trie is created, before any objects are put in it.
- *
- * This class is a copy of the one in org.apache.xml.utils.
- * It exists to cut the serializers dependancy on that package.
- *
- * @xsl.usage internal
- */
-
- /** Size of the m_nextChar array. */
- public static final int ALPHA_SIZE = 128;
-
- /** The root node of the tree. */
- final Node m_Root;
-
- /** helper buffer to convert Strings to char arrays */
- private char[] m_charBuffer = new char[0];
-
- /** true if the search for an object is lower case only with the key */
- private final boolean m_lowerCaseOnly;
-
- /**
- * Construct the trie that has a case insensitive search.
- */
- public Trie()
- {
- m_Root = new Node();
- m_lowerCaseOnly = false;
- }
-
- /**
- * Construct the trie given the desired case sensitivity with the key.
- * @param lowerCaseOnly true if the search keys are to be loser case only,
- * not case insensitive.
- */
- public Trie(boolean lowerCaseOnly)
- {
- m_Root = new Node();
- m_lowerCaseOnly = lowerCaseOnly;
- }
-
- /**
- * Put an object into the trie for lookup.
- *
- * @param key must be a 7-bit ASCII string
- * @param value any java object.
- *
- * @return The old object that matched key, or null.
- */
- public Object put(String key, Object value)
- {
-
- final int len = key.length();
- if (len > m_charBuffer.length)
- {
- // make the biggest buffer ever needed in get(String)
- m_charBuffer = new char[len];
- }
-
- Node node = m_Root;
-
- for (int i = 0; i < len; i++)
- {
- Node nextNode =
- node.m_nextChar[Character.toLowerCase(key.charAt(i))];
-
- if (nextNode != null)
- {
- node = nextNode;
- }
- else
- {
- for (; i < len; i++)
- {
- Node newNode = new Node();
- if (m_lowerCaseOnly)
- {
- // put this value into the tree only with a lower case key
- node.m_nextChar[Character.toLowerCase(
- key.charAt(i))] =
- newNode;
- }
- else
- {
- // put this value into the tree with a case insensitive key
- node.m_nextChar[Character.toUpperCase(
- key.charAt(i))] =
- newNode;
- node.m_nextChar[Character.toLowerCase(
- key.charAt(i))] =
- newNode;
- }
- node = newNode;
- }
- break;
- }
- }
-
- Object ret = node.m_Value;
-
- node.m_Value = value;
-
- return ret;
- }
-
- /**
- * Get an object that matches the key.
- *
- * @param key must be a 7-bit ASCII string
- *
- * @return The object that matches the key, or null.
- */
- public Object get(final String key)
- {
-
- final int len = key.length();
-
- /* If the name is too long, we won't find it, this also keeps us
- * from overflowing m_charBuffer
- */
- if (m_charBuffer.length < len)
- return null;
-
- Node node = m_Root;
- switch (len) // optimize the look up based on the number of chars
- {
- // case 0 looks silly, but the generated bytecode runs
- // faster for lookup of elements of length 2 with this in
- // and a fair bit faster. Don't know why.
- case 0 :
- {
- return null;
- }
-
- case 1 :
- {
- final char ch = key.charAt(0);
- if (ch < ALPHA_SIZE)
- {
- node = node.m_nextChar[ch];
- if (node != null)
- return node.m_Value;
- }
- return null;
- }
- // comment out case 2 because the default is faster
- // case 2 :
- // {
- // final char ch0 = key.charAt(0);
- // final char ch1 = key.charAt(1);
- // if (ch0 < ALPHA_SIZE && ch1 < ALPHA_SIZE)
- // {
- // node = node.m_nextChar[ch0];
- // if (node != null)
- // {
- //
- // if (ch1 < ALPHA_SIZE)
- // {
- // node = node.m_nextChar[ch1];
- // if (node != null)
- // return node.m_Value;
- // }
- // }
- // }
- // return null;
- // }
- default :
- {
- for (int i = 0; i < len; i++)
- {
- // A thread-safe way to loop over the characters
- final char ch = key.charAt(i);
- if (ALPHA_SIZE <= ch)
- {
- // the key is not 7-bit ASCII so we won't find it here
- return null;
- }
-
- node = node.m_nextChar[ch];
- if (node == null)
- return null;
- }
-
- return node.m_Value;
- }
- }
- }
-
- /**
- * The node representation for the trie.
- * @xsl.usage internal
- */
- private class Node
- {
-
- /**
- * Constructor, creates a Node[ALPHA_SIZE].
- */
- Node()
- {
- m_nextChar = new Node[ALPHA_SIZE];
- m_Value = null;
- }
-
- /** The next nodes. */
- final Node m_nextChar[];
-
- /** The value. */
- Object m_Value;
- }
- /**
- * Construct the trie from another Trie.
- * Both the existing Trie and this new one share the same table for
- * lookup, and it is assumed that the table is fully populated and
- * not changing anymore.
- *
- * @param existingTrie the Trie that this one is a copy of.
- */
- public Trie(Trie existingTrie)
- {
- // copy some fields from the existing Trie into this one.
- m_Root = existingTrie.m_Root;
- m_lowerCaseOnly = existingTrie.m_lowerCaseOnly;
-
- // get a buffer just big enough to hold the longest key in the table.
- int max = existingTrie.getLongestKeyLength();
- m_charBuffer = new char[max];
- }
-
- /**
- * Get an object that matches the key.
- * This method is faster than get(), but is not thread-safe.
- *
- * @param key must be a 7-bit ASCII string
- *
- * @return The object that matches the key, or null.
- */
- public Object get2(final String key)
- {
-
- final int len = key.length();
-
- /* If the name is too long, we won't find it, this also keeps us
- * from overflowing m_charBuffer
- */
- if (m_charBuffer.length < len)
- return null;
-
- Node node = m_Root;
- switch (len) // optimize the look up based on the number of chars
- {
- // case 0 looks silly, but the generated bytecode runs
- // faster for lookup of elements of length 2 with this in
- // and a fair bit faster. Don't know why.
- case 0 :
- {
- return null;
- }
-
- case 1 :
- {
- final char ch = key.charAt(0);
- if (ch < ALPHA_SIZE)
- {
- node = node.m_nextChar[ch];
- if (node != null)
- return node.m_Value;
- }
- return null;
- }
- default :
- {
- /* Copy string into array. This is not thread-safe because
- * it modifies the contents of m_charBuffer. If multiple
- * threads were to use this Trie they all would be
- * using this same array (not good). So this
- * method is not thread-safe, but it is faster because
- * converting to a char[] and looping over elements of
- * the array is faster than a String's charAt(i).
- */
- key.getChars(0, len, m_charBuffer, 0);
-
- for (int i = 0; i < len; i++)
- {
- final char ch = m_charBuffer[i];
- if (ALPHA_SIZE <= ch)
- {
- // the key is not 7-bit ASCII so we won't find it here
- return null;
- }
-
- node = node.m_nextChar[ch];
- if (node == null)
- return null;
- }
-
- return node.m_Value;
- }
- }
- }
-
- /**
- * Get the length of the longest key used in the table.
- */
- public int getLongestKeyLength()
- {
- return m_charBuffer.length;
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToSAXHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToSAXHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToSAXHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,436 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToSAXHandler.java,v 1.1.2.1 2007/01/09 18:57:27 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Vector;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class is used to provide a base behavior to be inherited
- * by other To...SAXHandler serializers.
- *
- * This class is not a public API.
- *
- * @xsl.usage internal
- */
-public abstract class ToSAXHandler extends SerializerBase
-{
- public ToSAXHandler()
- {
- }
-
- public ToSAXHandler(
- ContentHandler hdlr,
- LexicalHandler lex,
- String encoding)
- {
- setContentHandler(hdlr);
- setLexHandler(lex);
- setEncoding(encoding);
- }
- public ToSAXHandler(ContentHandler handler, String encoding)
- {
- setContentHandler(handler);
- setEncoding(encoding);
- }
-
- /**
- * Underlying SAX handler. Taken from XSLTC
- */
- protected ContentHandler m_saxHandler;
-
- /**
- * Underlying LexicalHandler. Taken from XSLTC
- */
- protected LexicalHandler m_lexHandler;
-
- /**
- * A startPrefixMapping() call on a ToSAXHandler will pass that call
- * on to the wrapped ContentHandler, but should we also mirror these calls
- * with matching attributes, if so this field is true.
- * For example if this field is true then a call such as
- * startPrefixMapping("prefix1","uri1") will also cause the additional
- * internally generated attribute xmlns:prefix1="uri1" to be effectively added
- * to the attributes passed to the wrapped ContentHandler.
- */
- private boolean m_shouldGenerateNSAttribute = true;
-
- /** If this is true, then the content handler wrapped by this
- * serializer implements the TransformState interface which
- * will give the content handler access to the state of
- * the transform. */
- protected TransformStateSetter m_state = null;
-
- /**
- * Pass callback to the SAX Handler
- */
- protected void startDocumentInternal() throws SAXException
- {
- if (m_needToCallStartDocument)
- {
- super.startDocumentInternal();
-
- m_saxHandler.startDocument();
- m_needToCallStartDocument = false;
- }
- }
- /**
- * Do nothing.
- * @see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
- */
- public void startDTD(String arg0, String arg1, String arg2)
- throws SAXException
- {
- // do nothing for now
- }
-
- /**
- * Receive notification of character data.
- *
- * @param characters The string of characters to process.
- *
- * @throws org.xml.sax.SAXException
- *
- * @see ExtendedContentHandler#characters(String)
- */
- public void characters(String characters) throws SAXException
- {
- final int len = characters.length();
- if (len > m_charsBuff.length)
- {
- m_charsBuff = new char[len*2 + 1];
- }
- characters.getChars(0,len, m_charsBuff, 0);
- characters(m_charsBuff, 0, len);
- }
-
- /**
- * Receive notification of a comment.
- *
- * @see ExtendedLexicalHandler#comment(String)
- */
- public void comment(String comment) throws SAXException
- {
- flushPending();
-
- // Ignore if a lexical handler has not been set
- if (m_lexHandler != null)
- {
- final int len = comment.length();
- if (len > m_charsBuff.length)
- {
- m_charsBuff = new char[len*2 + 1];
- }
- comment.getChars(0,len, m_charsBuff, 0);
- m_lexHandler.comment(m_charsBuff, 0, len);
- // time to fire off comment event
- if (m_tracer != null)
- super.fireCommentEvent(m_charsBuff, 0, len);
- }
-
- }
-
- /**
- * Do nothing as this is an abstract class. All subclasses will need to
- * define their behavior if it is different.
- * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
- */
- public void processingInstruction(String target, String data)
- throws SAXException
- {
- // Redefined in SAXXMLOutput
- }
-
- protected void closeStartTag() throws SAXException
- {
- }
-
- protected void closeCDATA() throws SAXException
- {
- // Redefined in SAXXMLOutput
- }
-
- /**
- * Receive notification of the beginning of an element, although this is a
- * SAX method additional namespace or attribute information can occur before
- * or after this call, that is associated with this element.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see org.xml.sax.ContentHandler#startElement
- * @see org.xml.sax.ContentHandler#endElement
- * @see org.xml.sax.AttributeList
- *
- * @throws org.xml.sax.SAXException
- *
- * @see org.xml.sax.ContentHandler#startElement(String,String,String,Attributes)
- */
- public void startElement(
- String arg0,
- String arg1,
- String arg2,
- Attributes arg3)
- throws SAXException
- {
- if (m_state != null) {
- m_state.resetState(getTransformer());
- }
-
- // fire off the start element event
- if (m_tracer != null)
- super.fireStartElem(arg2);
- }
-
- /**
- * Sets the LexicalHandler.
- * @param _lexHandler The LexicalHandler to set
- */
- public void setLexHandler(LexicalHandler _lexHandler)
- {
- this.m_lexHandler = _lexHandler;
- }
-
- /**
- * Sets the SAX ContentHandler.
- * @param _saxHandler The ContentHandler to set
- */
- public void setContentHandler(ContentHandler _saxHandler)
- {
- this.m_saxHandler = _saxHandler;
- if (m_lexHandler == null && _saxHandler instanceof LexicalHandler)
- {
- // we are not overwriting an existing LexicalHandler, and _saxHandler
- // is also implements LexicalHandler, so lets use it
- m_lexHandler = (LexicalHandler) _saxHandler;
- }
- }
-
- /**
- * Does nothing. The setting of CDATA section elements has an impact on
- * stream serializers.
- * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
- */
- public void setCdataSectionElements(Vector URI_and_localNames)
- {
- // do nothing
- }
-
- /** Set whether or not namespace declarations (e.g.
- * xmlns:foo) should appear as attributes of
- * elements
- * @param doOutputNSAttr whether or not namespace declarations
- * should appear as attributes
- */
- public void setShouldOutputNSAttr(boolean doOutputNSAttr)
- {
- m_shouldGenerateNSAttribute = doOutputNSAttr;
- }
-
- /**
- * Returns true if namespace declarations from calls such as
- * startPrefixMapping("prefix1","uri1") should
- * also be mirrored with self generated additional attributes of elements
- * that declare the namespace, for example the attribute xmlns:prefix1="uri1"
- */
- boolean getShouldOutputNSAttr()
- {
- return m_shouldGenerateNSAttribute;
- }
-
- /**
- * This method flushes any pending events, which can be startDocument()
- * closing the opening tag of an element, or closing an open CDATA section.
- */
- public void flushPending() throws SAXException
- {
-
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
-
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- if (m_cdataTagOpen)
- {
- closeCDATA();
- m_cdataTagOpen = false;
- }
-
- }
-
- /**
- * Pass in a reference to a TransformState object, which
- * can be used during SAX ContentHandler events to obtain
- * information about he state of the transformation. This
- * method will be called before each startDocument event.
- *
- * @param ts A reference to a TransformState object
- */
- public void setTransformState(TransformStateSetter ts) {
- this.m_state = ts;
- }
-
- /**
- * Receives notification that an element starts, but attributes are not
- * fully known yet.
- *
- * @param uri the URI of the namespace of the element (optional)
- * @param localName the element name, but without prefix (optional)
- * @param qName the element name, with prefix, if any (required)
- *
- * @see ExtendedContentHandler#startElement(String, String, String)
- */
- public void startElement(String uri, String localName, String qName)
- throws SAXException {
-
- if (m_state != null) {
- m_state.resetState(getTransformer());
- }
-
- // fire off the start element event
- if (m_tracer != null)
- super.fireStartElem(qName);
- }
-
- /**
- * An element starts, but attributes are not fully known yet.
- *
- * @param qName the element name, with prefix (if any).
-
- * @see ExtendedContentHandler#startElement(String)
- */
- public void startElement(String qName) throws SAXException {
- if (m_state != null) {
- m_state.resetState(getTransformer());
- }
- // fire off the start element event
- if (m_tracer != null)
- super.fireStartElem(qName);
- }
-
- /**
- * This method gets the node's value as a String and uses that String as if
- * it were an input character notification.
- * @param node the Node to serialize
- * @throws org.xml.sax.SAXException
- */
- public void characters(org.w3c.dom.Node node)
- throws org.xml.sax.SAXException
- {
- // remember the current node
- if (m_state != null)
- {
- m_state.setCurrentNode(node);
- }
-
- // Get the node's value as a String and use that String as if
- // it were an input character notification.
- String data = node.getNodeValue();
- if (data != null) {
- this.characters(data);
- }
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#fatalError(SAXParseException)
- */
- public void fatalError(SAXParseException exc) throws SAXException {
- super.fatalError(exc);
-
- m_needToCallStartDocument = false;
-
- if (m_saxHandler instanceof ErrorHandler) {
- ((ErrorHandler)m_saxHandler).fatalError(exc);
- }
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#error(SAXParseException)
- */
- public void error(SAXParseException exc) throws SAXException {
- super.error(exc);
-
- if (m_saxHandler instanceof ErrorHandler)
- ((ErrorHandler)m_saxHandler).error(exc);
-
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#warning(SAXParseException)
- */
- public void warning(SAXParseException exc) throws SAXException {
- super.warning(exc);
-
- if (m_saxHandler instanceof ErrorHandler)
- ((ErrorHandler)m_saxHandler).warning(exc);
- }
-
-
- /**
- * Try's to reset the super class and reset this class for
- * re-use, so that you don't need to create a new serializer
- * (mostly for performance reasons).
- *
- * @return true if the class was successfuly reset.
- * @see Serializer#reset()
- */
- public boolean reset()
- {
- boolean wasReset = false;
- if (super.reset())
- {
- resetToSAXHandler();
- wasReset = true;
- }
- return wasReset;
- }
-
- /**
- * Reset all of the fields owned by ToSAXHandler class
- *
- */
- private void resetToSAXHandler()
- {
- this.m_lexHandler = null;
- this.m_saxHandler = null;
- this.m_state = null;
- this.m_shouldGenerateNSAttribute = false;
- }
-
- /**
- * Add a unique attribute
- */
- public void addUniqueAttribute(String qName, String value, int flags)
- throws SAXException
- {
- addAttribute(qName, value);
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,3336 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToStream.java,v 1.1.2.1 2007/01/09 18:57:20 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-import java.util.EmptyStackException;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.ajax4jsf.xml.serializer.utils.WrappedRuntimeException;
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-
-//import com.sun.media.sound.IESecurity;
-
-/**
- * This abstract class is a base class for other stream
- * serializers (xml, html, text ...) that write output to a stream.
- *
- * @xsl.usage internal
- */
-abstract public class ToStream extends SerializerBase
-{
-
- private static final String COMMENT_BEGIN = "<!--";
- private static final String COMMENT_END = "-->";
-
- /** Stack to keep track of disabling output escaping. */
- protected BoolStack m_disableOutputEscapingStates = new BoolStack();
-
-
- /**
- * The encoding information associated with this serializer.
- * Although initially there is no encoding,
- * there is a dummy EncodingInfo object that will say
- * that every character is in the encoding. This is useful
- * for a serializer that is in temporary output state and has
- * no associated encoding. A serializer in final output state
- * will have an encoding, and will worry about whether
- * single chars or surrogate pairs of high/low chars form
- * characters in the output encoding.
- */
- EncodingInfo m_encodingInfo = new EncodingInfo(null,null);
-
- /**
- * Stack to keep track of whether or not we need to
- * preserve whitespace.
- *
- * Used to push/pop values used for the field m_ispreserve, but
- * m_ispreserve is only relevant if m_doIndent is true.
- * If m_doIndent is false this field has no impact.
- *
- */
- protected BoolStack m_preserves = new BoolStack();
-
- /**
- * State flag to tell if preservation of whitespace
- * is important.
- *
- * Used only in shouldIndent() but only if m_doIndent is true.
- * If m_doIndent is false this flag has no impact.
- *
- */
- protected boolean m_ispreserve = false;
-
- /**
- * State flag that tells if the previous node processed
- * was text, so we can tell if we should preserve whitespace.
- *
- * Used in endDocument() and shouldIndent() but
- * only if m_doIndent is true.
- * If m_doIndent is false this flag has no impact.
- */
- protected boolean m_isprevtext = false;
-
-
- /**
- * The system line separator for writing out line breaks.
- * The default value is from the system property,
- * but this value can be set through the xsl:output
- * extension attribute xalan:line-separator.
- */
- protected char[] m_lineSep =
- System.getProperty("line.separator").toCharArray();
-
- /**
- * True if the the system line separator is to be used.
- */
- protected boolean m_lineSepUse = true;
-
- /**
- * The length of the line seperator, since the write is done
- * one character at a time.
- */
- protected int m_lineSepLen = m_lineSep.length;
-
- /**
- * Map that tells which characters should have special treatment, and it
- * provides character to entity name lookup.
- */
- protected CharInfo m_charInfo;
-
- /** True if we control the buffer, and we should flush the output on endDocument. */
- boolean m_shouldFlush = true;
-
- /**
- * Add space before '/>' for XHTML.
- */
- protected boolean m_spaceBeforeClose = false;
-
- /**
- * Flag to signal that a newline should be added.
- *
- * Used only in indent() which is called only if m_doIndent is true.
- * If m_doIndent is false this flag has no impact.
- */
- boolean m_startNewLine;
-
- /**
- * Tells if we're in an internal document type subset.
- */
- protected boolean m_inDoctype = false;
-
- /**
- * Flag to quickly tell if the encoding is UTF8.
- */
- boolean m_isUTF8 = false;
-
- /** The xsl:output properties. */
- protected Properties m_format;
-
- /**
- * remembers if we are in between the startCDATA() and endCDATA() callbacks
- */
- protected boolean m_cdataStartCalled = false;
-
- /**
- * If this flag is true DTD entity references are not left as-is,
- * which is exiting older behavior.
- */
- private boolean m_expandDTDEntities = true;
-
-
- /**
- * Default constructor
- */
- public ToStream()
- {
- }
-
- /**
- * This helper method to writes out "]]>" when closing a CDATA section.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void closeCDATA() throws org.xml.sax.SAXException
- {
- try
- {
- m_writer.write(CDATA_DELIMITER_CLOSE);
- // write out a CDATA section closing "]]>"
- m_cdataTagOpen = false; // Remember that we have done so.
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Serializes the DOM node. Throws an exception only if an I/O
- * exception occured while serializing.
- *
- * @param node Node to serialize.
- * @throws IOException An I/O exception occured while serializing
- */
- public void serialize(Node node) throws IOException
- {
-
- try
- {
- TreeWalker walker = new TreeWalker(this);
- // FIX for http://jira.jboss.com/jira/browse/AJSF-129
- if (m_needToCallStartDocument) {
- walker.traverse(node);
- } else {
- // Serialise without start/endDocument calls.
- walker.traverseFragment(node);
- }
- } catch (org.xml.sax.SAXException se) {
- throw new WrappedRuntimeException(se);
- }
- }
-
- /**
- * Taken from XSLTC
- */
- private boolean m_escaping = true;
-
- /**
- * Flush the formatter's result stream.
- *
- * @throws org.xml.sax.SAXException
- */
- protected final void flushWriter() throws org.xml.sax.SAXException
- {
- final java.io.Writer writer = m_writer;
- if (null != writer)
- {
- try
- {
- if (writer instanceof WriterToUTF8Buffered)
- {
- if (m_shouldFlush)
- ((WriterToUTF8Buffered) writer).flush();
- else
- ((WriterToUTF8Buffered) writer).flushBuffer();
- }
- if (writer instanceof WriterToASCI)
- {
- if (m_shouldFlush)
- writer.flush();
- }
- else
- {
- // Flush always.
- // Not a great thing if the writer was created
- // by this class, but don't have a choice.
- writer.flush();
- }
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(ioe);
- }
- }
- }
-
- /**
- * Get the output stream where the events will be serialized to.
- *
- * @return reference to the result stream, or null of only a writer was
- * set.
- */
- public OutputStream getOutputStream()
- {
-
- if (m_writer instanceof WriterToUTF8Buffered)
- return ((WriterToUTF8Buffered) m_writer).getOutputStream();
- if (m_writer instanceof WriterToASCI)
- return ((WriterToASCI) m_writer).getOutputStream();
- else
- return null;
- }
-
- // Implement DeclHandler
-
- /**
- * Report an element type declaration.
- *
- * <p>The content model will consist of the string "EMPTY", the
- * string "ANY", or a parenthesised group, optionally followed
- * by an occurrence indicator. The model will be normalized so
- * that all whitespace is removed,and will include the enclosing
- * parentheses.</p>
- *
- * @param name The element type name.
- * @param model The content model as a normalized string.
- * @exception SAXException The application may raise an exception.
- */
- public void elementDecl(String name, String model) throws SAXException
- {
- // Do not inline external DTD
- if (m_inExternalDTD)
- return;
- try
- {
- final java.io.Writer writer = m_writer;
- DTDprolog();
-
- writer.write("<!ELEMENT ");
- writer.write(name);
- writer.write(' ');
- writer.write(model);
- writer.write('>');
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- }
-
- /**
- * Report an internal entity declaration.
- *
- * <p>Only the effective (first) declaration for each entity
- * will be reported.</p>
- *
- * @param name The name of the entity. If it is a parameter
- * entity, the name will begin with '%'.
- * @param value The replacement text of the entity.
- * @exception SAXException The application may raise an exception.
- * @see #externalEntityDecl
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl
- */
- public void internalEntityDecl(String name, String value)
- throws SAXException
- {
- // Do not inline external DTD
- if (m_inExternalDTD)
- return;
- try
- {
- DTDprolog();
- outputEntityDecl(name, value);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- }
-
- /**
- * Output the doc type declaration.
- *
- * @param name non-null reference to document type name.
- * NEEDSDOC @param value
- *
- * @throws org.xml.sax.SAXException
- */
- void outputEntityDecl(String name, String value) throws IOException
- {
- final java.io.Writer writer = m_writer;
- writer.write("<!ENTITY ");
- writer.write(name);
- writer.write(" \"");
- writer.write(value);
- writer.write("\">");
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
-
- /**
- * Output a system-dependent line break.
- *
- * @throws org.xml.sax.SAXException
- */
- protected final void outputLineSep() throws IOException
- {
-
- m_writer.write(m_lineSep, 0, m_lineSepLen);
- }
-
- /**
- * Specifies an output format for this serializer. It the
- * serializer has already been associated with an output format,
- * it will switch to the new format. This method should not be
- * called while the serializer is in the process of serializing
- * a document.
- *
- * @param format The output format to use
- */
- public void setOutputFormat(Properties format)
- {
-
- boolean shouldFlush = m_shouldFlush;
-
- init(m_writer, format, false, false);
-
- m_shouldFlush = shouldFlush;
- }
-
- /**
- * Initialize the serializer with the specified writer and output format.
- * Must be called before calling any of the serialize methods.
- * This method can be called multiple times and the xsl:output properties
- * passed in the 'format' parameter are accumulated across calls.
- *
- * @param writer The writer to use
- * @param format The output format
- * @param shouldFlush True if the writer should be flushed at EndDocument.
- */
- private synchronized void init(
- Writer writer,
- Properties format,
- boolean defaultProperties,
- boolean shouldFlush)
- {
-
- m_shouldFlush = shouldFlush;
-
-
- // if we are tracing events we need to trace what
- // characters are written to the output writer.
- if (m_tracer != null
- && !(writer instanceof SerializerTraceWriter) )
- m_writer = new SerializerTraceWriter(writer, m_tracer);
- else
- m_writer = writer;
-
-
- m_format = format;
- // m_cdataSectionNames =
- // OutputProperties.getQNameProperties(
- // OutputKeys.CDATA_SECTION_ELEMENTS,
- // format);
- setCdataSectionElements(OutputKeys.CDATA_SECTION_ELEMENTS, format);
-
- setIndentAmount(
- OutputPropertyUtils.getIntProperty(
- OutputPropertiesFactory.S_KEY_INDENT_AMOUNT,
- format));
- setIndent(
- OutputPropertyUtils.getBooleanProperty(OutputKeys.INDENT, format));
-
- {
- String sep =
- format.getProperty(OutputPropertiesFactory.S_KEY_LINE_SEPARATOR);
- if (sep != null) {
- m_lineSep = sep.toCharArray();
- m_lineSepLen = sep.length();
- }
- }
-
- boolean shouldNotWriteXMLHeader =
- OutputPropertyUtils.getBooleanProperty(
- OutputKeys.OMIT_XML_DECLARATION,
- format);
- setOmitXMLDeclaration(shouldNotWriteXMLHeader);
- setDoctypeSystem(format.getProperty(OutputKeys.DOCTYPE_SYSTEM));
- String doctypePublic = format.getProperty(OutputKeys.DOCTYPE_PUBLIC);
- setDoctypePublic(doctypePublic);
-
- // if standalone was explicitly specified
- if (format.get(OutputKeys.STANDALONE) != null)
- {
- String val = format.getProperty(OutputKeys.STANDALONE);
- if (defaultProperties)
- setStandaloneInternal(val);
- else
- setStandalone(val);
- }
-
- setMediaType(format.getProperty(OutputKeys.MEDIA_TYPE));
-
- if (null != doctypePublic)
- {
- if (doctypePublic.startsWith("-//W3C//DTD XHTML"))
- m_spaceBeforeClose = true;
- }
-
- /*
- * This code is added for XML 1.1 Version output.
- */
- String version = getVersion();
- if (null == version)
- {
- version = format.getProperty(OutputKeys.VERSION);
- setVersion(version);
- }
-
- // initCharsMap();
- String encoding = getEncoding();
- if (null == encoding)
- {
- encoding =
- Encodings.getMimeEncoding(
- format.getProperty(OutputKeys.ENCODING));
- setEncoding(encoding);
- }
-
- m_isUTF8 = encoding.equals(Encodings.DEFAULT_MIME_ENCODING);
-
- // Access this only from the Hashtable level... we don't want to
- // get default properties.
- String entitiesFileName =
- (String) format.get(OutputPropertiesFactory.S_KEY_ENTITIES);
-
- if (null != entitiesFileName)
- {
-
- String method =
- (String) format.get(OutputKeys.METHOD);
-
- m_charInfo = CharInfo.getCharInfo(entitiesFileName, method);
- }
-
- }
-
- /**
- * Initialize the serializer with the specified writer and output format.
- * Must be called before calling any of the serialize methods.
- *
- * @param writer The writer to use
- * @param format The output format
- */
- private synchronized void init(Writer writer, Properties format)
- {
- init(writer, format, false, false);
- }
- /**
- * Initialize the serializer with the specified output stream and output
- * format. Must be called before calling any of the serialize methods.
- *
- * @param output The output stream to use
- * @param format The output format
- * @param defaultProperties true if the properties are the default
- * properties
- *
- * @throws UnsupportedEncodingException The encoding specified in the
- * output format is not supported
- */
- protected synchronized void init(
- OutputStream output,
- Properties format,
- boolean defaultProperties)
- throws UnsupportedEncodingException
- {
-
- String encoding = getEncoding();
- if (encoding == null)
- {
- // if not already set then get it from the properties
- encoding =
- Encodings.getMimeEncoding(
- format.getProperty(OutputKeys.ENCODING));
- setEncoding(encoding);
- }
-
- if (encoding.equalsIgnoreCase("UTF-8"))
- {
- m_isUTF8 = true;
- // if (output instanceof java.io.BufferedOutputStream)
- // {
- // init(new WriterToUTF8(output), format, defaultProperties, true);
- // }
- // else if (output instanceof java.io.FileOutputStream)
- // {
- // init(new WriterToUTF8Buffered(output), format, defaultProperties, true);
- // }
- // else
- // {
- // // Not sure what to do in this case. I'm going to be conservative
- // // and not buffer.
- // init(new WriterToUTF8(output), format, defaultProperties, true);
- // }
-
-
- init(
- new WriterToUTF8Buffered(output),
- format,
- defaultProperties,
- true);
-
-
- }
- else if (
- encoding.equals("WINDOWS-1250")
- || encoding.equals("US-ASCII")
- || encoding.equals("ASCII"))
- {
- init(new WriterToASCI(output), format, defaultProperties, true);
- }
- else
- {
- Writer osw;
-
- try
- {
- osw = Encodings.getWriter(output, encoding);
- }
- catch (UnsupportedEncodingException uee)
- {
- System.out.println(
- "Warning: encoding \""
- + encoding
- + "\" not supported"
- + ", using "
- + Encodings.DEFAULT_MIME_ENCODING);
-
- encoding = Encodings.DEFAULT_MIME_ENCODING;
- setEncoding(encoding);
- osw = Encodings.getWriter(output, encoding);
- }
-
- init(osw, format, defaultProperties, true);
- }
-
- }
-
- /**
- * Returns the output format for this serializer.
- *
- * @return The output format in use
- */
- public Properties getOutputFormat()
- {
- return m_format;
- }
-
- /**
- * Specifies a writer to which the document should be serialized.
- * This method should not be called while the serializer is in
- * the process of serializing a document.
- *
- * @param writer The output writer stream
- */
- public void setWriter(Writer writer)
- {
- // if we are tracing events we need to trace what
- // characters are written to the output writer.
- if (m_tracer != null
- && !(writer instanceof SerializerTraceWriter) )
- m_writer = new SerializerTraceWriter(writer, m_tracer);
- else
- m_writer = writer;
- }
-
- /**
- * Set if the operating systems end-of-line line separator should
- * be used when serializing. If set false NL character
- * (decimal 10) is left alone, otherwise the new-line will be replaced on
- * output with the systems line separator. For example on UNIX this is
- * NL, while on Windows it is two characters, CR NL, where CR is the
- * carriage-return (decimal 13).
- *
- * @param use_sytem_line_break True if an input NL is replaced with the
- * operating systems end-of-line separator.
- * @return The previously set value of the serializer.
- */
- public boolean setLineSepUse(boolean use_sytem_line_break)
- {
- boolean oldValue = m_lineSepUse;
- m_lineSepUse = use_sytem_line_break;
- return oldValue;
- }
-
- /**
- * Specifies an output stream to which the document should be
- * serialized. This method should not be called while the
- * serializer is in the process of serializing a document.
- * <p>
- * The encoding specified in the output properties is used, or
- * if no encoding was specified, the default for the selected
- * output method.
- *
- * @param output The output stream
- */
- public void setOutputStream(OutputStream output)
- {
-
- try
- {
- Properties format;
- if (null == m_format)
- format =
- OutputPropertiesFactory.getDefaultMethodProperties(
- Method.XML);
- else
- format = m_format;
- init(output, format, true);
- }
- catch (UnsupportedEncodingException uee)
- {
-
- // Should have been warned in init, I guess...
- }
- }
-
- /**
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape)
- {
- final boolean temp = m_escaping;
- m_escaping = escape;
- return temp;
-
- }
-
-
- /**
- * Might print a newline character and the indentation amount
- * of the given depth.
- *
- * @param depth the indentation depth (element nesting depth)
- *
- * @throws org.xml.sax.SAXException if an error occurs during writing.
- */
- protected void indent(int depth) throws IOException
- {
-
- if (m_startNewLine)
- outputLineSep();
- /* For m_indentAmount > 0 this extra test might be slower
- * but Xalan's default value is 0, so this extra test
- * will run faster in that situation.
- */
- if (m_indentAmount > 0)
- printSpace(depth * m_indentAmount);
-
- }
-
- /**
- * Indent at the current element nesting depth.
- * @throws IOException
- */
- protected void indent() throws IOException
- {
- indent(m_elemContext.m_currentElemDepth);
- }
- /**
- * Prints <var>n</var> spaces.
- * @param n Number of spaces to print.
- *
- * @throws org.xml.sax.SAXException if an error occurs when writing.
- */
- private void printSpace(int n) throws IOException
- {
- final java.io.Writer writer = m_writer;
- for (int i = 0; i < n; i++)
- {
- writer.write(' ');
- }
-
- }
-
- /**
- * Report an attribute type declaration.
- *
- * <p>Only the effective (first) declaration for an attribute will
- * be reported. The type will be one of the strings "CDATA",
- * "ID", "IDREF", "IDREFS", "NMTOKEN", "NMTOKENS", "ENTITY",
- * "ENTITIES", or "NOTATION", or a parenthesized token group with
- * the separator "|" and all whitespace removed.</p>
- *
- * @param eName The name of the associated element.
- * @param aName The name of the attribute.
- * @param type A string representing the attribute type.
- * @param valueDefault A string representing the attribute default
- * ("#IMPLIED", "#REQUIRED", or "#FIXED") or null if
- * none of these applies.
- * @param value A string representing the attribute's default value,
- * or null if there is none.
- * @exception SAXException The application may raise an exception.
- */
- public void attributeDecl(
- String eName,
- String aName,
- String type,
- String valueDefault,
- String value)
- throws SAXException
- {
- // Do not inline external DTD
- if (m_inExternalDTD)
- return;
- try
- {
- final java.io.Writer writer = m_writer;
- DTDprolog();
-
- writer.write("<!ATTLIST ");
- writer.write(eName);
- writer.write(' ');
-
- writer.write(aName);
- writer.write(' ');
- writer.write(type);
- if (valueDefault != null)
- {
- writer.write(' ');
- writer.write(valueDefault);
- }
-
- //writer.write(" ");
- //writer.write(value);
- writer.write('>');
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Get the character stream where the events will be serialized to.
- *
- * @return Reference to the result Writer, or null.
- */
- public Writer getWriter()
- {
- return m_writer;
- }
-
- /**
- * Report a parsed external entity declaration.
- *
- * <p>Only the effective (first) declaration for each entity
- * will be reported.</p>
- *
- * @param name The name of the entity. If it is a parameter
- * entity, the name will begin with '%'.
- * @param publicId The declared public identifier of the entity, or
- * null if none was declared.
- * @param systemId The declared system identifier of the entity.
- * @exception SAXException The application may raise an exception.
- * @see #internalEntityDecl
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl
- */
- public void externalEntityDecl(
- String name,
- String publicId,
- String systemId)
- throws SAXException
- {
- try {
- DTDprolog();
-
- m_writer.write("<!ENTITY ");
- m_writer.write(name);
- if (publicId != null) {
- m_writer.write(" PUBLIC \"");
- m_writer.write(publicId);
-
- }
- else {
- m_writer.write(" SYSTEM \"");
- m_writer.write(systemId);
- }
- m_writer.write("\" >");
- m_writer.write(m_lineSep, 0, m_lineSepLen);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- /**
- * Tell if this character can be written without escaping.
- */
- protected boolean escapingNotNeeded(char ch)
- {
- final boolean ret;
- if (ch < 127)
- {
- // This is the old/fast code here, but is this
- // correct for all encodings?
- if (ch >= 0x20 || (0x0A == ch || 0x0D == ch || 0x09 == ch))
- ret= true;
- else
- ret = false;
- }
- else {
- ret = m_encodingInfo.isInEncoding(ch);
- }
- return ret;
- }
-
- /**
- * Once a surrogate has been detected, write out the pair of
- * characters if it is in the encoding, or if there is no
- * encoding, otherwise write out an entity reference
- * of the value of the unicode code point of the character
- * represented by the high/low surrogate pair.
- * <p>
- * An exception is thrown if there is no low surrogate in the pair,
- * because the array ends unexpectely, or if the low char is there
- * but its value is such that it is not a low surrogate.
- *
- * @param c the first (high) part of the surrogate, which
- * must be confirmed before calling this method.
- * @param ch Character array.
- * @param i position Where the surrogate was detected.
- * @param end The end index of the significant characters.
- * @return 0 if the pair of characters was written out as-is,
- * the unicode code point of the character represented by
- * the surrogate pair if an entity reference with that value
- * was written out.
- *
- * @throws IOException
- * @throws org.xml.sax.SAXException if invalid UTF-16 surrogate detected.
- */
- protected int writeUTF16Surrogate(char c, char ch[], int i, int end)
- throws IOException
- {
- int codePoint = 0;
- if (i + 1 >= end)
- {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] { Integer.toHexString((int) c)}));
- }
-
- final char high = c;
- final char low = ch[i+1];
- if (!Encodings.isLowUTF16Surrogate(low)) {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] {
- Integer.toHexString((int) c)
- + " "
- + Integer.toHexString(low)}));
- }
-
- final java.io.Writer writer = m_writer;
-
- // If we make it to here we have a valid high, low surrogate pair
- if (m_encodingInfo.isInEncoding(c,low)) {
- // If the character formed by the surrogate pair
- // is in the encoding, so just write it out
- writer.write(ch,i,2);
- }
- else {
- // Don't know what to do with this char, it is
- // not in the encoding and not a high char in
- // a surrogate pair, so write out as an entity ref
- final String encoding = getEncoding();
- if (encoding != null) {
- /* The output encoding is known,
- * so somthing is wrong.
- */
- codePoint = Encodings.toCodePoint(high, low);
- // not in the encoding, so write out a character reference
- writer.write('&');
- writer.write('#');
- writer.write(Integer.toString(codePoint));
- writer.write(';');
- } else {
- /* The output encoding is not known,
- * so just write it out as-is.
- */
- writer.write(ch, i, 2);
- }
- }
- // non-zero only if character reference was written out.
- return codePoint;
- }
-
- /**
- * Handle one of the default entities, return false if it
- * is not a default entity.
- *
- * @param ch character to be escaped.
- * @param i index into character array.
- * @param chars non-null reference to character array.
- * @param len length of chars.
- * @param fromTextNode true if the characters being processed
- * are from a text node, false if they are from an attribute value
- * @param escLF true if the linefeed should be escaped.
- *
- * @return i+1 if the character was written, else i.
- *
- * @throws java.io.IOException
- */
- protected int accumDefaultEntity(
- java.io.Writer writer,
- char ch,
- int i,
- char[] chars,
- int len,
- boolean fromTextNode,
- boolean escLF)
- throws IOException
- {
-
- if (!escLF && CharInfo.S_LINEFEED == ch)
- {
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- else
- {
- // if this is text node character and a special one of those,
- // or if this is a character from attribute value and a special one of those
- if ((fromTextNode && m_charInfo.isSpecialTextChar(ch)) || (!fromTextNode && m_charInfo.isSpecialAttrChar(ch)))
- {
- String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
-
- if (null != outputStringForChar)
- {
- writer.write(outputStringForChar);
- }
- else
- return i;
- }
- else
- return i;
- }
-
- return i + 1;
-
- }
- /**
- * Normalize the characters, but don't escape.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @param isCData true if a CDATA block should be built around the characters.
- * @param useSystemLineSeparator true if the operating systems
- * end-of-line separator should be output rather than a new-line character.
- *
- * @throws IOException
- * @throws org.xml.sax.SAXException
- */
- void writeNormalizedChars(
- char ch[],
- int start,
- int length,
- boolean isCData,
- boolean useSystemLineSeparator)
- throws IOException, org.xml.sax.SAXException
- {
- final java.io.Writer writer = m_writer;
- int end = start + length;
-
- for (int i = start; i < end; i++)
- {
- char c = ch[i];
-
- if (CharInfo.S_LINEFEED == c && useSystemLineSeparator)
- {
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- else if (isCData && (!escapingNotNeeded(c)))
- {
- // if (i != 0)
- if (m_cdataTagOpen)
- closeCDATA();
-
- // This needs to go into a function...
- if (Encodings.isHighUTF16Surrogate(c))
- {
- writeUTF16Surrogate(c, ch, i, end);
- i++ ; // process two input characters
- }
- else
- {
- writer.write("&#");
-
- String intStr = Integer.toString((int) c);
-
- writer.write(intStr);
- writer.write(';');
- }
-
- // if ((i != 0) && (i < (end - 1)))
- // if (!m_cdataTagOpen && (i < (end - 1)))
- // {
- // writer.write(CDATA_DELIMITER_OPEN);
- // m_cdataTagOpen = true;
- // }
- }
- else if (
- isCData
- && ((i < (end - 2))
- && (']' == c)
- && (']' == ch[i + 1])
- && ('>' == ch[i + 2])))
- {
- writer.write(CDATA_CONTINUE);
-
- i += 2;
- }
- else
- {
- if (escapingNotNeeded(c))
- {
- if (isCData && !m_cdataTagOpen)
- {
- writer.write(CDATA_DELIMITER_OPEN);
- m_cdataTagOpen = true;
- }
- writer.write(c);
- }
-
- // This needs to go into a function...
- else if (Encodings.isHighUTF16Surrogate(c))
- {
- if (m_cdataTagOpen)
- closeCDATA();
- writeUTF16Surrogate(c, ch, i, end);
- i++; // process two input characters
- }
- else
- {
- if (m_cdataTagOpen)
- closeCDATA();
- writer.write("&#");
-
- String intStr = Integer.toString((int) c);
-
- writer.write(intStr);
- writer.write(';');
- }
- }
- }
-
- }
-
- /**
- * Ends an un-escaping section.
- *
- * @see #startNonEscaping
- *
- * @throws org.xml.sax.SAXException
- */
- public void endNonEscaping() throws org.xml.sax.SAXException
- {
- m_disableOutputEscapingStates.pop();
- }
-
- /**
- * Starts an un-escaping section. All characters printed within an un-
- * escaping section are printed as is, without escaping special characters
- * into entity references. Only XML and HTML serializers need to support
- * this method.
- * <p> The contents of the un-escaping section will be delivered through the
- * regular <tt>characters</tt> event.
- *
- * @throws org.xml.sax.SAXException
- */
- public void startNonEscaping() throws org.xml.sax.SAXException
- {
- m_disableOutputEscapingStates.push(true);
- }
-
- /**
- * Receive notification of cdata.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- protected void cdata(char ch[], int start, final int length)
- throws org.xml.sax.SAXException
- {
-
- try
- {
- final int old_start = start;
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- m_ispreserve = true;
-
- if (shouldIndent())
- indent();
-
- boolean writeCDataBrackets =
- (((length >= 1) && escapingNotNeeded(ch[start])));
-
- /* Write out the CDATA opening delimiter only if
- * we are supposed to, and if we are not already in
- * the middle of a CDATA section
- */
- if (writeCDataBrackets && !m_cdataTagOpen)
- {
- m_writer.write(CDATA_DELIMITER_OPEN);
- m_cdataTagOpen = true;
- }
-
- // writer.write(ch, start, length);
- if (isEscapingDisabled())
- {
- charactersRaw(ch, start, length);
- }
- else
- writeNormalizedChars(ch, start, length, true, m_lineSepUse);
-
- /* used to always write out CDATA closing delimiter here,
- * but now we delay, so that we can merge CDATA sections on output.
- * need to write closing delimiter later
- */
- if (writeCDataBrackets)
- {
- /* if the CDATA section ends with ] don't leave it open
- * as there is a chance that an adjacent CDATA sections
- * starts with ]>.
- * We don't want to merge ]] with > , or ] with ]>
- */
- if (ch[start + length - 1] == ']')
- closeCDATA();
- }
-
- // time to fire off CDATA event
- if (m_tracer != null)
- super.fireCDATAEvent(ch, old_start, length);
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(
- Utils.messages.createMessage(
- MsgKey.ER_OIERROR,
- null),
- ioe);
- //"IO error", ioe);
- }
- }
-
- /**
- * Tell if the character escaping should be disabled for the current state.
- *
- * @return true if the character escaping should be disabled.
- */
- private boolean isEscapingDisabled()
- {
- return m_disableOutputEscapingStates.peekOrFalse();
- }
-
- /**
- * If available, when the disable-output-escaping attribute is used,
- * output raw text without escaping.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void charactersRaw(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if (m_inEntityRef)
- return;
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- m_ispreserve = true;
-
- m_writer.write(ch, start, length);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- }
-
- /**
- * Receive notification of character data.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param chars The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- public void characters(final char chars[], final int start, final int length)
- throws org.xml.sax.SAXException
- {
- // It does not make sense to continue with rest of the method if the number of
- // characters to read from array is 0.
- // Section 7.6.1 of XSLT 1.0 (http://www.w3.org/TR/xslt#value-of) suggest no text node
- // is created if string is empty.
- if (length == 0 || (m_inEntityRef && !m_expandDTDEntities))
- return;
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- }
-
- if (m_cdataStartCalled || m_elemContext.m_isCdataSection)
- {
- /* either due to startCDATA() being called or due to
- * cdata-section-elements atribute, we need this as cdata
- */
- cdata(chars, start, length);
-
- return;
- }
-
- if (m_cdataTagOpen)
- closeCDATA();
- // the check with _escaping is a bit of a hack for XLSTC
-
- if (m_disableOutputEscapingStates.peekOrFalse() || (!m_escaping))
- {
- charactersRaw(chars, start, length);
-
- // time to fire off characters generation event
- if (m_tracer != null)
- super.fireCharEvent(chars, start, length);
-
- return;
- }
-
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
-
- try
- {
- int i;
- char ch1;
- int startClean;
-
- // skip any leading whitspace
- // don't go off the end and use a hand inlined version
- // of isWhitespace(ch)
- final int end = start + length;
- int lastDirty = start - 1; // last character that needed processing
- for (i = start;
- ((i < end)
- && ((ch1 = chars[i]) == 0x20
- || (ch1 == 0xA && m_lineSepUse)
- || ch1 == 0xD
- || ch1 == 0x09));
- i++)
- {
- /*
- * We are processing leading whitespace, but are doing the same
- * processing for dirty characters here as for non-whitespace.
- *
- */
- if (!m_charInfo.isTextASCIIClean(ch1))
- {
- lastDirty = processDirty(chars,end, i,ch1, lastDirty, true);
- i = lastDirty;
- }
- }
- /* If there is some non-whitespace, mark that we may need
- * to preserve this. This is only important if we have indentation on.
- */
- if (i < end)
- m_ispreserve = true;
-
-
-// int lengthClean; // number of clean characters in a row
-// final boolean[] isAsciiClean = m_charInfo.getASCIIClean();
-
- final boolean isXML10 = XMLVERSION10.equals(getVersion());
- // we've skipped the leading whitespace, now deal with the rest
- for (; i < end; i++)
- {
- {
- // A tight loop to skip over common clean chars
- // This tight loop makes it easier for the JIT
- // to optimize.
- char ch2;
- while (i<end
- && ((ch2 = chars[i])<127)
- && m_charInfo.isTextASCIIClean(ch2))
- i++;
- if (i == end)
- break;
- }
-
- final char ch = chars[i];
- /* The check for isCharacterInC0orC1Ranger and
- * isNELorLSEPCharacter has been added
- * to support Control Characters in XML 1.1
- */
- if (!isCharacterInC0orC1Range(ch) &&
- (isXML10 || !isNELorLSEPCharacter(ch)) &&
- (escapingNotNeeded(ch) && (!m_charInfo.isSpecialTextChar(ch)))
- || ('"' == ch))
- {
- ; // a character needing no special processing
- }
- else
- {
- lastDirty = processDirty(chars,end, i, ch, lastDirty, true);
- i = lastDirty;
- }
- }
-
- // we've reached the end. Any clean characters at the
- // end of the array than need to be written out?
- startClean = lastDirty + 1;
- if (i > startClean)
- {
- int lengthClean = i - startClean;
- m_writer.write(chars, startClean, lengthClean);
- }
-
- // For indentation purposes, mark that we've just writen text out
- m_isprevtext = true;
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- // time to fire off characters generation event
- if (m_tracer != null)
- super.fireCharEvent(chars, start, length);
- }
- /**
- * This method checks if a given character is between C0 or C1 range
- * of Control characters.
- * This method is added to support Control Characters for XML 1.1
- * If a given character is TAB (0x09), LF (0x0A) or CR (0x0D), this method
- * return false. Since they are whitespace characters, no special processing is needed.
- *
- * @param ch
- * @return boolean
- */
- private static boolean isCharacterInC0orC1Range(char ch)
- {
- if(ch == 0x09 || ch == 0x0A || ch == 0x0D)
- return false;
- else
- return (ch >= 0x7F && ch <= 0x9F)|| (ch >= 0x01 && ch <= 0x1F);
- }
- /**
- * This method checks if a given character either NEL (0x85) or LSEP (0x2028)
- * These are new end of line charcters added in XML 1.1. These characters must be
- * written as Numeric Character References (NCR) in XML 1.1 output document.
- *
- * @param ch
- * @return boolean
- */
- private static boolean isNELorLSEPCharacter(char ch)
- {
- return (ch == 0x85 || ch == 0x2028);
- }
- /**
- * Process a dirty character and any preeceding clean characters
- * that were not yet processed.
- * @param chars array of characters being processed
- * @param end one (1) beyond the last character
- * in chars to be processed
- * @param i the index of the dirty character
- * @param ch the character in chars[i]
- * @param lastDirty the last dirty character previous to i
- * @param fromTextNode true if the characters being processed are
- * from a text node, false if they are from an attribute value.
- * @return the index of the last character processed
- */
- private int processDirty(
- char[] chars,
- int end,
- int i,
- char ch,
- int lastDirty,
- boolean fromTextNode) throws IOException
- {
- int startClean = lastDirty + 1;
- // if we have some clean characters accumulated
- // process them before the dirty one.
- if (i > startClean)
- {
- int lengthClean = i - startClean;
- m_writer.write(chars, startClean, lengthClean);
- }
-
- // process the "dirty" character
- if (CharInfo.S_LINEFEED == ch && fromTextNode)
- {
- m_writer.write(m_lineSep, 0, m_lineSepLen);
- }
- else
- {
- startClean =
- accumDefaultEscape(
- m_writer,
- (char)ch,
- i,
- chars,
- end,
- fromTextNode,
- false);
- i = startClean - 1;
- }
- // Return the index of the last character that we just processed
- // which is a dirty character.
- return i;
- }
-
- /**
- * Receive notification of character data.
- *
- * @param s The string of characters to process.
- *
- * @throws org.xml.sax.SAXException
- */
- public void characters(String s) throws org.xml.sax.SAXException
- {
- if (m_inEntityRef && !m_expandDTDEntities)
- return;
- final int length = s.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length * 2 + 1];
- }
- s.getChars(0, length, m_charsBuff, 0);
- characters(m_charsBuff, 0, length);
- }
-
- /**
- * Escape and writer.write a character.
- *
- * @param ch character to be escaped.
- * @param i index into character array.
- * @param chars non-null reference to character array.
- * @param len length of chars.
- * @param fromTextNode true if the characters being processed are
- * from a text node, false if the characters being processed are from
- * an attribute value.
- * @param escLF true if the linefeed should be escaped.
- *
- * @return i+1 if a character was written, i+2 if two characters
- * were written out, else return i.
- *
- * @throws org.xml.sax.SAXException
- */
- protected int accumDefaultEscape(
- Writer writer,
- char ch,
- int i,
- char[] chars,
- int len,
- boolean fromTextNode,
- boolean escLF)
- throws IOException
- {
-
- int pos = accumDefaultEntity(writer, ch, i, chars, len, fromTextNode, escLF);
-
- if (i == pos)
- {
- if (Encodings.isHighUTF16Surrogate(ch))
- {
-
- // Should be the UTF-16 low surrogate of the hig/low pair.
- char next;
- // Unicode code point formed from the high/low pair.
- int codePoint = 0;
-
- if (i + 1 >= len)
- {
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey.ER_INVALID_UTF16_SURROGATE,
- new Object[] { Integer.toHexString(ch)}));
- //"Invalid UTF-16 surrogate detected: "
-
- //+Integer.toHexString(ch)+ " ?");
- }
- else
- {
- next = chars[++i];
-
- if (!(Encodings.isLowUTF16Surrogate(next)))
- throw new IOException(
- Utils.messages.createMessage(
- MsgKey
- .ER_INVALID_UTF16_SURROGATE,
- new Object[] {
- Integer.toHexString(ch)
- + " "
- + Integer.toHexString(next)}));
- //"Invalid UTF-16 surrogate detected: "
-
- //+Integer.toHexString(ch)+" "+Integer.toHexString(next));
- codePoint = Encodings.toCodePoint(ch,next);
- }
-
- writer.write("&#");
- writer.write(Integer.toString(codePoint));
- writer.write(';');
- pos += 2; // count the two characters that went into writing out this entity
- }
- else
- {
- /* This if check is added to support control characters in XML 1.1.
- * If a character is a Control Character within C0 and C1 range, it is desirable
- * to write it out as Numeric Character Reference(NCR) regardless of XML Version
- * being used for output document.
- */
- if (isCharacterInC0orC1Range(ch) ||
- (XMLVERSION11.equals(getVersion()) && isNELorLSEPCharacter(ch)))
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- else if ((!escapingNotNeeded(ch) ||
- ( (fromTextNode && m_charInfo.isSpecialTextChar(ch))
- || (!fromTextNode && m_charInfo.isSpecialAttrChar(ch))))
- && m_elemContext.m_currentElemDepth > 0)
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- else
- {
- writer.write(ch);
- }
- pos++; // count the single character that was processed
- }
-
- }
- return pos;
- }
-
- /**
- * Receive notification of the beginning of an element, although this is a
- * SAX method additional namespace or attribute information can occur before
- * or after this call, that is associated with this element.
- *
- *
- * @param namespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param name The element type name.
- * @param atts The attributes attached to the element, if any.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see org.xml.sax.ContentHandler#startElement
- * @see org.xml.sax.ContentHandler#endElement
- * @see org.xml.sax.AttributeList
- *
- * @throws org.xml.sax.SAXException
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String name,
- Attributes atts)
- throws org.xml.sax.SAXException
- {
- if (m_inEntityRef)
- return;
-
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
- else if (m_cdataTagOpen)
- closeCDATA();
- try
- {
- if ((true == m_needToOutputDocTypeDecl)
- && (null != getDoctypeSystem()))
- {
- outputDocTypeDecl(name, true);
- }
-
- m_needToOutputDocTypeDecl = false;
-
- /* before we over-write the current elementLocalName etc.
- * lets close out the old one (if we still need to)
- */
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- if (namespaceURI != null)
- ensurePrefixIsDeclared(namespaceURI, name);
-
- m_ispreserve = false;
-
- if (shouldIndent() && m_startNewLine)
- {
- indent();
- }
-
- m_startNewLine = true;
-
- final java.io.Writer writer = m_writer;
- writer.write('<');
- writer.write(name);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- // process the attributes now, because after this SAX call they might be gone
- if (atts != null)
- addAttributes(atts);
-
- m_elemContext = m_elemContext.push(namespaceURI,localName,name);
- m_isprevtext = false;
-
- if (m_tracer != null)
- firePseudoAttributes();
- }
-
- /**
- * Receive notification of the beginning of an element, additional
- * namespace or attribute information can occur before or after this call,
- * that is associated with this element.
- *
- *
- * @param elementNamespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param elementLocalName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param elementName The element type name.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see org.xml.sax.ContentHandler#startElement
- * @see org.xml.sax.ContentHandler#endElement
- * @see org.xml.sax.AttributeList
- *
- * @throws org.xml.sax.SAXException
- */
- public void startElement(
- String elementNamespaceURI,
- String elementLocalName,
- String elementName)
- throws SAXException
- {
- startElement(elementNamespaceURI, elementLocalName, elementName, null);
- }
-
- public void startElement(String elementName) throws SAXException
- {
- startElement(null, null, elementName, null);
- }
-
- /**
- * Output the doc type declaration.
- *
- * @param name non-null reference to document type name.
- * NEEDSDOC @param closeDecl
- *
- * @throws java.io.IOException
- */
- void outputDocTypeDecl(String name, boolean closeDecl) throws SAXException
- {
- if (m_cdataTagOpen)
- closeCDATA();
- try
- {
- final java.io.Writer writer = m_writer;
- writer.write("<!DOCTYPE ");
- writer.write(name);
-
- String doctypePublic = getDoctypePublic();
- if (null != doctypePublic)
- {
- writer.write(" PUBLIC \"");
- writer.write(doctypePublic);
- writer.write('\"');
- }
-
- String doctypeSystem = getDoctypeSystem();
- if (null != doctypeSystem)
- {
- if (null == doctypePublic)
- writer.write(" SYSTEM \"");
- else
- writer.write(" \"");
-
- writer.write(doctypeSystem);
-
- if (closeDecl)
- {
- writer.write("\">");
- writer.write(m_lineSep, 0, m_lineSepLen);
- closeDecl = false; // done closing
- }
- else
- writer.write('\"');
- }
- boolean dothis = false;
- if (dothis)
- {
- // at one point this code seemed right,
- // but not anymore - Brian M.
- if (closeDecl)
- {
- writer.write('>');
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- }
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Process the attributes, which means to write out the currently
- * collected attributes to the writer. The attributes are not
- * cleared by this method
- *
- * @param writer the writer to write processed attributes to.
- * @param nAttrs the number of attributes in m_attributes
- * to be processed
- *
- * @throws java.io.IOException
- * @throws org.xml.sax.SAXException
- */
- public void processAttributes(java.io.Writer writer, int nAttrs) throws IOException, SAXException
- {
- /* real SAX attributes are not passed in, so process the
- * attributes that were collected after the startElement call.
- * _attribVector is a "cheap" list for Stream serializer output
- * accumulated over a series of calls to attribute(name,value)
- */
-
- String encoding = getEncoding();
- for (int i = 0; i < nAttrs; i++)
- {
- // elementAt is JDK 1.1.8
- final String name = m_attributes.getQName(i);
- final String value = m_attributes.getValue(i);
- writer.write(' ');
- writer.write(name);
- writer.write("=\"");
- writeAttrString(writer, value, encoding);
- writer.write('\"');
- }
- }
-
- /**
- * Returns the specified <var>string</var> after substituting <VAR>specials</VAR>,
- * and UTF-16 surrogates for chracter references <CODE>&#xnn</CODE>.
- *
- * @param string String to convert to XML format.
- * @param encoding CURRENTLY NOT IMPLEMENTED.
- *
- * @throws java.io.IOException
- */
- public void writeAttrString(
- Writer writer,
- String string,
- String encoding)
- throws IOException
- {
- final int len = string.length();
- if (len > m_attrBuff.length)
- {
- m_attrBuff = new char[len*2 + 1];
- }
- string.getChars(0,len, m_attrBuff, 0);
- final char[] stringChars = m_attrBuff;
-
- int start = 0;
- int current = 0;
- for (; current < len; current++)
- {
- char ch = stringChars[current];
- if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch)))
- {
-// writer.write(ch);
- }
- else
- { // I guess the parser doesn't normalize cr/lf in attributes. -sb
-// if ((CharInfo.S_CARRIAGERETURN == ch)
-// && ((i + 1) < len)
-// && (CharInfo.S_LINEFEED == stringChars[i + 1]))
-// {
-// i++;
-// ch = CharInfo.S_LINEFEED;
-// }
-
- // Write buffer
- if(start < current){
- writer.write(stringChars,start,current-start);
- }
- accumDefaultEscape(writer, ch, current, stringChars, len, false, true);
- start=current+1;
- }
- }
- if(start < current){
- writer.write(stringChars,start,current-start);
- }
-
- }
-
- /**
- * Receive notification of the end of an element.
- *
- *
- * @param namespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param name The element type name
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void endElement(String namespaceURI, String localName, String name)
- throws org.xml.sax.SAXException
- {
- if (m_inEntityRef)
- return;
-
- // namespaces declared at the current depth are no longer valid
- // so get rid of them
- m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth, null);
-
- try
- {
- final java.io.Writer writer = m_writer;
- if (m_elemContext.m_startTagOpen)
- {
- if (m_tracer != null)
- super.fireStartElem(m_elemContext.m_elementName);
- int nAttrs = m_attributes.getLength();
- if (nAttrs > 0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
- if (m_spaceBeforeClose)
- writer.write(" />");
- else
- writer.write("/>");
- /* don't need to pop cdataSectionState because
- * this element ended so quickly that we didn't get
- * to push the state.
- */
-
- }
- else
- {
- if (m_cdataTagOpen)
- closeCDATA();
-
- if (shouldIndent())
- indent(m_elemContext.m_currentElemDepth - 1);
- writer.write('<');
- writer.write('/');
- writer.write(name);
- writer.write('>');
- }
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- if (!m_elemContext.m_startTagOpen && m_doIndent)
- {
- m_ispreserve = m_preserves.isEmpty() ? false : m_preserves.pop();
- }
-
- m_isprevtext = false;
-
- // fire off the end element event
- if (m_tracer != null)
- super.fireEndElem(name);
- m_elemContext = m_elemContext.m_prev;
- }
-
- /**
- * Receive notification of the end of an element.
- * @param name The element type name
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public void endElement(String name) throws org.xml.sax.SAXException
- {
- endElement(null, null, name);
- }
-
- /**
- * Begin the scope of a prefix-URI Namespace mapping
- * just before another element is about to start.
- * This call will close any open tags so that the prefix mapping
- * will not apply to the current element, but the up comming child.
- *
- * @see org.xml.sax.ContentHandler#startPrefixMapping
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- *
- * @throws org.xml.sax.SAXException The client may throw
- * an exception during processing.
- *
- */
- public void startPrefixMapping(String prefix, String uri)
- throws org.xml.sax.SAXException
- {
- // the "true" causes the flush of any open tags
- startPrefixMapping(prefix, uri, true);
- }
-
- /**
- * Handle a prefix/uri mapping, which is associated with a startElement()
- * that is soon to follow. Need to close any open start tag to make
- * sure than any name space attributes due to this event are associated wih
- * the up comming element, not the current one.
- * @see ExtendedContentHandler#startPrefixMapping
- *
- * @param prefix The Namespace prefix being declared.
- * @param uri The Namespace URI the prefix is mapped to.
- * @param shouldFlush true if any open tags need to be closed first, this
- * will impact which element the mapping applies to (open parent, or its up
- * comming child)
- * @return returns true if the call made a change to the current
- * namespace information, false if it did not change anything, e.g. if the
- * prefix/namespace mapping was already in scope from before.
- *
- * @throws org.xml.sax.SAXException The client may throw
- * an exception during processing.
- *
- *
- */
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws org.xml.sax.SAXException
- {
-
- /* Remember the mapping, and at what depth it was declared
- * This is one greater than the current depth because these
- * mappings will apply to the next depth. This is in
- * consideration that startElement() will soon be called
- */
-
- boolean pushed;
- int pushDepth;
- if (shouldFlush)
- {
- flushPending();
- // the prefix mapping applies to the child element (one deeper)
- pushDepth = m_elemContext.m_currentElemDepth + 1;
- }
- else
- {
- // the prefix mapping applies to the current element
- pushDepth = m_elemContext.m_currentElemDepth;
- }
- pushed = m_prefixMap.pushNamespace(prefix, uri, pushDepth);
-
- if (pushed)
- {
- /* Brian M.: don't know if we really needto do this. The
- * callers of this object should have injected both
- * startPrefixMapping and the attributes. We are
- * just covering our butt here.
- */
- String name;
- if (EMPTYSTRING.equals(prefix))
- {
- name = "xmlns";
- addAttributeAlways(XMLNS_URI, name, name, "CDATA", uri, false);
- }
- else
- {
- if (!EMPTYSTRING.equals(uri))
- // hack for XSLTC attribset16 test
- { // that maps ns1 prefix to "" URI
- name = "xmlns:" + prefix;
-
- /* for something like xmlns:abc="w3.pretend.org"
- * the uri is the value, that is why we pass it in the
- * value, or 5th slot of addAttributeAlways()
- */
- addAttributeAlways(XMLNS_URI, prefix, name, "CDATA", uri, false);
- }
- }
- }
- return pushed;
- }
-
- /**
- * Receive notification of an XML comment anywhere in the document. This
- * callback will be used for comments inside or outside the document
- * element, including comments in the external DTD subset (if read).
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param length The number of characters to use from the array.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- */
- public void comment(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- int start_old = start;
- if (m_inEntityRef)
- return;
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
-
- try
- {
- if (shouldIndent())
- indent();
-
- final int limit = start + length;
- boolean wasDash = false;
- if (m_cdataTagOpen)
- closeCDATA();
- final java.io.Writer writer = m_writer;
- writer.write(COMMENT_BEGIN);
- // Detect occurrences of two consecutive dashes, handle as necessary.
- for (int i = start; i < limit; i++)
- {
- if (wasDash && ch[i] == '-')
- {
- writer.write(ch, start, i - start);
- writer.write(" -");
- start = i + 1;
- }
- wasDash = (ch[i] == '-');
- }
-
- // if we have some chars in the comment
- if (length > 0)
- {
- // Output the remaining characters (if any)
- final int remainingChars = (limit - start);
- if (remainingChars > 0)
- writer.write(ch, start, remainingChars);
- // Protect comment end from a single trailing dash
- if (ch[limit - 1] == '-')
- writer.write(' ');
- }
- writer.write(COMMENT_END);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- m_startNewLine = true;
- // time to generate comment event
- if (m_tracer != null)
- super.fireCommentEvent(ch, start_old,length);
- }
-
- /**
- * Report the end of a CDATA section.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- *
- * @see #startCDATA
- */
- public void endCDATA() throws org.xml.sax.SAXException
- {
- if (m_cdataTagOpen)
- closeCDATA();
- m_cdataStartCalled = false;
- }
-
- /**
- * Report the end of DTD declarations.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #startDTD
- */
- public void endDTD() throws org.xml.sax.SAXException
- {
- try
- {
- if (m_needToOutputDocTypeDecl)
- {
- outputDocTypeDecl(m_elemContext.m_elementName, false);
- m_needToOutputDocTypeDecl = false;
- }
- final java.io.Writer writer = m_writer;
- if (!m_inDoctype)
- writer.write("]>");
- else
- {
- writer.write('>');
- }
-
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- }
-
- /**
- * End the scope of a prefix-URI Namespace mapping.
- * @see org.xml.sax.ContentHandler#endPrefixMapping
- *
- * @param prefix The prefix that was being mapping.
- * @throws org.xml.sax.SAXException The client may throw
- * an exception during processing.
- */
- public void endPrefixMapping(String prefix) throws org.xml.sax.SAXException
- { // do nothing
- m_prefixMap.popNamespace(prefix);
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- *
- * Not sure how to get this invoked quite yet.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #characters
- *
- * @throws org.xml.sax.SAXException
- */
- public void ignorableWhitespace(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if (0 == length)
- return;
- characters(ch, start, length);
- }
-
- /**
- * Receive notification of a skipped entity.
- * @see org.xml.sax.ContentHandler#skippedEntity
- *
- * @param name The name of the skipped entity. If it is a
- * parameter entity, the name will begin with '%',
- * and if it is the external DTD subset, it will be the string
- * "[dtd]".
- * @throws org.xml.sax.SAXException Any SAX exception, possibly wrapping
- * another exception.
- */
- public void skippedEntity(String name) throws org.xml.sax.SAXException
- { // TODO: Should handle
- }
-
- /**
- * Report the start of a CDATA section.
- *
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #endCDATA
- */
- public void startCDATA() throws org.xml.sax.SAXException
- {
- m_cdataStartCalled = true;
- }
-
- /**
- * Report the beginning of an entity.
- *
- * The start and end of the document entity are not reported.
- * The start and end of the external DTD subset are reported
- * using the pseudo-name "[dtd]". All other events must be
- * properly nested within start/end entity events.
- *
- * @param name The name of the entity. If it is a parameter
- * entity, the name will begin with '%'.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #endEntity
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl
- */
- public void startEntity(String name) throws org.xml.sax.SAXException
- {
- if (name.equals("[dtd]"))
- m_inExternalDTD = true;
-
- if (!m_expandDTDEntities && !m_inExternalDTD) {
- /* Only leave the entity as-is if
- * we've been told not to expand them
- * and this is not the magic [dtd] name.
- */
- startNonEscaping();
- characters("&" + name + ';');
- endNonEscaping();
- }
-
- m_inEntityRef = true;
- }
-
- /**
- * For the enclosing elements starting tag write out
- * out any attributes followed by ">"
- *
- * @throws org.xml.sax.SAXException
- */
- protected void closeStartTag() throws SAXException
- {
-
- if (m_elemContext.m_startTagOpen)
- {
-
- try
- {
- if (m_tracer != null)
- super.fireStartElem(m_elemContext.m_elementName);
- int nAttrs = m_attributes.getLength();
- if (nAttrs > 0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
- m_writer.write('>');
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
-
- /* whether Xalan or XSLTC, we have the prefix mappings now, so
- * lets determine if the current element is specified in the cdata-
- * section-elements list.
- */
- if (m_cdataSectionElements != null)
- m_elemContext.m_isCdataSection = isCdataSection();
-
- if (m_doIndent)
- {
- m_isprevtext = false;
- m_preserves.push(m_ispreserve);
- }
- }
-
- }
-
- /**
- * Report the start of DTD declarations, if any.
- *
- * Any declarations are assumed to be in the internal subset unless
- * otherwise indicated.
- *
- * @param name The document type name.
- * @param publicId The declared public identifier for the
- * external DTD subset, or null if none was declared.
- * @param systemId The declared system identifier for the
- * external DTD subset, or null if none was declared.
- * @throws org.xml.sax.SAXException The application may raise an
- * exception.
- * @see #endDTD
- * @see #startEntity
- */
- public void startDTD(String name, String publicId, String systemId)
- throws org.xml.sax.SAXException
- {
- setDoctypeSystem(systemId);
- setDoctypePublic(publicId);
-
- m_elemContext.m_elementName = name;
- m_inDoctype = true;
- }
-
- /**
- * Returns the m_indentAmount.
- * @return int
- */
- public int getIndentAmount()
- {
- return m_indentAmount;
- }
-
- /**
- * Sets the m_indentAmount.
- *
- * @param m_indentAmount The m_indentAmount to set
- */
- public void setIndentAmount(int m_indentAmount)
- {
- this.m_indentAmount = m_indentAmount;
- }
-
- /**
- * Tell if, based on space preservation constraints and the doIndent property,
- * if an indent should occur.
- *
- * @return True if an indent should occur.
- */
- protected boolean shouldIndent()
- {
- return m_doIndent && (!m_ispreserve && !m_isprevtext);
- }
-
- /**
- * Searches for the list of qname properties with the specified key in the
- * property list. If the key is not found in this property list, the default
- * property list, and its defaults, recursively, are then checked. The
- * method returns <code>null</code> if the property is not found.
- *
- * @param key the property key.
- * @param props the list of properties to search in.
- *
- * Sets the vector of local-name/URI pairs of the cdata section elements
- * specified in the cdata-section-elements property.
- *
- * This method is essentially a copy of getQNameProperties() from
- * OutputProperties. Eventually this method should go away and a call
- * to setCdataSectionElements(Vector v) should be made directly.
- */
- private void setCdataSectionElements(String key, Properties props)
- {
-
- String s = props.getProperty(key);
-
- if (null != s)
- {
- // Vector of URI/LocalName pairs
- Vector v = new Vector();
- int l = s.length();
- boolean inCurly = false;
- StringBuffer buf = new StringBuffer();
-
- // parse through string, breaking on whitespaces. I do this instead
- // of a tokenizer so I can track whitespace inside of curly brackets,
- // which theoretically shouldn't happen if they contain legal URLs.
- for (int i = 0; i < l; i++)
- {
- char c = s.charAt(i);
-
- if (Character.isWhitespace(c))
- {
- if (!inCurly)
- {
- if (buf.length() > 0)
- {
- addCdataSectionElement(buf.toString(), v);
- buf.setLength(0);
- }
- continue;
- }
- }
- else if ('{' == c)
- inCurly = true;
- else if ('}' == c)
- inCurly = false;
-
- buf.append(c);
- }
-
- if (buf.length() > 0)
- {
- addCdataSectionElement(buf.toString(), v);
- buf.setLength(0);
- }
- // call the official, public method to set the collected names
- setCdataSectionElements(v);
- }
-
- }
-
- /**
- * Adds a URI/LocalName pair of strings to the list.
- *
- * @param URI_and_localName String of the form "{uri}local" or "local"
- *
- * @return a QName object
- */
- private void addCdataSectionElement(String URI_and_localName, Vector v)
- {
-
- StringTokenizer tokenizer =
- new StringTokenizer(URI_and_localName, "{}", false);
- String s1 = tokenizer.nextToken();
- String s2 = tokenizer.hasMoreTokens() ? tokenizer.nextToken() : null;
-
- if (null == s2)
- {
- // add null URI and the local name
- v.addElement(null);
- v.addElement(s1);
- }
- else
- {
- // add URI, then local name
- v.addElement(s1);
- v.addElement(s2);
- }
- }
-
- /**
- * Remembers the cdata sections specified in the cdata-section-elements.
- * The "official way to set URI and localName pairs.
- * This method should be used by both Xalan and XSLTC.
- *
- * @param URI_and_localNames a vector of pairs of Strings (URI/local)
- */
- public void setCdataSectionElements(Vector URI_and_localNames)
- {
- m_cdataSectionElements = URI_and_localNames;
- }
-
- /**
- * Makes sure that the namespace URI for the given qualified attribute name
- * is declared.
- * @param ns the namespace URI
- * @param rawName the qualified name
- * @return returns null if no action is taken, otherwise it returns the
- * prefix used in declaring the namespace.
- * @throws SAXException
- */
- protected String ensureAttributesNamespaceIsDeclared(
- String ns,
- String localName,
- String rawName)
- throws org.xml.sax.SAXException
- {
-
- if (ns != null && ns.length() > 0)
- {
-
- // extract the prefix in front of the raw name
- int index = 0;
- String prefixFromRawName =
- (index = rawName.indexOf(":")) < 0
- ? ""
- : rawName.substring(0, index);
-
- if (index > 0)
- {
- // we have a prefix, lets see if it maps to a namespace
- String uri = m_prefixMap.lookupNamespace(prefixFromRawName);
- if (uri != null && uri.equals(ns))
- {
- // the prefix in the raw name is already maps to the given namespace uri
- // so we don't need to do anything
- return null;
- }
- else
- {
- // The uri does not map to the prefix in the raw name,
- // so lets make the mapping.
- this.startPrefixMapping(prefixFromRawName, ns, false);
- this.addAttribute(
- "http://www.w3.org/2000/xmlns/",
- prefixFromRawName,
- "xmlns:" + prefixFromRawName,
- "CDATA",
- ns, false);
- return prefixFromRawName;
- }
- }
- else
- {
- // we don't have a prefix in the raw name.
- // Does the URI map to a prefix already?
- String prefix = m_prefixMap.lookupPrefix(ns);
- if (prefix == null)
- {
- // uri is not associated with a prefix,
- // so lets generate a new prefix to use
- prefix = m_prefixMap.generateNextPrefix();
- this.startPrefixMapping(prefix, ns, false);
- this.addAttribute(
- "http://www.w3.org/2000/xmlns/",
- prefix,
- "xmlns:" + prefix,
- "CDATA",
- ns, false);
- }
-
- return prefix;
-
- }
- }
- return null;
- }
-
- void ensurePrefixIsDeclared(String ns, String rawName)
- throws org.xml.sax.SAXException
- {
-
- if (ns != null && ns.length() > 0)
- {
- int index;
- final boolean no_prefix = ((index = rawName.indexOf(":")) < 0);
- String prefix = (no_prefix) ? "" : rawName.substring(0, index);
-
- if (null != prefix)
- {
- String foundURI = m_prefixMap.lookupNamespace(prefix);
-
- if ((null == foundURI) || !foundURI.equals(ns))
- {
- this.startPrefixMapping(prefix, ns);
-
- // Bugzilla1133: Generate attribute as well as namespace event.
- // SAX does expect both.
-
- this.addAttributeAlways(
- "http://www.w3.org/2000/xmlns/",
- no_prefix ? "xmlns" : prefix, // local name
- no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname
- "CDATA",
- ns,
- false);
- }
-
- }
- }
- }
-
- /**
- * This method flushes any pending events, which can be startDocument()
- * closing the opening tag of an element, or closing an open CDATA section.
- */
- public void flushPending() throws SAXException
- {
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- if (m_cdataTagOpen)
- {
- closeCDATA();
- m_cdataTagOpen = false;
- }
- }
-
- public void setContentHandler(ContentHandler ch)
- {
- // this method is really only useful in the ToSAXHandler classes but it is
- // in the interface. If the method defined here is ever called
- // we are probably in trouble.
- }
-
- /**
- * Adds the given attribute to the set of attributes, even if there is
- * no currently open element. This is useful if a SAX startPrefixMapping()
- * should need to add an attribute before the element name is seen.
- *
- * This method is a copy of its super classes method, except that some
- * tracing of events is done. This is so the tracing is only done for
- * stream serializers, not for SAX ones.
- *
- * @param uri the URI of the attribute
- * @param localName the local name of the attribute
- * @param rawName the qualified name of the attribute
- * @param type the type of the attribute (probably CDATA)
- * @param value the value of the attribute
- * @param xslAttribute true if this attribute is coming from an xsl:attribute element.
- * @return true if the attribute value was added,
- * false if the attribute already existed and the value was
- * replaced with the new value.
- */
- public boolean addAttributeAlways(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean xslAttribute)
- {
- boolean was_added;
- int index;
- if (uri == null || localName == null || uri.length() == 0)
- index = m_attributes.getIndex(rawName);
- else {
- index = m_attributes.getIndex(uri, localName);
- }
-
- if (index >= 0)
- {
- String old_value = null;
- if (m_tracer != null)
- {
- old_value = m_attributes.getValue(index);
- if (value.equals(old_value))
- old_value = null;
- }
-
- /* We've seen the attribute before.
- * We may have a null uri or localName, but all we really
- * want to re-set is the value anyway.
- */
- m_attributes.setValue(index, value);
- was_added = false;
- if (old_value != null)
- firePseudoAttributes();
-
- }
- else
- {
- // the attribute doesn't exist yet, create it
- if (xslAttribute)
- {
- /*
- * This attribute is from an xsl:attribute element so we take some care in
- * adding it, e.g.
- * <elem1 foo:attr1="1" xmlns:foo="uri1">
- * <xsl:attribute name="foo:attr2">2</xsl:attribute>
- * </elem1>
- *
- * We are adding attr1 and attr2 both as attributes of elem1,
- * and this code is adding attr2 (the xsl:attribute ).
- * We could have a collision with the prefix like in the example above.
- */
-
- // In the example above, is there a prefix like foo ?
- final int colonIndex = rawName.indexOf(':');
- if (colonIndex > 0)
- {
- String prefix = rawName.substring(0,colonIndex);
- NamespaceMappings.MappingRecord existing_mapping = m_prefixMap.getMappingFromPrefix(prefix);
-
- /* Before adding this attribute (foo:attr2),
- * is the prefix for it (foo) already mapped at the current depth?
- */
- if (existing_mapping != null
- && existing_mapping.m_declarationDepth == m_elemContext.m_currentElemDepth
- && !existing_mapping.m_uri.equals(uri))
- {
- /*
- * There is an existing mapping of this prefix,
- * it differs from the one we need,
- * and unfortunately it is at the current depth so we
- * can not over-ride it.
- */
-
- /*
- * Are we lucky enough that an existing other prefix maps to this URI ?
- */
- prefix = m_prefixMap.lookupPrefix(uri);
- if (prefix == null)
- {
- /* Unfortunately there is no existing prefix that happens to map to ours,
- * so to avoid a prefix collision we must generated a new prefix to use.
- * This is OK because the prefix URI mapping
- * defined in the xsl:attribute is short in scope,
- * just the xsl:attribute element itself,
- * and at this point in serialization the body of the
- * xsl:attribute, if any, is just a String. Right?
- * . . . I sure hope so - Brian M.
- */
- prefix = m_prefixMap.generateNextPrefix();
- }
-
- rawName = prefix + ':' + localName;
- }
- }
-
- try
- {
- /* This is our last chance to make sure the namespace for this
- * attribute is declared, especially if we just generated an alternate
- * prefix to avoid a collision (the new prefix/rawName will go out of scope
- * soon and be lost ... last chance here.
- */
- String prefixUsed =
- ensureAttributesNamespaceIsDeclared(
- uri,
- localName,
- rawName);
- }
- catch (SAXException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- m_attributes.addAttribute(uri, localName, rawName, type, value);
- was_added = true;
- if (m_tracer != null)
- firePseudoAttributes();
- }
- return was_added;
- }
-
- /**
- * To fire off the pseudo characters of attributes, as they currently
- * exist. This method should be called everytime an attribute is added,
- * or when an attribute value is changed, or an element is created.
- */
-
- protected void firePseudoAttributes()
- {
- if (m_tracer != null)
- {
- try
- {
- // flush out the "<elemName" if not already flushed
- m_writer.flush();
-
- // make a StringBuffer to write the name="value" pairs to.
- StringBuffer sb = new StringBuffer();
- int nAttrs = m_attributes.getLength();
- if (nAttrs > 0)
- {
- // make a writer that internally appends to the same
- // StringBuffer
- java.io.Writer writer =
- new ToStream.WritertoStringBuffer(sb);
-
- processAttributes(writer, nAttrs);
- // Don't clear the attributes!
- // We only want to see what would be written out
- // at this point, we don't want to loose them.
- }
- sb.append('>'); // the potential > after the attributes.
- // convert the StringBuffer to a char array and
- // emit the trace event that these characters "might"
- // be written
- char ch[] = sb.toString().toCharArray();
- m_tracer.fireGenerateEvent(
- SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
- ch,
- 0,
- ch.length);
- }
- catch (IOException ioe)
- {
- // ignore ?
- }
- catch (SAXException se)
- {
- // ignore ?
- }
- }
- }
-
- /**
- * This inner class is used only to collect attribute values
- * written by the method writeAttrString() into a string buffer.
- * In this manner trace events, and the real writing of attributes will use
- * the same code.
- */
- private class WritertoStringBuffer extends java.io.Writer
- {
- final private StringBuffer m_stringbuf;
- /**
- * @see java.io.Writer#write(char[], int, int)
- */
- WritertoStringBuffer(StringBuffer sb)
- {
- m_stringbuf = sb;
- }
-
- public void write(char[] arg0, int arg1, int arg2) throws IOException
- {
- m_stringbuf.append(arg0, arg1, arg2);
- }
- /**
- * @see java.io.Writer#flush()
- */
- public void flush() throws IOException
- {
- }
- /**
- * @see java.io.Writer#close()
- */
- public void close() throws IOException
- {
- }
-
- public void write(int i)
- {
- m_stringbuf.append((char) i);
- }
-
- public void write(String s)
- {
- m_stringbuf.append(s);
- }
- }
-
- /**
- * @see SerializationHandler#setTransformer(Transformer)
- */
- public void setTransformer(Transformer transformer) {
- super.setTransformer(transformer);
- if (m_tracer != null
- && !(m_writer instanceof SerializerTraceWriter) )
- m_writer = new SerializerTraceWriter(m_writer, m_tracer);
-
-
- }
- /**
- * Try's to reset the super class and reset this class for
- * re-use, so that you don't need to create a new serializer
- * (mostly for performance reasons).
- *
- * @return true if the class was successfuly reset.
- */
- public boolean reset()
- {
- boolean wasReset = false;
- if (super.reset())
- {
- resetToStream();
- wasReset = true;
- }
- return wasReset;
- }
-
- /**
- * Reset all of the fields owned by ToStream class
- *
- */
- private void resetToStream()
- {
- this.m_cdataStartCalled = false;
- /* The stream is being reset. It is one of
- * ToXMLStream, ToHTMLStream ... and this type can't be changed
- * so neither should m_charInfo which is associated with the
- * type of Stream. Just leave m_charInfo as-is for the next re-use.
- *
- */
- // this.m_charInfo = null; // don't set to null
-
- this.m_disableOutputEscapingStates.clear();
-
- this.m_escaping = true;
- // Leave m_format alone for now - Brian M.
- // this.m_format = null;
- this.m_inDoctype = false;
- this.m_ispreserve = false;
- this.m_ispreserve = false;
- this.m_isprevtext = false;
- this.m_isUTF8 = false; // ?? used anywhere ??
- this.m_preserves.clear();
- this.m_shouldFlush = true;
- this.m_spaceBeforeClose = false;
- this.m_startNewLine = false;
- this.m_lineSepUse = true;
- // DON'T SET THE WRITER TO NULL, IT MAY BE REUSED !!
- // this.m_writer = null;
- this.m_expandDTDEntities = true;
-
- }
-
- /**
- * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
- * @param encoding the character encoding
- */
- public void setEncoding(String encoding)
- {
- String old = getEncoding();
- super.setEncoding(encoding);
- if (old == null || !old.equals(encoding)) {
- // If we have changed the setting of the
- m_encodingInfo = Encodings.getEncodingInfo(encoding);
-
- if (encoding != null && m_encodingInfo.name == null) {
- // We tried to get an EncodingInfo for Object for the given
- // encoding, but it came back with an internall null name
- // so the encoding is not supported by the JDK, issue a message.
- String msg = Utils.messages.createMessage(
- MsgKey.ER_ENCODING_NOT_SUPPORTED,new Object[]{ encoding });
- try
- {
- // Prepare to issue the warning message
- Transformer tran = super.getTransformer();
- if (tran != null) {
- ErrorListener errHandler = tran.getErrorListener();
- // Issue the warning message
- if (null != errHandler && m_sourceLocator != null)
- errHandler.warning(new TransformerException(msg, m_sourceLocator));
- else
- System.out.println(msg);
- }
- else
- System.out.println(msg);
- }
- catch (Exception e){}
- }
- }
- return;
- }
-
- /**
- * Simple stack for boolean values.
- *
- * This class is a copy of the one in org.apache.xml.utils.
- * It exists to cut the serializers dependancy on that package.
- * A minor changes from that package are:
- * doesn't implement Clonable
- *
- * @xsl.usage internal
- */
- static final class BoolStack
- {
-
- /** Array of boolean values */
- private boolean m_values[];
-
- /** Array size allocated */
- private int m_allocatedSize;
-
- /** Index into the array of booleans */
- private int m_index;
-
- /**
- * Default constructor. Note that the default
- * block size is very small, for small lists.
- */
- public BoolStack()
- {
- this(32);
- }
-
- /**
- * Construct a IntVector, using the given block size.
- *
- * @param size array size to allocate
- */
- public BoolStack(int size)
- {
-
- m_allocatedSize = size;
- m_values = new boolean[size];
- m_index = -1;
- }
-
- /**
- * Get the length of the list.
- *
- * @return Current length of the list
- */
- public final int size()
- {
- return m_index + 1;
- }
-
- /**
- * Clears the stack.
- *
- */
- public final void clear()
- {
- m_index = -1;
- }
-
- /**
- * Pushes an item onto the top of this stack.
- *
- *
- * @param val the boolean to be pushed onto this stack.
- * @return the <code>item</code> argument.
- */
- public final boolean push(boolean val)
- {
-
- if (m_index == m_allocatedSize - 1)
- grow();
-
- return (m_values[++m_index] = val);
- }
-
- /**
- * Removes the object at the top of this stack and returns that
- * object as the value of this function.
- *
- * @return The object at the top of this stack.
- * @throws EmptyStackException if this stack is empty.
- */
- public final boolean pop()
- {
- return m_values[m_index--];
- }
-
- /**
- * Removes the object at the top of this stack and returns the
- * next object at the top as the value of this function.
- *
- *
- * @return Next object to the top or false if none there
- */
- public final boolean popAndTop()
- {
-
- m_index--;
-
- return (m_index >= 0) ? m_values[m_index] : false;
- }
-
- /**
- * Set the item at the top of this stack
- *
- *
- * @param b Object to set at the top of this stack
- */
- public final void setTop(boolean b)
- {
- m_values[m_index] = b;
- }
-
- /**
- * Looks at the object at the top of this stack without removing it
- * from the stack.
- *
- * @return the object at the top of this stack.
- * @throws EmptyStackException if this stack is empty.
- */
- public final boolean peek()
- {
- return m_values[m_index];
- }
-
- /**
- * Looks at the object at the top of this stack without removing it
- * from the stack. If the stack is empty, it returns false.
- *
- * @return the object at the top of this stack.
- */
- public final boolean peekOrFalse()
- {
- return (m_index > -1) ? m_values[m_index] : false;
- }
-
- /**
- * Looks at the object at the top of this stack without removing it
- * from the stack. If the stack is empty, it returns true.
- *
- * @return the object at the top of this stack.
- */
- public final boolean peekOrTrue()
- {
- return (m_index > -1) ? m_values[m_index] : true;
- }
-
- /**
- * Tests if this stack is empty.
- *
- * @return <code>true</code> if this stack is empty;
- * <code>false</code> otherwise.
- */
- public boolean isEmpty()
- {
- return (m_index == -1);
- }
-
- /**
- * Grows the size of the stack
- *
- */
- private void grow()
- {
-
- m_allocatedSize *= 2;
-
- boolean newVector[] = new boolean[m_allocatedSize];
-
- System.arraycopy(m_values, 0, newVector, 0, m_index + 1);
-
- m_values = newVector;
- }
- }
-
- // Implement DTDHandler
- /**
- * If this method is called, the serializer is used as a
- * DTDHandler, which changes behavior how the serializer
- * handles document entities.
- * @see org.xml.sax.DTDHandler#notationDecl(java.lang.String, java.lang.String, java.lang.String)
- */
- public void notationDecl(String name, String pubID, String sysID) throws SAXException {
- // TODO Auto-generated method stub
- try {
- DTDprolog();
-
- m_writer.write("<!NOTATION ");
- m_writer.write(name);
- if (pubID != null) {
- m_writer.write(" PUBLIC \"");
- m_writer.write(pubID);
-
- }
- else {
- m_writer.write(" SYSTEM \"");
- m_writer.write(sysID);
- }
- m_writer.write("\" >");
- m_writer.write(m_lineSep, 0, m_lineSepLen);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * If this method is called, the serializer is used as a
- * DTDHandler, which changes behavior how the serializer
- * handles document entities.
- * @see org.xml.sax.DTDHandler#unparsedEntityDecl(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
- */
- public void unparsedEntityDecl(String name, String pubID, String sysID, String notationName) throws SAXException {
- // TODO Auto-generated method stub
- try {
- DTDprolog();
-
- m_writer.write("<!ENTITY ");
- m_writer.write(name);
- if (pubID != null) {
- m_writer.write(" PUBLIC \"");
- m_writer.write(pubID);
-
- }
- else {
- m_writer.write(" SYSTEM \"");
- m_writer.write(sysID);
- }
- m_writer.write("\" NDATA ");
- m_writer.write(notationName);
- m_writer.write(" >");
- m_writer.write(m_lineSep, 0, m_lineSepLen);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * A private helper method to output the
- * @throws SAXException
- * @throws IOException
- */
- private void DTDprolog() throws SAXException, IOException {
- final java.io.Writer writer = m_writer;
- if (m_needToOutputDocTypeDecl)
- {
- outputDocTypeDecl(m_elemContext.m_elementName, false);
- m_needToOutputDocTypeDecl = false;
- }
- if (m_inDoctype)
- {
- writer.write(" [");
- writer.write(m_lineSep, 0, m_lineSepLen);
- m_inDoctype = false;
- }
- }
-
- /**
- * If set to false the serializer does not expand DTD entities,
- * but leaves them as is, the default value is true;
- */
- public void setDTDEntityExpansion(boolean expand) {
- m_expandDTDEntities = expand;
- }
-}
\ No newline at end of file
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextSAXHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextSAXHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextSAXHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,409 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToTextSAXHandler.java,v 1.1.2.1 2007/01/09 18:57:14 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class converts SAX-like event to SAX events for
- * xsl:output method "text".
- *
- * This class is only to be used internally. This class is not a public API.
- *
- * @xsl.usage internal
- */
-public final class ToTextSAXHandler extends ToSAXHandler
-{
- /**
- * From XSLTC
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elemName) throws SAXException
- {
- if (m_tracer != null)
- super.fireEndElem(elemName);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endElement(String, String, String)
- */
- public void endElement(String arg0, String arg1, String arg2)
- throws SAXException
- {
- if (m_tracer != null)
- super.fireEndElem(arg2);
- }
-
- public ToTextSAXHandler(ContentHandler hdlr, LexicalHandler lex, String encoding)
- {
- super(hdlr, lex, encoding);
- }
-
- /**
- * From XSLTC
- */
- public ToTextSAXHandler(ContentHandler handler, String encoding)
- {
- super(handler,encoding);
- }
-
- public void comment(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- super.fireCommentEvent(ch, start, length);
- }
-
- public void comment(String data) throws org.xml.sax.SAXException
- {
- final int length = data.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- data.getChars(0, length, m_charsBuff, 0);
- comment(m_charsBuff, 0, length);
- }
-
- /**
- * @see Serializer#getOutputFormat()
- */
- public Properties getOutputFormat()
- {
- return null;
- }
-
- /**
- * @see Serializer#getOutputStream()
- */
- public OutputStream getOutputStream()
- {
- return null;
- }
-
- /**
- * @see Serializer#getWriter()
- */
- public Writer getWriter()
- {
- return null;
- }
-
- /**
- * Does nothing because
- * the indent attribute is ignored for text output.
- *
- */
- public void indent(int n) throws SAXException
- {
- }
-
- /**
- * @see Serializer#reset()
- */
- public boolean reset()
- {
- return false;
- }
-
- /**
- * @see DOMSerializer#serialize(Node)
- */
- public void serialize(Node node) throws IOException
- {
- }
-
- /**
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape)
- {
- return false;
- }
-
- /**
- * @see SerializationHandler#setIndent(boolean)
- */
- public void setIndent(boolean indent)
- {
- }
-
- /**
- * @see Serializer#setOutputFormat(Properties)
- */
- public void setOutputFormat(Properties format)
- {
- }
-
- /**
- * @see Serializer#setOutputStream(OutputStream)
- */
- public void setOutputStream(OutputStream output)
- {
- }
-
- /**
- * @see Serializer#setWriter(Writer)
- */
- public void setWriter(Writer writer)
- {
- }
-
- /**
- * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
- */
- public void attributeDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3,
- String arg4)
- throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
- */
- public void elementDecl(String arg0, String arg1) throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
- */
- public void externalEntityDecl(String arg0, String arg1, String arg2)
- throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
- */
- public void internalEntityDecl(String arg0, String arg1)
- throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
- */
- public void endPrefixMapping(String arg0) throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
- throws SAXException
- {
- }
-
- /**
- * From XSLTC
- * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
- */
- public void processingInstruction(String arg0, String arg1)
- throws SAXException
- {
- if (m_tracer != null)
- super.fireEscapingEvent(arg0, arg1);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
- */
- public void setDocumentLocator(Locator arg0)
- {
- }
-
- /**
- * @see org.xml.sax.ContentHandler#skippedEntity(String)
- */
- public void skippedEntity(String arg0) throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
- */
- public void startElement(
- String arg0,
- String arg1,
- String arg2,
- Attributes arg3)
- throws SAXException
- {
- flushPending();
- super.startElement(arg0, arg1, arg2, arg3);
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#endDTD()
- */
- public void endDTD() throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#startCDATA()
- */
- public void startCDATA() throws SAXException
- {
- }
-
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
- */
- public void startEntity(String arg0) throws SAXException
- {
- }
-
-
- /**
- * From XSLTC
- * @see ExtendedContentHandler#startElement(String)
- */
- public void startElement(
- String elementNamespaceURI,
- String elementLocalName,
- String elementName) throws SAXException
- {
- super.startElement(elementNamespaceURI, elementLocalName, elementName);
- }
-
- public void startElement(
- String elementName) throws SAXException
- {
- super.startElement(elementName);
- }
-
-
- /**
- * From XSLTC
- * @see org.xml.sax.ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException {
-
- flushPending();
- m_saxHandler.endDocument();
-
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- *
- * @see ExtendedContentHandler#characters(String)
- */
- public void characters(String characters)
- throws SAXException
- {
- final int length = characters.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- characters.getChars(0, length, m_charsBuff, 0);
-
- m_saxHandler.characters(m_charsBuff, 0, length);
-
- }
- /**
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] characters, int offset, int length)
- throws SAXException
- {
-
- m_saxHandler.characters(characters, offset, length);
-
- // time to fire off characters event
- if (m_tracer != null)
- super.fireCharEvent(characters, offset, length);
- }
-
- /**
- * From XSLTC
- */
- public void addAttribute(String name, String value)
- {
- // do nothing
- }
-
-
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws SAXException
- {
- // no namespace support for HTML
- return false;
- }
-
-
- public void startPrefixMapping(String prefix, String uri)
- throws org.xml.sax.SAXException
- {
- // no namespace support for HTML
- }
-
-
- public void namespaceAfterStartElement(
- final String prefix,
- final String uri)
- throws SAXException
- {
- // no namespace support for HTML
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToTextStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,632 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToTextStream.java,v 1.1.2.1 2007/01/09 18:57:30 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * This class is not a public API.
- * It is only public because it is used in other packages.
- * This class converts SAX or SAX-like calls to a
- * serialized document for xsl:output method of "text".
- * @xsl.usage internal
- */
-public final class ToTextStream extends ToStream
-{
-
-
- /**
- * Default constructor.
- */
- public ToTextStream()
- {
- super();
- }
-
-
-
- /**
- * Receive notification of the beginning of a document.
- *
- * <p>The SAX parser will invoke this method only once, before any
- * other methods in this interface or in DTDHandler (except for
- * setDocumentLocator).</p>
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void startDocumentInternal() throws org.xml.sax.SAXException
- {
- super.startDocumentInternal();
-
- m_needToCallStartDocument = false;
-
- // No action for the moment.
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * <p>The SAX parser will invoke this method only once, and it will
- * be the last method invoked during the parse. The parser shall
- * not invoke this method until it has either abandoned parsing
- * (because of an unrecoverable error) or reached the end of
- * input.</p>
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void endDocument() throws org.xml.sax.SAXException
- {
- flushPending();
- flushWriter();
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * Receive notification of the beginning of an element.
- *
- * <p>The Parser will invoke this method at the beginning of every
- * element in the XML document; there will be a corresponding
- * endElement() event for every startElement() event (even when the
- * element is empty). All of the element's content will be
- * reported, in order, before the corresponding endElement()
- * event.</p>
- *
- * <p>If the element name has a namespace prefix, the prefix will
- * still be attached. Note that the attribute list provided will
- * contain only attributes with explicit values (specified or
- * defaulted): #IMPLIED attributes will be omitted.</p>
- *
- *
- * @param namespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param name The qualified name (with prefix), or the
- * empty string if qualified names are not available.
- * @param atts The attributes attached to the element, if any.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement
- * @see org.xml.sax.AttributeList
- *
- * @throws org.xml.sax.SAXException
- */
- public void startElement(
- String namespaceURI, String localName, String name, Attributes atts)
- throws org.xml.sax.SAXException
- {
- // time to fire off startElement event
- if (m_tracer != null) {
- super.fireStartElem(name);
- this.firePseudoAttributes();
- }
- return;
- }
-
- /**
- * Receive notification of the end of an element.
- *
- * <p>The SAX parser will invoke this method at the end of every
- * element in the XML document; there will be a corresponding
- * startElement() event for every endElement() event (even when the
- * element is empty).</p>
- *
- * <p>If the element name has a namespace prefix, the prefix will
- * still be attached to the name.</p>
- *
- *
- * @param namespaceURI The Namespace URI, or the empty string if the
- * element has no Namespace URI or if Namespace
- * processing is not being performed.
- * @param localName The local name (without prefix), or the
- * empty string if Namespace processing is not being
- * performed.
- * @param name The qualified name (with prefix), or the
- * empty string if qualified names are not available.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void endElement(String namespaceURI, String localName, String name)
- throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- super.fireEndElem(name);
- }
-
- /**
- * Receive notification of character data.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- */
- public void characters(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- flushPending();
-
- try
- {
- if (inTemporaryOutputState()) {
- /* leave characters un-processed as we are
- * creating temporary output, the output generated by
- * this serializer will be input to a final serializer
- * later on and it will do the processing in final
- * output state (not temporary output state).
- *
- * A "temporary" ToTextStream serializer is used to
- * evaluate attribute value templates (for example),
- * and the result of evaluating such a thing
- * is fed into a final serializer later on.
- */
- m_writer.write(ch, start, length);
- }
- else {
- // In final output state we do process the characters!
- writeNormalizedChars(ch, start, length, m_lineSepUse);
- }
-
- if (m_tracer != null)
- super.fireCharEvent(ch, start, length);
- }
- catch(IOException ioe)
- {
- throw new SAXException(ioe);
- }
- }
-
- /**
- * If available, when the disable-output-escaping attribute is used,
- * output raw text without escaping.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public void charactersRaw(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- try
- {
- writeNormalizedChars(ch, start, length, m_lineSepUse);
- }
- catch(IOException ioe)
- {
- throw new SAXException(ioe);
- }
- }
-
- /**
- * Normalize the characters, but don't escape. Different from
- * SerializerToXML#writeNormalizedChars because it does not attempt to do
- * XML escaping at all.
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @param useLineSep true if the operating systems
- * end-of-line separator should be output rather than a new-line character.
- *
- * @throws IOException
- * @throws org.xml.sax.SAXException
- */
- void writeNormalizedChars(
- final char ch[],
- final int start,
- final int length,
- final boolean useLineSep)
- throws IOException, org.xml.sax.SAXException
- {
- final String encoding = getEncoding();
- final java.io.Writer writer = m_writer;
- final int end = start + length;
-
- /* copy a few "constants" before the loop for performance */
- final char S_LINEFEED = CharInfo.S_LINEFEED;
-
- // This for() loop always increments i by one at the end
- // of the loop. Additional increments of i adjust for when
- // two input characters (a high/low UTF16 surrogate pair)
- // are processed.
- for (int i = start; i < end; i++) {
- final char c = ch[i];
-
- if (S_LINEFEED == c && useLineSep) {
- writer.write(m_lineSep, 0, m_lineSepLen);
- // one input char processed
- } else if (m_encodingInfo.isInEncoding(c)) {
- writer.write(c);
- // one input char processed
- } else if (Encodings.isHighUTF16Surrogate(c)) {
- final int codePoint = writeUTF16Surrogate(c, ch, i, end);
- if (codePoint != 0) {
- // I think we can just emit the message,
- // not crash and burn.
- final String integralValue = Integer.toString(codePoint);
- final String msg = Utils.messages.createMessage(
- MsgKey.ER_ILLEGAL_CHARACTER,
- new Object[] { integralValue, encoding });
-
- //Older behavior was to throw the message,
- //but newer gentler behavior is to write a message to System.err
- //throw new SAXException(msg);
- System.err.println(msg);
-
- }
- i++; // two input chars processed
- } else {
- // Don't know what to do with this char, it is
- // not in the encoding and not a high char in
- // a surrogate pair, so write out as an entity ref
- if (encoding != null) {
- /* The output encoding is known,
- * so somthing is wrong.
- */
-
- // not in the encoding, so write out a character reference
- writer.write('&');
- writer.write('#');
- writer.write(Integer.toString(c));
- writer.write(';');
-
- // I think we can just emit the message,
- // not crash and burn.
- final String integralValue = Integer.toString(c);
- final String msg = Utils.messages.createMessage(
- MsgKey.ER_ILLEGAL_CHARACTER,
- new Object[] { integralValue, encoding });
-
- //Older behavior was to throw the message,
- //but newer gentler behavior is to write a message to System.err
- //throw new SAXException(msg);
- System.err.println(msg);
- } else {
- /* The output encoding is not known,
- * so just write it out as-is.
- */
- writer.write(c);
- }
-
- // one input char was processed
- }
- }
- }
-
- /**
- * Receive notification of cdata.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- */
- public void cdata(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
- try
- {
- writeNormalizedChars(ch, start, length, m_lineSepUse);
- if (m_tracer != null)
- super.fireCDATAEvent(ch, start, length);
- }
- catch(IOException ioe)
- {
- throw new SAXException(ioe);
- }
- }
-
- /**
- * Receive notification of ignorable whitespace in element content.
- *
- * <p>Validating Parsers must use this method to report each chunk
- * of ignorable whitespace (see the W3C XML 1.0 recommendation,
- * section 2.10): non-validating parsers may also use this method
- * if they are capable of parsing and using content models.</p>
- *
- * <p>SAX parsers may return all contiguous whitespace in a single
- * chunk, or they may split it into several chunks; however, all of
- * the characters in any single event must come from the same
- * external entity, so that the Locator provides useful
- * information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #characters
- *
- * @throws org.xml.sax.SAXException
- */
- public void ignorableWhitespace(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- try
- {
- writeNormalizedChars(ch, start, length, m_lineSepUse);
- }
- catch(IOException ioe)
- {
- throw new SAXException(ioe);
- }
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * <p>The Parser will invoke this method once for each processing
- * instruction found: note that processing instructions may occur
- * before or after the main document element.</p>
- *
- * <p>A SAX parser should never report an XML declaration (XML 1.0,
- * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
- * using this method.</p>
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if
- * none was supplied.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void processingInstruction(String target, String data)
- throws org.xml.sax.SAXException
- {
- // flush anything pending first
- flushPending();
-
- if (m_tracer != null)
- super.fireEscapingEvent(target, data);
- }
-
- /**
- * Called when a Comment is to be constructed.
- * Note that Xalan will normally invoke the other version of this method.
- * %REVIEW% In fact, is this one ever needed, or was it a mistake?
- *
- * @param data The comment data.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public void comment(String data) throws org.xml.sax.SAXException
- {
- final int length = data.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- data.getChars(0, length, m_charsBuff, 0);
- comment(m_charsBuff, 0, length);
- }
-
- /**
- * Report an XML comment anywhere in the document.
- *
- * This callback will be used for comments inside or outside the
- * document element, including comments in the external DTD
- * subset (if read).
- *
- * @param ch An array holding the characters in the comment.
- * @param start The starting position in the array.
- * @param length The number of characters to use from the array.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- */
- public void comment(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- flushPending();
- if (m_tracer != null)
- super.fireCommentEvent(ch, start, length);
- }
-
- /**
- * Receive notivication of a entityReference.
- *
- * @param name non-null reference to the name of the entity.
- *
- * @throws org.xml.sax.SAXException
- */
- public void entityReference(String name) throws org.xml.sax.SAXException
- {
- if (m_tracer != null)
- super.fireEntityReference(name);
- }
-
- /**
- * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- {
- // do nothing, just forget all about the attribute
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
- // do nothing
- }
-
- /**
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elemName) throws SAXException
- {
- if (m_tracer != null)
- super.fireEndElem(elemName);
- }
-
- /**
- * From XSLTC
- */
- public void startElement(
- String elementNamespaceURI,
- String elementLocalName,
- String elementName)
- throws SAXException
- {
- if (m_needToCallStartDocument)
- startDocumentInternal();
- // time to fire off startlement event.
- if (m_tracer != null) {
- super.fireStartElem(elementName);
- this.firePseudoAttributes();
- }
-
- return;
- }
-
-
- /**
- * From XSLTC
- */
- public void characters(String characters)
- throws SAXException
- {
- final int length = characters.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- characters.getChars(0, length, m_charsBuff, 0);
- characters(m_charsBuff, 0, length);
- }
-
-
- /**
- * From XSLTC
- */
- public void addAttribute(String name, String value)
- {
- // do nothing, forget about the attribute
- }
-
- /**
- * Add a unique attribute
- */
- public void addUniqueAttribute(String qName, String value, int flags)
- throws SAXException
- {
- // do nothing, forget about the attribute
- }
-
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws SAXException
- {
- // no namespace support for HTML
- return false;
- }
-
-
- public void startPrefixMapping(String prefix, String uri)
- throws org.xml.sax.SAXException
- {
- // no namespace support for HTML
- }
-
-
- public void namespaceAfterStartElement(
- final String prefix,
- final String uri)
- throws SAXException
- {
- // no namespace support for HTML
- }
-
- public void flushPending() throws org.xml.sax.SAXException
- {
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToUnknownStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToUnknownStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToUnknownStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,1306 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToUnknownStream.java,v 1.1.2.1 2007/01/09 18:57:25 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-import java.util.Vector;
-
-import javax.xml.transform.SourceLocator;
-import javax.xml.transform.Transformer;
-
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-
-
-/**
- *This class wraps another SerializationHandler. The wrapped object will either
- * handler XML or HTML, which is not known until a little later when the first XML
- * tag is seen. If the first tag is <html> then the wrapped object is an HTML
- * handler, otherwise it is an XML handler.
- *
- * This class effectively caches the first few calls to it then passes them
- * on to the wrapped handler (once it exists). After that subsequent calls a
- * simply passed directly to the wrapped handler.
- *
- * The user of this class doesn't know if the output is ultimatley XML or HTML.
- *
- * This class is not a public API, it is public because it is used within Xalan.
- * @xsl.usage internal
- */
-public final class ToUnknownStream extends SerializerBase
-{
-
- /**
- * The wrapped handler, initially XML but possibly switched to HTML
- */
- private SerializationHandler m_handler;
-
- /**
- * A String with no characters
- */
- private static final String EMPTYSTRING = "";
-
- /**
- * true if the underlying handler (XML or HTML) is fully initialized
- */
- private boolean m_wrapped_handler_not_initialized = false;
-
-
- /**
- * the prefix of the very first tag in the document
- */
- private String m_firstElementPrefix;
- /**
- * the element name (including any prefix) of the very first tag in the document
- */
- private String m_firstElementName;
-
- /**
- * the namespace URI associated with the first element
- */
- private String m_firstElementURI;
-
- /**
- * the local name (no prefix) associated with the first element
- */
- private String m_firstElementLocalName = null;
-
- /**
- * true if the first tag has been emitted to the wrapped handler
- */
- private boolean m_firstTagNotEmitted = true;
-
- /**
- * A collection of namespace URI's (only for first element).
- * _namespacePrefix has the matching prefix for these URI's
- */
- private Vector m_namespaceURI = null;
- /**
- * A collection of namespace Prefix (only for first element)
- * _namespaceURI has the matching URIs for these prefix'
- */
- private Vector m_namespacePrefix = null;
-
- /**
- * true if startDocument() was called before the underlying handler
- * was initialized
- */
- private boolean m_needToCallStartDocument = false;
- /**
- * true if setVersion() was called before the underlying handler
- * was initialized
- */
- private boolean m_setVersion_called = false;
- /**
- * true if setDoctypeSystem() was called before the underlying handler
- * was initialized
- */
- private boolean m_setDoctypeSystem_called = false;
- /**
- * true if setDoctypePublic() was called before the underlying handler
- * was initialized
- */
- private boolean m_setDoctypePublic_called = false;
- /**
- * true if setMediaType() was called before the underlying handler
- * was initialized
- */
- private boolean m_setMediaType_called = false;
-
- /**
- * Default constructor.
- * Initially this object wraps an XML Stream object, so _handler is never null.
- * That may change later to an HTML Stream object.
- */
- public ToUnknownStream()
- {
- m_handler = new ToXMLStream();
- }
-
- /**
- * @see Serializer#asContentHandler()
- * @return the wrapped XML or HTML handler
- */
- public ContentHandler asContentHandler() throws IOException
- {
- /* don't return the real handler ( m_handler ) because
- * that would expose the real handler to the outside.
- * Keep m_handler private so it can be internally swapped
- * to an HTML handler.
- */
- return this;
- }
-
- /**
- * @see SerializationHandler#close()
- */
- public void close()
- {
- m_handler.close();
- }
-
- /**
- * @see Serializer#getOutputFormat()
- * @return the properties of the underlying handler
- */
- public Properties getOutputFormat()
- {
- return m_handler.getOutputFormat();
- }
-
- /**
- * @see Serializer#getOutputStream()
- * @return the OutputStream of the underlying XML or HTML handler
- */
- public OutputStream getOutputStream()
- {
- return m_handler.getOutputStream();
- }
-
- /**
- * @see Serializer#getWriter()
- * @return the Writer of the underlying XML or HTML handler
- */
- public Writer getWriter()
- {
- return m_handler.getWriter();
- }
-
- /**
- * passes the call on to the underlying HTML or XML handler
- * @see Serializer#reset()
- * @return ???
- */
- public boolean reset()
- {
- return m_handler.reset();
- }
-
- /**
- * Converts the DOM node to output
- * @param node the DOM node to transform to output
- * @see DOMSerializer#serialize(Node)
- *
- */
- public void serialize(Node node) throws IOException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.serialize(node);
- }
-
- /**
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape) throws SAXException
- {
- return m_handler.setEscaping(escape);
- }
-
- /**
- * Set the properties of the handler
- * @param format the output properties to set
- * @see Serializer#setOutputFormat(Properties)
- */
- public void setOutputFormat(Properties format)
- {
- m_handler.setOutputFormat(format);
- }
-
- /**
- * Sets the output stream to write to
- * @param output the OutputStream to write to
- * @see Serializer#setOutputStream(OutputStream)
- */
- public void setOutputStream(OutputStream output)
- {
- m_handler.setOutputStream(output);
- }
-
- /**
- * Sets the writer to write to
- * @param writer the writer to write to
- * @see Serializer#setWriter(Writer)
- */
- public void setWriter(Writer writer)
- {
- m_handler.setWriter(writer);
- }
-
- /**
- * Adds an attribute to the currenly open tag
- * @param uri the URI of a namespace
- * @param localName the attribute name, without prefix
- * @param rawName the attribute name, with prefix (if any)
- * @param type the type of the attribute, typically "CDATA"
- * @param value the value of the parameter
- * @param XSLAttribute true if this attribute is coming from an xsl:attribute element
- * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.addAttribute(uri, localName, rawName, type, value, XSLAttribute);
- }
- /**
- * Adds an attribute to the currenly open tag
- * @param rawName the attribute name, with prefix (if any)
- * @param value the value of the parameter
- * @see ExtendedContentHandler#addAttribute(String, String)
- */
- public void addAttribute(String rawName, String value)
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.addAttribute(rawName, value);
-
- }
-
- /**
- * Adds a unique attribute to the currenly open tag
- */
- public void addUniqueAttribute(String rawName, String value, int flags)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.addUniqueAttribute(rawName, value, flags);
-
- }
-
- /**
- * Converts the String to a character array and calls the SAX method
- * characters(char[],int,int);
- *
- * @see ExtendedContentHandler#characters(String)
- */
- public void characters(String chars) throws SAXException
- {
- final int length = chars.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- chars.getChars(0, length, m_charsBuff, 0);
- this.characters(m_charsBuff, 0, length);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elementName) throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.endElement(elementName);
- }
-
-
- /**
- * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
- * @param prefix The prefix that maps to the URI
- * @param uri The URI for the namespace
- */
- public void startPrefixMapping(String prefix, String uri) throws SAXException
- {
- this.startPrefixMapping(prefix,uri, true);
- }
-
- /**
- * This method is used when a prefix/uri namespace mapping
- * is indicated after the element was started with a
- * startElement() and before and endElement().
- * startPrefixMapping(prefix,uri) would be used before the
- * startElement() call.
- * @param uri the URI of the namespace
- * @param prefix the prefix associated with the given URI.
- *
- * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
- */
- public void namespaceAfterStartElement(String prefix, String uri)
- throws SAXException
- {
- // hack for XSLTC with finding URI for default namespace
- if (m_firstTagNotEmitted && m_firstElementURI == null && m_firstElementName != null)
- {
- String prefix1 = getPrefixPart(m_firstElementName);
- if (prefix1 == null && EMPTYSTRING.equals(prefix))
- {
- // the elements URI is not known yet, and it
- // doesn't have a prefix, and we are currently
- // setting the uri for prefix "", so we have
- // the uri for the element... lets remember it
- m_firstElementURI = uri;
- }
- }
- startPrefixMapping(prefix,uri, false);
- }
-
- public boolean startPrefixMapping(String prefix, String uri, boolean shouldFlush)
- throws SAXException
- {
- boolean pushed = false;
- if (m_firstTagNotEmitted)
- {
- if (m_firstElementName != null && shouldFlush)
- {
- /* we've already seen a startElement, and this is a prefix mapping
- * for the up coming element, so flush the old element
- * then send this event on its way.
- */
- flush();
- pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
- }
- else
- {
- if (m_namespacePrefix == null)
- {
- m_namespacePrefix = new Vector();
- m_namespaceURI = new Vector();
- }
- m_namespacePrefix.addElement(prefix);
- m_namespaceURI.addElement(uri);
-
- if (m_firstElementURI == null)
- {
- if (prefix.equals(m_firstElementPrefix))
- m_firstElementURI = uri;
- }
- }
-
- }
- else
- {
- pushed = m_handler.startPrefixMapping(prefix, uri, shouldFlush);
- }
- return pushed;
- }
-
- /**
- * This method cannot be cached because default is different in
- * HTML and XML (we need more than a boolean).
- */
-
- public void setVersion(String version)
- {
- m_handler.setVersion(version);
-
- // Cache call to setVersion()
- // super.setVersion(version);
- m_setVersion_called = true;
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startDocument()
- */
- public void startDocument() throws SAXException
- {
- m_needToCallStartDocument = true;
- }
-
-
-
- public void startElement(String qName) throws SAXException
- {
- this.startElement(null, null, qName, null);
- }
-
- public void startElement(String namespaceURI, String localName, String qName) throws SAXException
- {
- this.startElement(namespaceURI, localName, qName, null);
- }
-
- public void startElement(
- String namespaceURI,
- String localName,
- String elementName,
- Attributes atts) throws SAXException
- {
- /* we are notified of the start of an element */
- if (m_firstTagNotEmitted)
- {
- /* we have not yet sent the first element on its way */
- if (m_firstElementName != null)
- {
- /* this is not the first element, but a later one.
- * But we have the old element pending, so flush it out,
- * then send this one on its way.
- */
- flush();
- m_handler.startElement(namespaceURI, localName, elementName, atts);
- }
- else
- {
- /* this is the very first element that we have seen,
- * so save it for flushing later. We may yet get to know its
- * URI due to added attributes.
- */
-
- m_wrapped_handler_not_initialized = true;
- m_firstElementName = elementName;
-
- // null if not known
- m_firstElementPrefix = getPrefixPartUnknown(elementName);
-
- // null if not known
- m_firstElementURI = namespaceURI;
-
- // null if not known
- m_firstElementLocalName = localName;
-
- if (m_tracer != null)
- firePseudoElement(elementName);
-
- /* we don't want to call our own addAttributes, which
- * merely delegates to the wrapped handler, but we want to
- * add these attributes to m_attributes. So me must call super.
- * addAttributes() In this case m_attributes is only used for the
- * first element, after that this class totally delegates to the
- * wrapped handler which is either XML or HTML.
- */
- if (atts != null)
- super.addAttributes(atts);
-
- // if there are attributes, then lets make the flush()
- // call the startElement on the handler and send the
- // attributes on their way.
- if (atts != null)
- flush();
-
- }
- }
- else
- {
- // this is not the first element, but a later one, so just
- // send it on its way.
- m_handler.startElement(namespaceURI, localName, elementName, atts);
- }
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see ExtendedLexicalHandler#comment(String)
- */
- public void comment(String comment) throws SAXException
- {
- if (m_firstTagNotEmitted && m_firstElementName != null)
- {
- emitFirstTag();
- }
- else if (m_needToCallStartDocument)
- {
- m_handler.startDocument();
- m_needToCallStartDocument = false;
- }
-
- m_handler.comment(comment);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getDoctypePublic()
- */
- public String getDoctypePublic()
- {
-
- return m_handler.getDoctypePublic();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getDoctypeSystem()
- */
- public String getDoctypeSystem()
- {
- return m_handler.getDoctypeSystem();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getEncoding()
- */
- public String getEncoding()
- {
- return m_handler.getEncoding();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getIndent()
- */
- public boolean getIndent()
- {
- return m_handler.getIndent();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getIndentAmount()
- */
- public int getIndentAmount()
- {
- return m_handler.getIndentAmount();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getMediaType()
- */
- public String getMediaType()
- {
- return m_handler.getMediaType();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getOmitXMLDeclaration()
- */
- public boolean getOmitXMLDeclaration()
- {
- return m_handler.getOmitXMLDeclaration();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getStandalone()
- */
- public String getStandalone()
- {
- return m_handler.getStandalone();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#getVersion()
- */
- public String getVersion()
- {
- return m_handler.getVersion();
- }
-
- /**
- * @see XSLOutputAttributes#setDoctype(String, String)
- */
- public void setDoctype(String system, String pub)
- {
- m_handler.setDoctypePublic(pub);
- m_handler.setDoctypeSystem(system);
- }
-
- /**
- * Set the doctype in the underlying XML handler. Remember that this method
- * was called, just in case we need to transfer this doctype to an HTML handler
- * @param doctype the public doctype to set
- * @see XSLOutputAttributes#setDoctypePublic(String)
- */
- public void setDoctypePublic(String doctype)
- {
- m_handler.setDoctypePublic(doctype);
- m_setDoctypePublic_called = true;
- }
-
- /**
- * Set the doctype in the underlying XML handler. Remember that this method
- * was called, just in case we need to transfer this doctype to an HTML handler
- * @param doctype the system doctype to set
- * @see XSLOutputAttributes#setDoctypeSystem(String)
- */
- public void setDoctypeSystem(String doctype)
- {
- m_handler.setDoctypeSystem(doctype);
- m_setDoctypeSystem_called = true;
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#setEncoding(String)
- */
- public void setEncoding(String encoding)
- {
- m_handler.setEncoding(encoding);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#setIndent(boolean)
- */
- public void setIndent(boolean indent)
- {
- m_handler.setIndent(indent);
- }
-
- /**
- * Pass the call on to the underlying handler
- */
- public void setIndentAmount(int value)
- {
- m_handler.setIndentAmount(value);
- }
-
- /**
- * @see XSLOutputAttributes#setMediaType(String)
- */
- public void setMediaType(String mediaType)
- {
- m_handler.setMediaType(mediaType);
- m_setMediaType_called = true;
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#setOmitXMLDeclaration(boolean)
- */
- public void setOmitXMLDeclaration(boolean b)
- {
- m_handler.setOmitXMLDeclaration(b);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see XSLOutputAttributes#setStandalone(String)
- */
- public void setStandalone(String standalone)
- {
- m_handler.setStandalone(standalone);
- }
-
- /**
- * @see XSLOutputAttributes#setVersion(String)
- */
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
- */
- public void attributeDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3,
- String arg4)
- throws SAXException
- {
- m_handler.attributeDecl(arg0, arg1, arg2, arg3, arg4);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
- */
- public void elementDecl(String arg0, String arg1) throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- emitFirstTag();
- }
- m_handler.elementDecl(arg0, arg1);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
- */
- public void externalEntityDecl(
- String name,
- String publicId,
- String systemId)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.externalEntityDecl(name, publicId, systemId);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
- */
- public void internalEntityDecl(String arg0, String arg1)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.internalEntityDecl(arg0, arg1);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] characters, int offset, int length)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
-
- m_handler.characters(characters, offset, length);
-
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
-
- m_handler.endDocument();
-
-
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#endElement(String, String, String)
- */
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- if (namespaceURI == null && m_firstElementURI != null)
- namespaceURI = m_firstElementURI;
-
-
- if (localName == null && m_firstElementLocalName != null)
- localName = m_firstElementLocalName;
- }
-
- m_handler.endElement(namespaceURI, localName, qName);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
- */
- public void endPrefixMapping(String prefix) throws SAXException
- {
- m_handler.endPrefixMapping(prefix);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] ch, int start, int length)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
- m_handler.ignorableWhitespace(ch, start, length);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
- */
- public void processingInstruction(String target, String data)
- throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
-
- m_handler.processingInstruction(target, data);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
- */
- public void setDocumentLocator(Locator locator)
- {
- m_handler.setDocumentLocator(locator);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ContentHandler#skippedEntity(String)
- */
- public void skippedEntity(String name) throws SAXException
- {
- m_handler.skippedEntity(name);
- }
-
-
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
- */
- public void comment(char[] ch, int start, int length) throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- flush();
- }
-
- m_handler.comment(ch, start, length);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
-
- m_handler.endCDATA();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#endDTD()
- */
- public void endDTD() throws SAXException
- {
-
- m_handler.endDTD();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#endEntity(String)
- */
- public void endEntity(String name) throws SAXException
- {
- if (m_firstTagNotEmitted)
- {
- emitFirstTag();
- }
- m_handler.endEntity(name);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#startCDATA()
- */
- public void startCDATA() throws SAXException
- {
- m_handler.startCDATA();
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#startDTD(String, String, String)
- */
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException
- {
- m_handler.startDTD(name, publicId, systemId);
- }
-
- /**
- * Pass the call on to the underlying handler
- * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
- */
- public void startEntity(String name) throws SAXException
- {
- m_handler.startEntity(name);
- }
-
- /**
- * Initialize the wrapped output stream (XML or HTML).
- * If the stream handler should be HTML, then replace the XML handler with
- * an HTML handler. After than send the starting method calls that were cached
- * to the wrapped handler.
- *
- */
- private void initStreamOutput() throws SAXException
- {
-
- // Try to rule out if this is an not to be an HTML document based on prefix
- boolean firstElementIsHTML = isFirstElemHTML();
-
- if (firstElementIsHTML)
- {
- // create an HTML output handler, and initialize it
-
- // keep a reference to the old handler, ... it will soon be gone
- SerializationHandler oldHandler = m_handler;
-
- /* We have to make sure we get an output properties with the proper
- * defaults for the HTML method. The easiest way to do this is to
- * have the OutputProperties class do it.
- */
-
- Properties htmlProperties =
- OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
- Serializer serializer =
- SerializerFactory.getSerializer(htmlProperties);
-
- // The factory should be returning a ToStream
- // Don't know what to do if it doesn't
- // i.e. the user has over-ridden the content-handler property
- // for html
- m_handler = (SerializationHandler) serializer;
- //m_handler = new ToHTMLStream();
-
- Writer writer = oldHandler.getWriter();
-
- if (null != writer)
- m_handler.setWriter(writer);
- else
- {
- OutputStream os = oldHandler.getOutputStream();
-
- if (null != os)
- m_handler.setOutputStream(os);
- }
-
- // need to copy things from the old handler to the new one here
-
- // if (_setVersion_called)
- // {
- m_handler.setVersion(oldHandler.getVersion());
- // }
- // if (_setDoctypeSystem_called)
- // {
- m_handler.setDoctypeSystem(oldHandler.getDoctypeSystem());
- // }
- // if (_setDoctypePublic_called)
- // {
- m_handler.setDoctypePublic(oldHandler.getDoctypePublic());
- // }
- // if (_setMediaType_called)
- // {
- m_handler.setMediaType(oldHandler.getMediaType());
- // }
-
- m_handler.setTransformer(oldHandler.getTransformer());
- }
-
- /* Now that we have a real wrapped handler (XML or HTML) lets
- * pass any cached calls to it
- */
- // Call startDocument() if necessary
- if (m_needToCallStartDocument)
- {
- m_handler.startDocument();
- m_needToCallStartDocument = false;
- }
-
- // the wrapped handler is now fully initialized
- m_wrapped_handler_not_initialized = false;
- }
-
- private void emitFirstTag() throws SAXException
- {
- if (m_firstElementName != null)
- {
- if (m_wrapped_handler_not_initialized)
- {
- initStreamOutput();
- m_wrapped_handler_not_initialized = false;
- }
- // Output first tag
- m_handler.startElement(m_firstElementURI, null, m_firstElementName, m_attributes);
- // don't need the collected attributes of the first element anymore.
- m_attributes = null;
-
- // Output namespaces of first tag
- if (m_namespacePrefix != null)
- {
- final int n = m_namespacePrefix.size();
- for (int i = 0; i < n; i++)
- {
- final String prefix =
- (String) m_namespacePrefix.elementAt(i);
- final String uri = (String) m_namespaceURI.elementAt(i);
- m_handler.startPrefixMapping(prefix, uri, false);
- }
- m_namespacePrefix = null;
- m_namespaceURI = null;
- }
- m_firstTagNotEmitted = false;
- }
- }
-
- /**
- * Utility function for calls to local-name().
- *
- * Don't want to override static function on SerializerBase
- * So added Unknown suffix to method name.
- */
- private String getLocalNameUnknown(String value)
- {
- int idx = value.lastIndexOf(':');
- if (idx >= 0)
- value = value.substring(idx + 1);
- idx = value.lastIndexOf('@');
- if (idx >= 0)
- value = value.substring(idx + 1);
- return (value);
- }
-
- /**
- * Utility function to return prefix
- *
- * Don't want to override static function on SerializerBase
- * So added Unknown suffix to method name.
- */
- private String getPrefixPartUnknown(String qname)
- {
- final int index = qname.indexOf(':');
- return (index > 0) ? qname.substring(0, index) : EMPTYSTRING;
- }
-
- /**
- * Determine if the firts element in the document is <html> or <HTML>
- * This uses the cached first element name, first element prefix and the
- * cached namespaces from previous method calls
- *
- * @return true if the first element is an opening <html> tag
- */
- private boolean isFirstElemHTML()
- {
- boolean isHTML;
-
- // is the first tag html, not considering the prefix ?
- isHTML =
- getLocalNameUnknown(m_firstElementName).equalsIgnoreCase("html");
-
- // Try to rule out if this is not to be an HTML document based on URI
- if (isHTML
- && m_firstElementURI != null
- && !EMPTYSTRING.equals(m_firstElementURI))
- {
- // the <html> element has a non-trivial namespace
- isHTML = false;
- }
- // Try to rule out if this is an not to be an HTML document based on prefix
- if (isHTML && m_namespacePrefix != null)
- {
- /* the first element has a name of "html", but lets check the prefix.
- * If the prefix points to a namespace with a URL that is not ""
- * then the doecument doesn't start with an <html> tag, and isn't html
- */
- final int max = m_namespacePrefix.size();
- for (int i = 0; i < max; i++)
- {
- final String prefix = (String) m_namespacePrefix.elementAt(i);
- final String uri = (String) m_namespaceURI.elementAt(i);
-
- if (m_firstElementPrefix != null
- && m_firstElementPrefix.equals(prefix)
- && !EMPTYSTRING.equals(uri))
- {
- // The first element has a prefix, so it can't be <html>
- isHTML = false;
- break;
- }
- }
-
- }
- return isHTML;
- }
- /**
- * @see Serializer#asDOMSerializer()
- */
- public DOMSerializer asDOMSerializer() throws IOException
- {
- return m_handler.asDOMSerializer();
- }
-
- /**
- * @param URI_and_localNames Vector a list of pairs of URI/localName
- * specified in the cdata-section-elements attribute.
- * @see SerializationHandler#setCdataSectionElements(java.util.Vector)
- */
- public void setCdataSectionElements(Vector URI_and_localNames)
- {
- m_handler.setCdataSectionElements(URI_and_localNames);
- }
- /**
- * @see ExtendedContentHandler#addAttributes(org.xml.sax.Attributes)
- */
- public void addAttributes(Attributes atts) throws SAXException
- {
- m_handler.addAttributes(atts);
- }
-
- /**
- * Get the current namespace mappings.
- * Simply returns the mappings of the wrapped handler.
- * @see ExtendedContentHandler#getNamespaceMappings()
- */
- public NamespaceMappings getNamespaceMappings()
- {
- NamespaceMappings mappings = null;
- if (m_handler != null)
- {
- mappings = m_handler.getNamespaceMappings();
- }
- return mappings;
- }
- /**
- * @see SerializationHandler#flushPending()
- */
- public void flushPending() throws SAXException
- {
-
- flush();
-
- m_handler.flushPending();
- }
-
- private void flush()
- {
- try
- {
- if (m_firstTagNotEmitted)
- {
- emitFirstTag();
- }
- if (m_needToCallStartDocument)
- {
- m_handler.startDocument();
- m_needToCallStartDocument = false;
- }
- }
- catch(SAXException e)
- {
- throw new RuntimeException(e.toString());
- }
-
-
- }
-
- /**
- * @see ExtendedContentHandler#getPrefix
- */
- public String getPrefix(String namespaceURI)
- {
- return m_handler.getPrefix(namespaceURI);
- }
- /**
- * @see ExtendedContentHandler#entityReference(java.lang.String)
- */
- public void entityReference(String entityName) throws SAXException
- {
- m_handler.entityReference(entityName);
- }
-
- /**
- * @see ExtendedContentHandler#getNamespaceURI(java.lang.String, boolean)
- */
- public String getNamespaceURI(String qname, boolean isElement)
- {
- return m_handler.getNamespaceURI(qname, isElement);
- }
-
- public String getNamespaceURIFromPrefix(String prefix)
- {
- return m_handler.getNamespaceURIFromPrefix(prefix);
- }
-
- public void setTransformer(Transformer t)
- {
- m_handler.setTransformer(t);
- if ((t instanceof SerializerTrace) &&
- (((SerializerTrace) t).hasTraceListeners())) {
- m_tracer = (SerializerTrace) t;
- } else {
- m_tracer = null;
- }
- }
- public Transformer getTransformer()
- {
- return m_handler.getTransformer();
- }
-
- /**
- * @see SerializationHandler#setContentHandler(org.xml.sax.ContentHandler)
- */
- public void setContentHandler(ContentHandler ch)
- {
- m_handler.setContentHandler(ch);
- }
- /**
- * This method is used to set the source locator, which might be used to
- * generated an error message.
- * @param locator the source locator
- *
- * @see ExtendedContentHandler#setSourceLocator(javax.xml.transform.SourceLocator)
- */
- public void setSourceLocator(SourceLocator locator)
- {
- m_handler.setSourceLocator(locator);
- }
-
- protected void firePseudoElement(String elementName)
- {
-
- if (m_tracer != null) {
- StringBuffer sb = new StringBuffer();
-
- sb.append('<');
- sb.append(elementName);
-
- // convert the StringBuffer to a char array and
- // emit the trace event that these characters "might"
- // be written
- char ch[] = sb.toString().toCharArray();
- m_tracer.fireGenerateEvent(
- SerializerTrace.EVENTTYPE_OUTPUT_PSEUDO_CHARACTERS,
- ch,
- 0,
- ch.length);
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXHTMLStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,2355 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToXHTMLStream.java,v 1.1.2.1 2007/01/09 18:57:19 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Properties;
-
-import javax.xml.transform.Result;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-
-/**
- * This serializer takes a series of SAX or
- * SAX-like events and writes its output
- * to the given stream.
- *
- * This class is not a public API, it is public
- * because it is used from another package.
- *
- * @xsl.usage internal
- */
-public final class ToXHTMLStream extends ToStream
-{
-
- /** This flag is set while receiving events from the DTD */
- protected boolean m_inDTD = false;
-
- /** True if the current element is a block element. (seems like
- * this needs to be a stack. -sb). */
- private boolean m_inBlockElem = false;
-
- /**
- * Map that tells which XML characters should have special treatment, and it
- * provides character to entity name lookup.
- */
- private static final CharInfo m_htmlcharInfo =
-// new CharInfo(CharInfo.HTML_ENTITIES_RESOURCE);
- // Asmirnov - disable HTML Entities.
- CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XHTML);
-
- /** A digital search trie for fast, case insensitive lookup of ElemDesc objects. */
- static final Trie m_elementFlags = new Trie();
-
- static {
- initTagReference(m_elementFlags);
- }
- static void initTagReference(Trie m_elementFlags) {
-
- // HTML 4.0 loose DTD
- m_elementFlags.put("BASEFONT", new ElemDesc(0 | ElemDesc.EMPTY));
- m_elementFlags.put(
- "FRAME",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put("FRAMESET", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("NOFRAMES", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "ISINDEX",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "APPLET",
- new ElemDesc(0 | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put("CENTER", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("DIR", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("MENU", new ElemDesc(0 | ElemDesc.BLOCK));
-
- // HTML 4.0 strict DTD
- m_elementFlags.put("TT", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("I", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("B", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("BIG", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("SMALL", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("EM", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("STRONG", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("DFN", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("CODE", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("SAMP", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("KBD", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("VAR", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("CITE", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("ABBR", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put("ACRONYM", new ElemDesc(0 | ElemDesc.PHRASE));
- m_elementFlags.put(
- "SUP",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "SUB",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "SPAN",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BDO",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BR",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.EMPTY
- | ElemDesc.BLOCK));
- m_elementFlags.put("BODY", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "ADDRESS",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put(
- "DIV",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("A", new ElemDesc(0 | ElemDesc.SPECIAL));
- m_elementFlags.put(
- "MAP",
- new ElemDesc(
- 0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL | ElemDesc.BLOCK));
- m_elementFlags.put(
- "AREA",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "LINK",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "IMG",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.EMPTY
- | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put(
- "OBJECT",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.HEADMISC
- | ElemDesc.WHITESPACESENSITIVE));
- m_elementFlags.put("PARAM", new ElemDesc(0 | ElemDesc.EMPTY));
- m_elementFlags.put(
- "HR",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET
- | ElemDesc.EMPTY));
- m_elementFlags.put(
- "P",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put(
- "H1",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H2",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H3",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H4",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H5",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "H6",
- new ElemDesc(0 | ElemDesc.HEAD | ElemDesc.BLOCK));
- m_elementFlags.put(
- "PRE",
- new ElemDesc(0 | ElemDesc.PREFORMATTED | ElemDesc.BLOCK));
- m_elementFlags.put(
- "Q",
- new ElemDesc(0 | ElemDesc.SPECIAL | ElemDesc.ASPECIAL));
- m_elementFlags.put(
- "BLOCKQUOTE",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("INS", new ElemDesc(0));
- m_elementFlags.put("DEL", new ElemDesc(0));
- m_elementFlags.put(
- "DL",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("DT", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("DD", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "OL",
- new ElemDesc(0 | ElemDesc.LIST | ElemDesc.BLOCK));
- m_elementFlags.put(
- "UL",
- new ElemDesc(0 | ElemDesc.LIST | ElemDesc.BLOCK));
- m_elementFlags.put("LI", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("FORM", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("LABEL", new ElemDesc(0 | ElemDesc.FORMCTRL));
- m_elementFlags.put(
- "INPUT",
- new ElemDesc(
- 0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL | ElemDesc.EMPTY));
- m_elementFlags.put(
- "SELECT",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put("OPTGROUP", new ElemDesc(0));
- m_elementFlags.put("OPTION", new ElemDesc(0));
- m_elementFlags.put(
- "TEXTAREA",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put(
- "FIELDSET",
- new ElemDesc(0 | ElemDesc.BLOCK | ElemDesc.BLOCKFORM));
- m_elementFlags.put("LEGEND", new ElemDesc(0));
- m_elementFlags.put(
- "BUTTON",
- new ElemDesc(0 | ElemDesc.FORMCTRL | ElemDesc.INLINELABEL));
- m_elementFlags.put(
- "TABLE",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("CAPTION", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("THEAD", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TFOOT", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TBODY", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("COLGROUP", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "COL",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put("TR", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put("TH", new ElemDesc(0));
- m_elementFlags.put("TD", new ElemDesc(0));
- m_elementFlags.put(
- "HEAD",
- new ElemDesc(0 | ElemDesc.BLOCK | ElemDesc.HEADELEM));
- m_elementFlags.put("TITLE", new ElemDesc(0 | ElemDesc.BLOCK));
- m_elementFlags.put(
- "BASE",
- new ElemDesc(0 | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "META",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC | ElemDesc.EMPTY | ElemDesc.BLOCK));
- m_elementFlags.put(
- "STYLE",
- new ElemDesc(
- 0 | ElemDesc.HEADMISC /* | ElemDesc.RAW */ | ElemDesc.BLOCK));
- m_elementFlags.put(
- "SCRIPT",
- new ElemDesc(
- 0
- | ElemDesc.SPECIAL
- | ElemDesc.ASPECIAL
- | ElemDesc.HEADMISC
- /* | ElemDesc.RAW */));
- m_elementFlags.put(
- "NOSCRIPT",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- m_elementFlags.put("HTML", new ElemDesc(0 | ElemDesc.BLOCK));
-
- // From "John Ky" <hand(a)syd.speednet.com.au
- // Transitional Document Type Definition ()
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/sgml/loosedtd.html#basefont
- m_elementFlags.put("FONT", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/present/graphics.html#edef-STRIKE
- m_elementFlags.put("S", new ElemDesc(0 | ElemDesc.FONTSTYLE));
- m_elementFlags.put("STRIKE", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // file:///C:/Documents%20and%20Settings/sboag.BOAG600E/My%20Documents/html/present/graphics.html#edef-U
- m_elementFlags.put("U", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // From "John Ky" <hand(a)syd.speednet.com.au
- m_elementFlags.put("NOBR", new ElemDesc(0 | ElemDesc.FONTSTYLE));
-
- // HTML 4.0, section 16.5
- m_elementFlags.put(
- "IFRAME",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
-
- // Netscape 4 extension
- m_elementFlags.put(
- "LAYER",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
- // Netscape 4 extension
- m_elementFlags.put(
- "ILAYER",
- new ElemDesc(
- 0
- | ElemDesc.BLOCK
- | ElemDesc.BLOCKFORM
- | ElemDesc.BLOCKFORMFIELDSET));
-
-
- // NOW FOR ATTRIBUTE INFORMATION . . .
- ElemDesc elemDesc;
-
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("A");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
- elemDesc.setAttr("NAME", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("AREA");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
- elemDesc.setAttr("NOHREF", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BASE");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BUTTON");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("BLOCKQUOTE");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DEL");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DIR");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
-
- elemDesc = (ElemDesc) m_elementFlags.get("DIV");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL); // Netscape 4 extension
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("DL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("FORM");
- elemDesc.setAttr("ACTION", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Attribution to: "Voytenko, Dimitry" <DVoytenko(a)SECTORBASE.COM>
- elemDesc = (ElemDesc) m_elementFlags.get("FRAME");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
- elemDesc.setAttr("NORESIZE",ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("HEAD");
- elemDesc.setAttr("PROFILE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("HR");
- elemDesc.setAttr("NOSHADE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- // HTML 4.0, section 16.5
- elemDesc = (ElemDesc) m_elementFlags.get("IFRAME");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Netscape 4 extension
- elemDesc = (ElemDesc) m_elementFlags.get("ILAYER");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("IMG");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("LONGDESC", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("INPUT");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("CHECKED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("ISMAP", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("INS");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- // Netscape 4 extension
- elemDesc = (ElemDesc) m_elementFlags.get("LAYER");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("LINK");
- elemDesc.setAttr("HREF", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("MENU");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OBJECT");
- elemDesc.setAttr("CLASSID", ElemDesc.ATTRURL);
- elemDesc.setAttr("CODEBASE", ElemDesc.ATTRURL);
- elemDesc.setAttr("DATA", ElemDesc.ATTRURL);
- elemDesc.setAttr("ARCHIVE", ElemDesc.ATTRURL);
- elemDesc.setAttr("USEMAP", ElemDesc.ATTRURL);
- elemDesc.setAttr("DECLARE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OPTGROUP");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("OPTION");
- elemDesc.setAttr("SELECTED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("Q");
- elemDesc.setAttr("CITE", ElemDesc.ATTRURL);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("SCRIPT");
- elemDesc.setAttr("SRC", ElemDesc.ATTRURL);
- elemDesc.setAttr("FOR", ElemDesc.ATTRURL);
- elemDesc.setAttr("DEFER", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("SELECT");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("MULTIPLE", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TABLE");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY); // Internet-Explorer extension
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TD");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TEXTAREA");
- elemDesc.setAttr("DISABLED", ElemDesc.ATTREMPTY);
- elemDesc.setAttr("READONLY", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("TH");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- // The nowrap attribute of a tr element is both
- // a Netscape and Internet-Explorer extension
- elemDesc = (ElemDesc) m_elementFlags.get("TR");
- elemDesc.setAttr("NOWRAP", ElemDesc.ATTREMPTY);
-
- // ----------------------------------------------
- elemDesc = (ElemDesc) m_elementFlags.get("UL");
- elemDesc.setAttr("COMPACT", ElemDesc.ATTREMPTY);
- }
-
- /**
- * Dummy element for elements not found.
- */
- static private final ElemDesc m_dummy = new ElemDesc(0 | ElemDesc.BLOCK);
-
- public static final String XHTML_NAMESPACE_URI = "http://www.w3.org/1999/xhtml";
-
- /** True if URLs should be specially escaped with the %xx form. */
- private boolean m_specialEscapeURLs = true;
-
- /** True if the META tag should be omitted. */
- private boolean m_omitMetaTag = false;
-
- /**
- * Tells if the formatter should use special URL escaping.
- *
- * @param bool True if URLs should be specially escaped with the %xx form.
- */
- public void setSpecialEscapeURLs(boolean bool)
- {
- m_specialEscapeURLs = bool;
- }
-
- /**
- * Tells if the formatter should omit the META tag.
- *
- * @param bool True if the META tag should be omitted.
- */
- public void setOmitMetaTag(boolean bool)
- {
- m_omitMetaTag = bool;
- }
-
- /**
- * Specifies an output format for this serializer. It the
- * serializer has already been associated with an output format,
- * it will switch to the new format. This method should not be
- * called while the serializer is in the process of serializing
- * a document.
- *
- * This method can be called multiple times before starting
- * the serialization of a particular result-tree. In principle
- * all serialization parameters can be changed, with the exception
- * of method="html" (it must be method="html" otherwise we
- * shouldn't even have a ToHTMLStream object here!)
- *
- * @param format The output format or serialzation parameters
- * to use.
- */
- public void setOutputFormat(Properties format)
- {
-
- m_specialEscapeURLs =
- OutputPropertyUtils.getBooleanProperty(
- OutputPropertiesFactory.S_USE_URL_ESCAPING,
- format);
-
- m_omitMetaTag =
- OutputPropertyUtils.getBooleanProperty(
- OutputPropertiesFactory.S_OMIT_META_TAG,
- format);
-
- super.setOutputFormat(format);
- }
-
- /**
- * Tells if the formatter should use special URL escaping.
- *
- * @return True if URLs should be specially escaped with the %xx form.
- */
- private final boolean getSpecialEscapeURLs()
- {
- return m_specialEscapeURLs;
- }
-
- /**
- * Tells if the formatter should omit the META tag.
- *
- * @return True if the META tag should be omitted.
- */
- private final boolean getOmitMetaTag()
- {
- return m_omitMetaTag;
- }
-
- /**
- * Get a description of the given element.
- *
- * @param name non-null name of element, case insensitive.
- *
- * @return non-null reference to ElemDesc, which may be m_dummy if no
- * element description matches the given name.
- */
- public static final ElemDesc getElemDesc(String name)
- {
- /* this method used to return m_dummy when name was null
- * but now it doesn't check and and requires non-null name.
- */
- Object obj = m_elementFlags.get(name);
- if (null != obj)
- return (ElemDesc)obj;
- return m_dummy;
- }
-
- /**
- * A Trie that is just a copy of the "static" one.
- * We need this one to be able to use the faster, but not thread-safe
- * method Trie.get2(name)
- */
- private Trie m_htmlInfo = new Trie(m_elementFlags);
- /**
- * Calls to this method could be replaced with calls to
- * getElemDesc(name), but this one should be faster.
- */
- private ElemDesc getElemDesc2(String name)
- {
- Object obj = m_htmlInfo.get2(name);
- if (null != obj)
- return (ElemDesc)obj;
- return m_dummy;
- }
-
- /**
- * Default constructor.
- */
- public ToXHTMLStream()
- {
-
- super();
- m_charInfo = m_htmlcharInfo;
- // initialize namespaces
- m_prefixMap = new NamespaceMappings();
-
- }
-
- /** The name of the current element. */
-// private String m_currentElementName = null;
-
- /**
- * Receive notification of the beginning of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void startDocumentInternal() throws org.xml.sax.SAXException
- {
- super.startDocumentInternal();
-
- m_needToCallStartDocument = false;
- m_needToOutputDocTypeDecl = true;
- m_startNewLine = false;
-// setOmitXMLDeclaration(true);
-
- /* The call to getXMLVersion() might emit an error message
- * and we should emit this message regardless of if we are
- * writing out an XML header or not.
- */
- final String version = XMLVERSION10;
- if (getOmitXMLDeclaration() == false)
- {
- String encoding = Encodings.getMimeEncoding(getEncoding());
- String standalone;
-
- if (m_standaloneWasSpecified)
- {
- standalone = " standalone=\"" + getStandalone() + "\"";
- }
- else
- {
- standalone = "";
- }
-
- try
- {
- final java.io.Writer writer = m_writer;
- writer.write("<?xml version=\"");
- writer.write(version);
- writer.write("\" encoding=\"");
- writer.write(encoding);
- writer.write('\"');
- writer.write(standalone);
- writer.write("?>");
- if (m_doIndent)
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
-
- }
-
- if (true == m_needToOutputDocTypeDecl)
- {
- String doctypeSystem = getDoctypeSystem();
- String doctypePublic = getDoctypePublic();
- if ((null != doctypeSystem) || (null != doctypePublic))
- {
- final java.io.Writer writer = m_writer;
- try
- {
- writer.write("<!DOCTYPE html");
-
- if (null != doctypePublic)
- {
- writer.write(" PUBLIC \"");
- writer.write(doctypePublic);
- writer.write('"');
- }
-
- if (null != doctypeSystem)
- {
- if (null == doctypePublic)
- writer.write(" SYSTEM \"");
- else
- writer.write(" \"");
-
- writer.write(doctypeSystem);
- writer.write('"');
- }
-
- writer.write('>');
- outputLineSep();
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- }
-
- m_needToOutputDocTypeDecl = false;
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public final void endDocument() throws org.xml.sax.SAXException
- {
-
- flushPending();
- if (m_doIndent && !m_isprevtext)
- {
- try
- {
- outputLineSep();
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- flushWriter();
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * Receive notification of the beginning of an element.
- *
- *
- * @param namespaceURI
- * @param localName
- * @param name The element type name.
- * @param atts The attributes attached to the element, if any.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #endElement
- * @see org.xml.sax.AttributeList
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String name,
- Attributes atts)
- throws org.xml.sax.SAXException
- {
-
- ElemContext elemContext = m_elemContext;
-
- // clean up any pending things first
- if (elemContext.m_startTagOpen)
- {
- closeStartTag();
- elemContext.m_startTagOpen = false;
- }
- else if (m_cdataTagOpen)
- {
- closeCDATA();
- m_cdataTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
-
-
- // if this element has a namespace then treat it like XML
- if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
- {
- super.startElement(namespaceURI, localName, name, atts);
-
- return;
- }
-
- try
- {
- // getElemDesc2(name) is faster than getElemDesc(name)
- ElemDesc elemDesc = getElemDesc2(name);
- int elemFlags = elemDesc.getFlags();
-
- // deal with indentation issues first
- if (m_doIndent)
- {
-
- boolean isBlockElement = (elemFlags & ElemDesc.BLOCK) != 0;
- if (m_ispreserve)
- m_ispreserve = false;
- else if (
- (null != elemContext.m_elementName)
- && (!m_inBlockElem
- || isBlockElement) /* && !isWhiteSpaceSensitive */
- )
- {
- m_startNewLine = true;
-
- indent();
-
- }
- m_inBlockElem = !isBlockElement;
- }
-
- // save any attributes for later processing
- if (atts != null)
- addAttributes(atts);
-
- m_isprevtext = false;
- final java.io.Writer writer = m_writer;
- writer.write('<');
- writer.write(name);
-
-
-
- if (m_tracer != null)
- firePseudoAttributes();
-
- if ((elemFlags & ElemDesc.EMPTY) != 0)
- {
- // an optimization for elements which are expected
- // to be empty.
- m_elemContext = elemContext.push();
- /* XSLTC sometimes calls namespaceAfterStartElement()
- * so we need to remember the name
- */
- m_elemContext.m_elementName = name;
- m_elemContext.m_elementDesc = elemDesc;
- return;
- }
- else
- {
- elemContext = elemContext.push(namespaceURI,localName,name);
- m_elemContext = elemContext;
- elemContext.m_elementDesc = elemDesc;
- elemContext.m_isRaw = (elemFlags & ElemDesc.RAW) != 0;
- }
-
-
- if ((elemFlags & ElemDesc.HEADELEM) != 0)
- {
- // This is the <HEAD> element, do some special processing
- closeStartTag();
- elemContext.m_startTagOpen = false;
- if (!m_omitMetaTag)
- {
- if (m_doIndent)
- indent();
- writer.write(
- "<META http-equiv=\"Content-Type\" content=\"text/html;charset=");
- String encoding = getEncoding();
- String encode = Encodings.getMimeEncoding(encoding);
- writer.write(encode);
- writer.write("\">");
- }
- }
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Receive notification of the end of an element.
- *
- *
- * @param namespaceURI
- * @param localName
- * @param name The element type name
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- */
- public final void endElement(
- final String namespaceURI,
- final String localName,
- final String name)
- throws org.xml.sax.SAXException
- {
- // deal with any pending issues
- if (m_cdataTagOpen)
- closeCDATA();
-
- // if the element has a namespace, treat it like XML, not HTML
- if (null != namespaceURI && namespaceURI.length() > 0 && (!XHTML_NAMESPACE_URI.equals(namespaceURI)))
- {
- super.endElement(namespaceURI, localName, name);
-
- return;
- }
-
- try
- {
-
- ElemContext elemContext = m_elemContext;
- final ElemDesc elemDesc = elemContext.m_elementDesc != null?elemContext.m_elementDesc:m_dummy;
- final int elemFlags = elemDesc.getFlags();
- final boolean elemEmpty = (elemFlags & ElemDesc.EMPTY) != 0;
-
- // deal with any indentation issues
- if (m_doIndent)
- {
- final boolean isBlockElement = (elemFlags&ElemDesc.BLOCK) != 0;
- boolean shouldIndent = false;
-
- if (m_ispreserve)
- {
- m_ispreserve = false;
- }
- else if (m_doIndent && (!m_inBlockElem || isBlockElement))
- {
- m_startNewLine = true;
- shouldIndent = true;
- }
- if (!elemContext.m_startTagOpen && shouldIndent)
- indent(elemContext.m_currentElemDepth - 1);
- m_inBlockElem = !isBlockElement;
- }
-
- final java.io.Writer writer = m_writer;
- if (!elemContext.m_startTagOpen)
- {
- writer.write("</");
- writer.write(name);
- writer.write('>');
- }
- else
- {
- // the start-tag open when this method was called,
- // so we need to process it now.
-
- if (m_tracer != null)
- super.fireStartElem(name);
-
- // the starting tag was still open when we received this endElement() call
- // so we need to process any gathered attributes NOW, before they go away.
- int nAttrs = m_attributes.getLength();
- if (nAttrs > 0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
- if (!elemEmpty)
- {
- // As per Dave/Paul recommendation 12/06/2000
- // if (shouldIndent)
- // writer.write('>');
- // indent(m_currentIndent);
-
- writer.write("></");
- writer.write(name);
- writer.write('>');
- }
- else
- {
- writer.write(" />");
- }
- }
-
- // clean up because the element has ended
- if ((elemFlags & ElemDesc.WHITESPACESENSITIVE) != 0)
- m_ispreserve = true;
- m_isprevtext = false;
-
- // fire off the end element event
- if (m_tracer != null)
- super.fireEndElem(name);
-
- // OPTIMIZE-EMPTY
- if (elemEmpty)
- {
- // a quick exit if the HTML element had no children.
- // This block of code can be removed if the corresponding block of code
- // in startElement() also labeled with "OPTIMIZE-EMPTY" is also removed
- m_elemContext = elemContext.m_prev;
- return;
- }
-
- // some more clean because the element has ended.
- if (!elemContext.m_startTagOpen)
- {
- if (m_doIndent && !m_preserves.isEmpty())
- m_preserves.pop();
- }
- m_elemContext = elemContext.m_prev;
-// m_isRawStack.pop();
- }
- catch (IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- /**
- * Process an attribute.
- * @param writer The writer to write the processed output to.
- * @param name The name of the attribute.
- * @param value The value of the attribute.
- * @param elemDesc The description of the HTML element
- * that has this attribute.
- *
- * @throws org.xml.sax.SAXException
- */
- protected void processAttribute(
- java.io.Writer writer,
- String name,
- String value,
- ElemDesc elemDesc)
- throws IOException
- {
- writer.write(' ');
-
- if ( ((value.length() == 0) )
- && elemDesc != null
- && elemDesc.isAttrFlagSet(name, ElemDesc.ATTREMPTY))
- {
- writer.write(name);
- writer.write("=\"");
- writeAttrString(writer, name, this.getEncoding());
- writer.write('"');
- }
- else
- {
- // %REVIEW% %OPT%
- // Two calls to single-char write may NOT
- // be more efficient than one to string-write...
- writer.write(name);
- writer.write("=\"");
- if ( elemDesc != null
- && elemDesc.isAttrFlagSet(name, ElemDesc.ATTRURL))
- writeAttrURI(writer, value, m_specialEscapeURLs);
- else
- writeAttrString(writer, value, this.getEncoding());
- writer.write('"');
-
- }
- }
-
- /**
- * Tell if a character is an ASCII digit.
- */
- private boolean isASCIIDigit(char c)
- {
- return (c >= '0' && c <= '9');
- }
-
- /**
- * Make an integer into an HH hex value.
- * Does no checking on the size of the input, since this
- * is only meant to be used locally by writeAttrURI.
- *
- * @param i must be a value less than 255.
- *
- * @return should be a two character string.
- */
- private static String makeHHString(int i)
- {
- String s = Integer.toHexString(i).toUpperCase();
- if (s.length() == 1)
- {
- s = "0" + s;
- }
- return s;
- }
-
- /**
- * Dmitri Ilyin: Makes sure if the String is HH encoded sign.
- * @param str must be 2 characters long
- *
- * @return true or false
- */
- private boolean isHHSign(String str)
- {
- boolean sign = true;
- try
- {
- char r = (char) Integer.parseInt(str, 16);
- }
- catch (NumberFormatException e)
- {
- sign = false;
- }
- return sign;
- }
-
- /**
- * Write the specified <var>string</var> after substituting non ASCII characters,
- * with <CODE>%HH</CODE>, where HH is the hex of the byte value.
- *
- * @param string String to convert to XML format.
- * @param doURLEscaping True if we should try to encode as
- * per http://www.ietf.org/rfc/rfc2396.txt.
- *
- * @throws org.xml.sax.SAXException if a bad surrogate pair is detected.
- */
- public void writeAttrURI(
- final java.io.Writer writer, String string, boolean doURLEscaping)
- throws IOException
- {
- // http://www.ietf.org/rfc/rfc2396.txt says:
- // A URI is always in an "escaped" form, since escaping or unescaping a
- // completed URI might change its semantics. Normally, the only time
- // escape encodings can safely be made is when the URI is being created
- // from its component parts; each component may have its own set of
- // characters that are reserved, so only the mechanism responsible for
- // generating or interpreting that component can determine whether or
- // not escaping a character will change its semantics. Likewise, a URI
- // must be separated into its components before the escaped characters
- // within those components can be safely decoded.
- //
- // ...So we do our best to do limited escaping of the URL, without
- // causing damage. If the URL is already properly escaped, in theory, this
- // function should not change the string value.
-
- final int end = string.length();
- if (end > m_attrBuff.length)
- {
- m_attrBuff = new char[end*2 + 1];
- }
- string.getChars(0,end, m_attrBuff, 0);
- final char[] chars = m_attrBuff;
-
- int cleanStart = 0;
- int cleanLength = 0;
-
-
- char ch = 0;
- for (int i = 0; i < end; i++)
- {
- ch = chars[i];
-
- if ((ch < 32) || (ch > 126))
- {
- if (cleanLength > 0)
- {
- writer.write(chars, cleanStart, cleanLength);
- cleanLength = 0;
- }
- if (doURLEscaping)
- {
- // Encode UTF16 to UTF8.
- // Reference is Unicode, A Primer, by Tony Graham.
- // Page 92.
-
- // Note that Kay doesn't escape 0x20...
- // if(ch == 0x20) // Not sure about this... -sb
- // {
- // writer.write(ch);
- // }
- // else
- if (ch <= 0x7F)
- {
- writer.write('%');
- writer.write(makeHHString(ch));
- }
- else if (ch <= 0x7FF)
- {
- // Clear low 6 bits before rotate, put high 4 bits in low byte,
- // and set two high bits.
- int high = (ch >> 6) | 0xC0;
- int low = (ch & 0x3F) | 0x80;
- // First 6 bits, + high bit
- writer.write('%');
- writer.write(makeHHString(high));
- writer.write('%');
- writer.write(makeHHString(low));
- }
- else if (Encodings.isHighUTF16Surrogate(ch)) // high surrogate
- {
- // I'm sure this can be done in 3 instructions, but I choose
- // to try and do it exactly like it is done in the book, at least
- // until we are sure this is totally clean. I don't think performance
- // is a big issue with this particular function, though I could be
- // wrong. Also, the stuff below clearly does more masking than
- // it needs to do.
-
- // Clear high 6 bits.
- int highSurrogate = ((int) ch) & 0x03FF;
-
- // Middle 4 bits (wwww) + 1
- // "Note that the value of wwww from the high surrogate bit pattern
- // is incremented to make the uuuuu bit pattern in the scalar value
- // so the surrogate pair don't address the BMP."
- int wwww = ((highSurrogate & 0x03C0) >> 6);
- int uuuuu = wwww + 1;
-
- // next 4 bits
- int zzzz = (highSurrogate & 0x003C) >> 2;
-
- // low 2 bits
- int yyyyyy = ((highSurrogate & 0x0003) << 4) & 0x30;
-
- // Get low surrogate character.
- ch = chars[++i];
-
- // Clear high 6 bits.
- int lowSurrogate = ((int) ch) & 0x03FF;
-
- // put the middle 4 bits into the bottom of yyyyyy (byte 3)
- yyyyyy = yyyyyy | ((lowSurrogate & 0x03C0) >> 6);
-
- // bottom 6 bits.
- int xxxxxx = (lowSurrogate & 0x003F);
-
- int byte1 = 0xF0 | (uuuuu >> 2); // top 3 bits of uuuuu
- int byte2 =
- 0x80 | (((uuuuu & 0x03) << 4) & 0x30) | zzzz;
- int byte3 = 0x80 | yyyyyy;
- int byte4 = 0x80 | xxxxxx;
-
- writer.write('%');
- writer.write(makeHHString(byte1));
- writer.write('%');
- writer.write(makeHHString(byte2));
- writer.write('%');
- writer.write(makeHHString(byte3));
- writer.write('%');
- writer.write(makeHHString(byte4));
- }
- else
- {
- int high = (ch >> 12) | 0xE0; // top 4 bits
- int middle = ((ch & 0x0FC0) >> 6) | 0x80;
- // middle 6 bits
- int low = (ch & 0x3F) | 0x80;
- // First 6 bits, + high bit
- writer.write('%');
- writer.write(makeHHString(high));
- writer.write('%');
- writer.write(makeHHString(middle));
- writer.write('%');
- writer.write(makeHHString(low));
- }
-
- }
- else if (escapingNotNeeded(ch))
- {
- writer.write(ch);
- }
- else
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- // In this character range we have first written out any previously accumulated
- // "clean" characters, then processed the current more complicated character,
- // which may have incremented "i".
- // We now we reset the next possible clean character.
- cleanStart = i + 1;
- }
- // Since http://www.ietf.org/rfc/rfc2396.txt refers to the URI grammar as
- // not allowing quotes in the URI proper syntax, nor in the fragment
- // identifier, we believe that it's OK to double escape quotes.
- else if (ch == '"' || ch == '<' || ch == '>' || ch == '&')
- {
- // If the character is a '%' number number, try to avoid double-escaping.
- // There is a question if this is legal behavior.
-
- // Dmitri Ilyin: to check if '%' number number is invalid. It must be checked if %xx is a sign, that would be encoded
- // The encoded signes are in Hex form. So %xx my be in form %3C that is "<" sign. I will try to change here a little.
-
- // if( ((i+2) < len) && isASCIIDigit(stringArray[i+1]) && isASCIIDigit(stringArray[i+2]) )
-
- // We are no longer escaping '%'
-
- if (cleanLength > 0)
- {
- writer.write(chars, cleanStart, cleanLength);
- cleanLength = 0;
- }
-
-
- // Mike Kay encodes this as ", so he may know something I don't?
- if (doURLEscaping){
- writer.write('%');
- writer.write(makeHHString(ch));
- } else {
- int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true);
-
- if (i != pos)
- {
- i = pos - 1;
- }
-// writer.write("""); // we have to escape this, I guess.
- }
- // We have written out any clean characters, then the escaped '%' and now we
- // We now we reset the next possible clean character.
- cleanStart = i + 1;
- }
- else
- {
- // no processing for this character, just count how
- // many characters in a row that we have that need no processing
- cleanLength++;
- }
- }
-
- // are there any clean characters at the end of the array
- // that we haven't processed yet?
- if (cleanLength > 1)
- {
- // if the whole string can be written out as-is do so
- // otherwise write out the clean chars at the end of the
- // array
- if (cleanStart == 0)
- writer.write(string);
- else
- writer.write(chars, cleanStart, cleanLength);
- }
- else if (cleanLength == 1)
- {
- // a little optimization for 1 clean character
- // (we could have let the previous if(...) handle them all)
- writer.write(ch);
- }
- }
-
- /**
- * Writes the specified <var>string</var> after substituting <VAR>specials</VAR>,
- * and UTF-16 surrogates for character references <CODE>&#xnn</CODE>.
- *
- * @param string String to convert to XML format.
- * @param encoding CURRENTLY NOT IMPLEMENTED.
- *
- * @throws org.xml.sax.SAXException
- */
- public void writeAttrString(
- final java.io.Writer writer, String string, String encoding)
- throws IOException
- {
- final int end = string.length();
- if (end > m_attrBuff.length)
- {
- m_attrBuff = new char[end * 2 + 1];
- }
- string.getChars(0, end, m_attrBuff, 0);
- final char[] chars = m_attrBuff;
-
-
-
- int cleanStart = 0;
- int cleanLength = 0;
-
- char ch = 0;
- for (int i = 0; i < end; i++)
- {
- ch = chars[i];
-
- // System.out.println("SPECIALSSIZE: "+SPECIALSSIZE);
- // System.out.println("ch: "+(int)ch);
- // System.out.println("m_maxCharacter: "+(int)m_maxCharacter);
- // System.out.println("m_attrCharsMap[ch]: "+(int)m_attrCharsMap[ch]);
- if (escapingNotNeeded(ch) && (!m_charInfo.isSpecialAttrChar(ch)))
- {
- cleanLength++;
- }
-// else if ('<' == ch || '>' == ch)
-// {
-// cleanLength++; // no escaping in this case, as specified in 15.2
-// }
-// else if (
-// ('&' == ch) && ((i + 1) < end) && ('{' == chars[i + 1]))
-// {
-// cleanLength++; // no escaping in this case, as specified in 15.2
-// }
- else
- {
- if (cleanLength > 0)
- {
- writer.write(chars,cleanStart,cleanLength);
- cleanLength = 0;
- }
- int pos = accumDefaultEntity(writer, ch, i, chars, end, false, true);
-
- if (i != pos)
- {
- i = pos - 1;
- }
- else
- {
- if (Encodings.isHighUTF16Surrogate(ch))
- {
-
- writeUTF16Surrogate(ch, chars, i, end);
- i++; // two input characters processed
- // this increments by one and the for()
- // loop itself increments by another one.
- }
-
- // The next is kind of a hack to keep from escaping in the case
- // of Shift_JIS and the like.
-
- /*
- else if ((ch < m_maxCharacter) && (m_maxCharacter == 0xFFFF)
- && (ch != 160))
- {
- writer.write(ch); // no escaping in this case
- }
- else
- */
- String outputStringForChar = m_charInfo.getOutputStringForChar(ch);
- if (null != outputStringForChar)
- {
- writer.write(outputStringForChar);
- }
- else if (escapingNotNeeded(ch))
- {
- writer.write(ch); // no escaping in this case
- }
- else
- {
- writer.write("&#");
- writer.write(Integer.toString(ch));
- writer.write(';');
- }
- }
- cleanStart = i + 1;
- }
- } // end of for()
-
- // are there any clean characters at the end of the array
- // that we haven't processed yet?
- if (cleanLength > 1)
- {
- // if the whole string can be written out as-is do so
- // otherwise write out the clean chars at the end of the
- // array
- if (cleanStart == 0)
- writer.write(string);
- else
- writer.write(chars, cleanStart, cleanLength);
- }
- else if (cleanLength == 1)
- {
- // a little optimization for 1 clean character
- // (we could have let the previous if(...) handle them all)
- writer.write(ch);
- }
- }
-
-
-
- /**
- * Receive notification of character data.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param chars The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- public final void characters(char chars[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if (m_elemContext.m_isRaw)
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- m_ispreserve = true;
-
-// With m_ispreserve just set true it looks like shouldIndent()
-// will always return false, so drop any possible indentation.
-// if (shouldIndent())
-// indent();
-
- // writer.write("<![CDATA[");
- // writer.write(chars, start, length);
- writeNormalizedChars(chars, start, length, false, m_lineSepUse);
-
- // writer.write("]]>");
-
- // time to generate characters event
- if (m_tracer != null)
- super.fireCharEvent(chars, start, length);
-
- return;
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(
- Utils.messages.createMessage(
- MsgKey.ER_OIERROR,
- null),
- ioe);
- //"IO error", ioe);
- }
- }
- else
- {
- super.characters(chars, start, length);
- }
- }
-
- /**
- * Receive notification of cdata.
- *
- * <p>The Parser will call this method to report each chunk of
- * character data. SAX parsers may return all contiguous character
- * data in a single chunk, or they may split it into several
- * chunks; however, all of the characters in any single event
- * must come from the same external entity, so that the Locator
- * provides useful information.</p>
- *
- * <p>The application must not attempt to read from the array
- * outside of the specified range.</p>
- *
- * <p>Note that some parsers will report whitespace using the
- * ignorableWhitespace() method rather than this one (validating
- * parsers must do so).</p>
- *
- * @param ch The characters from the XML document.
- * @param start The start position in the array.
- * @param length The number of characters to read from the array.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- * @see #ignorableWhitespace
- * @see org.xml.sax.Locator
- *
- * @throws org.xml.sax.SAXException
- */
- public final void cdata(char ch[], int start, int length)
- throws org.xml.sax.SAXException
- {
-
- if ((null != m_elemContext.m_elementName)
- /* && (m_elemContext.m_elementName.equalsIgnoreCase("SCRIPT")
- || m_elemContext.m_elementName.equalsIgnoreCase("STYLE")) */)
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- m_ispreserve = true;
-
- if (shouldIndent())
- indent();
-
- // writer.write(ch, start, length);
- writeNormalizedChars(ch, start, length, true, m_lineSepUse);
- }
- catch (IOException ioe)
- {
- throw new org.xml.sax.SAXException(
- Utils.messages.createMessage(
- MsgKey.ER_OIERROR,
- null),
- ioe);
- //"IO error", ioe);
- }
- }
- else
- {
- super.cdata(ch, start, length);
- }
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if
- * none was supplied.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void processingInstruction(String target, String data)
- throws org.xml.sax.SAXException
- {
-
- // Process any pending starDocument and startElement first.
- flushPending();
-
- // Use a fairly nasty hack to tell if the next node is supposed to be
- // unescaped text.
- if (target.equals(Result.PI_DISABLE_OUTPUT_ESCAPING))
- {
- startNonEscaping();
- }
- else if (target.equals(Result.PI_ENABLE_OUTPUT_ESCAPING))
- {
- endNonEscaping();
- }
- else
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- startDocumentInternal();
-
- if (shouldIndent())
- indent();
-
- final java.io.Writer writer = m_writer;
- //writer.write("<?" + target);
- writer.write("<?");
- writer.write(target);
-
- if (data.length() > 0 && !Character.isSpaceChar(data.charAt(0)))
- writer.write(' ');
-
- //writer.write(data + ">"); // different from XML
- writer.write(data); // different from XML
- writer.write('>'); // different from XML
-
- // Always output a newline char if not inside of an
- // element. The whitespace is not significant in that
- // case.
- if (m_elemContext.m_currentElemDepth <= 0)
- outputLineSep();
-
- m_startNewLine = true;
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- // now generate the PI event
- if (m_tracer != null)
- super.fireEscapingEvent(target, data);
- }
-
- /**
- * Receive notivication of a entityReference.
- *
- * @param name non-null reference to entity name string.
- *
- * @throws org.xml.sax.SAXException
- */
- public final void entityReference(String name)
- throws org.xml.sax.SAXException
- {
- try
- {
-
- final java.io.Writer writer = m_writer;
- writer.write('&');
- writer.write(name);
- writer.write(';');
-
- } catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- /**
- * @see ExtendedContentHandler#endElement(String)
- */
- public final void endElement(String elemName) throws SAXException
- {
- endElement(null, null, elemName);
- }
-
- /**
- * Process the attributes, which means to write out the currently
- * collected attributes to the writer. The attributes are not
- * cleared by this method
- *
- * @param writer the writer to write processed attributes to.
- * @param nAttrs the number of attributes in m_attributes
- * to be processed
- *
- * @throws org.xml.sax.SAXException
- */
- public void processAttributes(java.io.Writer writer, int nAttrs)
- throws IOException,SAXException
- {
- /*
- * process the collected attributes
- */
- for (int i = 0; i < nAttrs; i++)
- {
- processAttribute(
- writer,
- m_attributes.getQName(i),
- m_attributes.getValue(i),
- m_elemContext.m_elementDesc);
- }
- }
-
- /**
- * For the enclosing elements starting tag write out out any attributes
- * followed by ">"
- *
- *@throws org.xml.sax.SAXException
- */
- protected void closeStartTag() throws SAXException
- {
- try
- {
-
- // finish processing attributes, time to fire off the start element event
- if (m_tracer != null)
- super.fireStartElem(m_elemContext.m_elementName);
-
- int nAttrs = m_attributes.getLength();
- if (nAttrs>0)
- {
- processAttributes(m_writer, nAttrs);
- // clear attributes object for re-use with next element
- m_attributes.clear();
- }
-
- m_writer.write('>');
-
- /* whether Xalan or XSLTC, we have the prefix mappings now, so
- * lets determine if the current element is specified in the cdata-
- * section-elements list.
- */
- if (m_cdataSectionElements != null)
- m_elemContext.m_isCdataSection = isCdataSection();
- if (m_doIndent)
- {
- m_isprevtext = false;
- m_preserves.push(m_ispreserve);
- }
-
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
- /**
- * Initialize the serializer with the specified output stream and output
- * format. Must be called before calling any of the serialize methods.
- *
- * @param output The output stream to use
- * @param format The output format
- * @throws UnsupportedEncodingException The encoding specified in the
- * output format is not supported
- */
- protected synchronized void init(OutputStream output, Properties format)
- throws UnsupportedEncodingException
- {
- if (null == format)
- {
- format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
- }
- super.init(output,format, false);
- }
-
- /**
- * Specifies an output stream to which the document should be
- * serialized. This method should not be called while the
- * serializer is in the process of serializing a document.
- * <p>
- * The encoding specified in the output properties is used, or
- * if no encoding was specified, the default for the selected
- * output method.
- *
- * @param output The output stream
- */
- public void setOutputStream(OutputStream output)
- {
-
- try
- {
- Properties format;
- if (null == m_format)
- format = OutputPropertiesFactory.getDefaultMethodProperties(Method.HTML);
- else
- format = m_format;
- init(output, format, true);
- }
- catch (UnsupportedEncodingException uee)
- {
-
- // Should have been warned in init, I guess...
- }
- }
- /**
- * This method is used when a prefix/uri namespace mapping
- * is indicated after the element was started with a
- * startElement() and before and endElement().
- * startPrefixMapping(prefix,uri) would be used before the
- * startElement() call.
- * @param uri the URI of the namespace
- * @param prefix the prefix associated with the given URI.
- *
- * @see ExtendedContentHandler#namespaceAfterStartElement(String, String)
- */
- public void namespaceAfterStartElement(String prefix, String uri)
- throws SAXException
- {
- // hack for XSLTC with finding URI for default namespace
- if (m_elemContext.m_elementURI == null)
- {
- String prefix1 = getPrefixPart(m_elemContext.m_elementName);
- if (prefix1 == null && EMPTYSTRING.equals(prefix))
- {
- // the elements URI is not known yet, and it
- // doesn't have a prefix, and we are currently
- // setting the uri for prefix "", so we have
- // the uri for the element... lets remember it
- m_elemContext.m_elementURI = uri;
- }
- }
- startPrefixMapping(prefix,uri,false);
- }
-
- public void startDTD(String name, String publicId, String systemId)
- throws SAXException
- {
- m_inDTD = true;
- super.startDTD(name, publicId, systemId);
- }
-
- /**
- * Report the end of DTD declarations.
- * @throws org.xml.sax.SAXException The application may raise an exception.
- * @see #startDTD
- */
- public void endDTD() throws org.xml.sax.SAXException
- {
- m_inDTD = false;
- /* for ToHTMLStream the DOCTYPE is entirely output in the
- * startDocumentInternal() method, so don't do anything here
- */
- }
- /**
- * This method does nothing.
- */
- public void attributeDecl(
- String eName,
- String aName,
- String type,
- String valueDefault,
- String value)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
-
- /**
- * This method does nothing.
- */
- public void elementDecl(String name, String model) throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
- /**
- * This method does nothing.
- */
- public void internalEntityDecl(String name, String value)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
- /**
- * This method does nothing.
- */
- public void externalEntityDecl(
- String name,
- String publicId,
- String systemId)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- }
-
- /**
- * This method is used to add an attribute to the currently open element.
- * The caller has guaranted that this attribute is unique, which means that it
- * not been seen before and will not be seen again.
- *
- * @param name the qualified name of the attribute
- * @param value the value of the attribute which can contain only
- * ASCII printable characters characters in the range 32 to 127 inclusive.
- * @param flags the bit values of this integer give optimization information.
- */
- public void addUniqueAttribute(String name, String value, int flags)
- throws SAXException
- {
- try
- {
- final java.io.Writer writer = m_writer;
- if ((flags & NO_BAD_CHARS) > 0 && m_htmlcharInfo.onlyQuotAmpLtGt)
- {
- // "flags" has indicated that the characters
- // '>' '<' '&' and '"' are not in the value and
- // m_htmlcharInfo has recorded that there are no other
- // entities in the range 0 to 127 so we write out the
- // value directly
- writer.write(' ');
- writer.write(name);
- writer.write("=\"");
- writer.write(value);
- writer.write('"');
- }
- else if (
- (flags & HTML_ATTREMPTY) > 0
- && (value.length() == 0 || value.equalsIgnoreCase(name)))
- {
- writer.write(' ');
- writer.write(name);
- }
- else
- {
- writer.write(' ');
- writer.write(name);
- writer.write("=\"");
- if ((flags & HTML_ATTRURL) > 0)
- {
- writeAttrURI(writer, value, m_specialEscapeURLs);
- }
- else
- {
- writeAttrString(writer, value, this.getEncoding());
- }
- writer.write('"');
- }
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
-
- public void comment(char ch[], int start, int length)
- throws SAXException
- {
- // The internal DTD subset is not serialized by the ToHTMLStream serializer
- if (m_inDTD)
- return;
- super.comment(ch, start, length);
- }
-
- public boolean reset()
- {
- boolean ret = super.reset();
- if (!ret)
- return false;
- initToHTMLStream();
- return true;
- }
-
- private void initToHTMLStream()
- {
-// m_elementDesc = null;
- m_inBlockElem = false;
- m_inDTD = false;
-// m_isRawStack.clear();
- m_omitMetaTag = false;
- m_specialEscapeURLs = true;
- }
-
- static class Trie
- {
- /**
- * A digital search trie for 7-bit ASCII text
- * The API is a subset of java.util.Hashtable
- * The key must be a 7-bit ASCII string
- * The value may be any Java Object
- * One can get an object stored in a trie from its key,
- * but the search is either case sensitive or case
- * insensitive to the characters in the key, and this
- * choice of sensitivity or insensitivity is made when
- * the Trie is created, before any objects are put in it.
- *
- * This class is a copy of the one in org.apache.xml.utils.
- * It exists to cut the serializers dependancy on that package.
- *
- * @xsl.usage internal
- */
-
- /** Size of the m_nextChar array. */
- public static final int ALPHA_SIZE = 128;
-
- /** The root node of the tree. */
- final Node m_Root;
-
- /** helper buffer to convert Strings to char arrays */
- private char[] m_charBuffer = new char[0];
-
- /** true if the search for an object is lower case only with the key */
- private final boolean m_lowerCaseOnly;
-
- /**
- * Construct the trie that has a case insensitive search.
- */
- public Trie()
- {
- m_Root = new Node();
- m_lowerCaseOnly = false;
- }
-
- /**
- * Construct the trie given the desired case sensitivity with the key.
- * @param lowerCaseOnly true if the search keys are to be loser case only,
- * not case insensitive.
- */
- public Trie(boolean lowerCaseOnly)
- {
- m_Root = new Node();
- m_lowerCaseOnly = lowerCaseOnly;
- }
-
- /**
- * Put an object into the trie for lookup.
- *
- * @param key must be a 7-bit ASCII string
- * @param value any java object.
- *
- * @return The old object that matched key, or null.
- */
- public Object put(String key, Object value)
- {
-
- final int len = key.length();
- if (len > m_charBuffer.length)
- {
- // make the biggest buffer ever needed in get(String)
- m_charBuffer = new char[len];
- }
-
- Node node = m_Root;
-
- for (int i = 0; i < len; i++)
- {
- Node nextNode =
- node.m_nextChar[Character.toLowerCase(key.charAt(i))];
-
- if (nextNode != null)
- {
- node = nextNode;
- }
- else
- {
- for (; i < len; i++)
- {
- Node newNode = new Node();
- if (m_lowerCaseOnly)
- {
- // put this value into the tree only with a lower case key
- node.m_nextChar[Character.toLowerCase(
- key.charAt(i))] =
- newNode;
- }
- else
- {
- // put this value into the tree with a case insensitive key
- node.m_nextChar[Character.toUpperCase(
- key.charAt(i))] =
- newNode;
- node.m_nextChar[Character.toLowerCase(
- key.charAt(i))] =
- newNode;
- }
- node = newNode;
- }
- break;
- }
- }
-
- Object ret = node.m_Value;
-
- node.m_Value = value;
-
- return ret;
- }
-
- /**
- * Get an object that matches the key.
- *
- * @param key must be a 7-bit ASCII string
- *
- * @return The object that matches the key, or null.
- */
- public Object get(final String key)
- {
-
- final int len = key.length();
-
- /* If the name is too long, we won't find it, this also keeps us
- * from overflowing m_charBuffer
- */
- if (m_charBuffer.length < len)
- return null;
-
- Node node = m_Root;
- switch (len) // optimize the look up based on the number of chars
- {
- // case 0 looks silly, but the generated bytecode runs
- // faster for lookup of elements of length 2 with this in
- // and a fair bit faster. Don't know why.
- case 0 :
- {
- return null;
- }
-
- case 1 :
- {
- final char ch = key.charAt(0);
- if (ch < ALPHA_SIZE)
- {
- node = node.m_nextChar[ch];
- if (node != null)
- return node.m_Value;
- }
- return null;
- }
- // comment out case 2 because the default is faster
- // case 2 :
- // {
- // final char ch0 = key.charAt(0);
- // final char ch1 = key.charAt(1);
- // if (ch0 < ALPHA_SIZE && ch1 < ALPHA_SIZE)
- // {
- // node = node.m_nextChar[ch0];
- // if (node != null)
- // {
- //
- // if (ch1 < ALPHA_SIZE)
- // {
- // node = node.m_nextChar[ch1];
- // if (node != null)
- // return node.m_Value;
- // }
- // }
- // }
- // return null;
- // }
- default :
- {
- for (int i = 0; i < len; i++)
- {
- // A thread-safe way to loop over the characters
- final char ch = key.charAt(i);
- if (ALPHA_SIZE <= ch)
- {
- // the key is not 7-bit ASCII so we won't find it here
- return null;
- }
-
- node = node.m_nextChar[ch];
- if (node == null)
- return null;
- }
-
- return node.m_Value;
- }
- }
- }
-
- /**
- * The node representation for the trie.
- * @xsl.usage internal
- */
- private class Node
- {
-
- /**
- * Constructor, creates a Node[ALPHA_SIZE].
- */
- Node()
- {
- m_nextChar = new Node[ALPHA_SIZE];
- m_Value = null;
- }
-
- /** The next nodes. */
- final Node m_nextChar[];
-
- /** The value. */
- Object m_Value;
- }
- /**
- * Construct the trie from another Trie.
- * Both the existing Trie and this new one share the same table for
- * lookup, and it is assumed that the table is fully populated and
- * not changing anymore.
- *
- * @param existingTrie the Trie that this one is a copy of.
- */
- public Trie(Trie existingTrie)
- {
- // copy some fields from the existing Trie into this one.
- m_Root = existingTrie.m_Root;
- m_lowerCaseOnly = existingTrie.m_lowerCaseOnly;
-
- // get a buffer just big enough to hold the longest key in the table.
- int max = existingTrie.getLongestKeyLength();
- m_charBuffer = new char[max];
- }
-
- /**
- * Get an object that matches the key.
- * This method is faster than get(), but is not thread-safe.
- *
- * @param key must be a 7-bit ASCII string
- *
- * @return The object that matches the key, or null.
- */
- public Object get2(final String key)
- {
-
- final int len = key.length();
-
- /* If the name is too long, we won't find it, this also keeps us
- * from overflowing m_charBuffer
- */
- if (m_charBuffer.length < len)
- return null;
-
- Node node = m_Root;
- switch (len) // optimize the look up based on the number of chars
- {
- // case 0 looks silly, but the generated bytecode runs
- // faster for lookup of elements of length 2 with this in
- // and a fair bit faster. Don't know why.
- case 0 :
- {
- return null;
- }
-
- case 1 :
- {
- final char ch = key.charAt(0);
- if (ch < ALPHA_SIZE)
- {
- node = node.m_nextChar[ch];
- if (node != null)
- return node.m_Value;
- }
- return null;
- }
- default :
- {
- /* Copy string into array. This is not thread-safe because
- * it modifies the contents of m_charBuffer. If multiple
- * threads were to use this Trie they all would be
- * using this same array (not good). So this
- * method is not thread-safe, but it is faster because
- * converting to a char[] and looping over elements of
- * the array is faster than a String's charAt(i).
- */
- key.getChars(0, len, m_charBuffer, 0);
-
- for (int i = 0; i < len; i++)
- {
- final char ch = m_charBuffer[i];
- if (ALPHA_SIZE <= ch)
- {
- // the key is not 7-bit ASCII so we won't find it here
- return null;
- }
-
- node = node.m_nextChar[ch];
- if (node == null)
- return null;
- }
-
- return node.m_Value;
- }
- }
- }
-
- /**
- * Get the length of the longest key used in the table.
- */
- public int getLongestKeyLength()
- {
- return m_charBuffer.length;
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLSAXHandler.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLSAXHandler.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLSAXHandler.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,773 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToXMLSAXHandler.java,v 1.1.2.1 2007/01/09 18:57:23 alexsmirnov Exp $
- */
- package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-import java.util.Properties;
-
-import javax.xml.transform.Result;
-
-import org.w3c.dom.Node;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-
-/**
- * This class receives notification of SAX-like events, and with gathered
- * information over these calls it will invoke the equivalent SAX methods
- * on a handler, the ultimate xsl:output method is known to be "xml".
- *
- * This class is not a public API, it is only public because it is used by Xalan.
- * @xsl.usage internal
- */
-public final class ToXMLSAXHandler extends ToSAXHandler
-{
-
- /**
- * Keeps track of whether output escaping is currently enabled
- */
- protected boolean m_escapeSetting = false;
-
- public ToXMLSAXHandler()
- {
- // default constructor (need to set content handler ASAP !)
- m_prefixMap = new NamespaceMappings();
- initCDATA();
- }
-
- /**
- * @see Serializer#getOutputFormat()
- */
- public Properties getOutputFormat()
- {
- return null;
- }
-
- /**
- * @see Serializer#getOutputStream()
- */
- public OutputStream getOutputStream()
- {
- return null;
- }
-
- /**
- * @see Serializer#getWriter()
- */
- public Writer getWriter()
- {
- return null;
- }
-
- /**
- * Do nothing for SAX.
- */
- public void indent(int n) throws SAXException
- {
- }
-
-
- /**
- * @see DOMSerializer#serialize(Node)
- */
- public void serialize(Node node) throws IOException
- {
- }
-
- /**
- * @see SerializationHandler#setEscaping(boolean)
- */
- public boolean setEscaping(boolean escape) throws SAXException
- {
- boolean oldEscapeSetting = m_escapeSetting;
- m_escapeSetting = escape;
-
- if (escape) {
- processingInstruction(Result.PI_ENABLE_OUTPUT_ESCAPING, "");
- } else {
- processingInstruction(Result.PI_DISABLE_OUTPUT_ESCAPING, "");
- }
-
- return oldEscapeSetting;
- }
-
- /**
- * @see Serializer#setOutputFormat(Properties)
- */
- public void setOutputFormat(Properties format)
- {
- }
-
- /**
- * @see Serializer#setOutputStream(OutputStream)
- */
- public void setOutputStream(OutputStream output)
- {
- }
-
- /**
- * @see Serializer#setWriter(Writer)
- */
- public void setWriter(Writer writer)
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#attributeDecl(String, String, String, String, String)
- */
- public void attributeDecl(
- String arg0,
- String arg1,
- String arg2,
- String arg3,
- String arg4)
- throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#elementDecl(String, String)
- */
- public void elementDecl(String arg0, String arg1) throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#externalEntityDecl(String, String, String)
- */
- public void externalEntityDecl(String arg0, String arg1, String arg2)
- throws SAXException
- {
- }
-
- /**
- * @see org.xml.sax.ext.DeclHandler#internalEntityDecl(String, String)
- */
- public void internalEntityDecl(String arg0, String arg1)
- throws SAXException
- {
- }
-
- /**
- * Receives notification of the end of the document.
- * @see org.xml.sax.ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException
- {
-
- flushPending();
-
- // Close output document
- m_saxHandler.endDocument();
-
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * This method is called when all the data needed for a call to the
- * SAX handler's startElement() method has been gathered.
- */
- protected void closeStartTag() throws SAXException
- {
-
- m_elemContext.m_startTagOpen = false;
-
- final String localName = getLocalName(m_elemContext.m_elementName);
- final String uri = getNamespaceURI(m_elemContext.m_elementName, true);
-
- // Now is time to send the startElement event
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- }
- m_saxHandler.startElement(uri, localName, m_elemContext.m_elementName, m_attributes);
- // we've sent the official SAX attributes on their way,
- // now we don't need them anymore.
- m_attributes.clear();
-
- if(m_state != null)
- m_state.setCurrentNode(null);
- }
-
- /**
- * Closes ane open cdata tag, and
- * unlike the this.endCDATA() method (from the LexicalHandler) interface,
- * this "internal" method will send the endCDATA() call to the wrapped
- * handler.
- *
- */
- public void closeCDATA() throws SAXException
- {
-
- // Output closing bracket - "]]>"
- if (m_lexHandler != null && m_cdataTagOpen) {
- m_lexHandler.endCDATA();
- }
-
-
- // There are no longer any calls made to
- // m_lexHandler.startCDATA() without a balancing call to
- // m_lexHandler.endCDATA()
- // so we set m_cdataTagOpen to false to remember this.
- m_cdataTagOpen = false;
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endElement(String, String, String)
- */
- public void endElement(String namespaceURI, String localName, String qName)
- throws SAXException
- {
- // Close any open elements etc.
- flushPending();
-
- if (namespaceURI == null)
- {
- if (m_elemContext.m_elementURI != null)
- namespaceURI = m_elemContext.m_elementURI;
- else
- namespaceURI = getNamespaceURI(qName, true);
- }
-
- if (localName == null)
- {
- if (m_elemContext.m_elementLocalName != null)
- localName = m_elemContext.m_elementLocalName;
- else
- localName = getLocalName(qName);
- }
-
- m_saxHandler.endElement(namespaceURI, localName, qName);
-
- if (m_tracer != null)
- super.fireEndElem(qName);
-
- /* Pop all namespaces at the current element depth.
- * We are not waiting for official endPrefixMapping() calls.
- */
- m_prefixMap.popNamespaces(m_elemContext.m_currentElemDepth,
- m_saxHandler);
- m_elemContext = m_elemContext.m_prev;
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endPrefixMapping(String)
- */
- public void endPrefixMapping(String prefix) throws SAXException
- {
- /* poping all prefix mappings should have been done
- * in endElement() already
- */
- return;
- }
-
- /**
- * @see org.xml.sax.ContentHandler#ignorableWhitespace(char[], int, int)
- */
- public void ignorableWhitespace(char[] arg0, int arg1, int arg2)
- throws SAXException
- {
- m_saxHandler.ignorableWhitespace(arg0,arg1,arg2);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#setDocumentLocator(Locator)
- */
- public void setDocumentLocator(Locator arg0)
- {
- m_saxHandler.setDocumentLocator(arg0);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#skippedEntity(String)
- */
- public void skippedEntity(String arg0) throws SAXException
- {
- m_saxHandler.skippedEntity(arg0);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
- * @param prefix The prefix that maps to the URI
- * @param uri The URI for the namespace
- */
- public void startPrefixMapping(String prefix, String uri)
- throws SAXException
- {
- startPrefixMapping(prefix, uri, true);
- }
-
- /**
- * Remember the prefix/uri mapping at the current nested element depth.
- *
- * @see org.xml.sax.ContentHandler#startPrefixMapping(String, String)
- * @param prefix The prefix that maps to the URI
- * @param uri The URI for the namespace
- * @param shouldFlush a flag indicating if the mapping applies to the
- * current element or an up coming child (not used).
- */
-
- public boolean startPrefixMapping(
- String prefix,
- String uri,
- boolean shouldFlush)
- throws org.xml.sax.SAXException
- {
-
- /* Remember the mapping, and at what depth it was declared
- * This is one greater than the current depth because these
- * mappings will apply to the next depth. This is in
- * consideration that startElement() will soon be called
- */
-
- boolean pushed;
- int pushDepth;
- if (shouldFlush)
- {
- flushPending();
- // the prefix mapping applies to the child element (one deeper)
- pushDepth = m_elemContext.m_currentElemDepth + 1;
- }
- else
- {
- // the prefix mapping applies to the current element
- pushDepth = m_elemContext.m_currentElemDepth;
- }
- pushed = m_prefixMap.pushNamespace(prefix, uri, pushDepth);
-
- if (pushed)
- {
- m_saxHandler.startPrefixMapping(prefix,uri);
-
- if (getShouldOutputNSAttr())
- {
-
- /* Brian M.: don't know if we really needto do this. The
- * callers of this object should have injected both
- * startPrefixMapping and the attributes. We are
- * just covering our butt here.
- */
- String name;
- if (EMPTYSTRING.equals(prefix))
- {
- name = "xmlns";
- addAttributeAlways(XMLNS_URI, name, name,"CDATA",uri, false);
- }
- else
- {
- if (!EMPTYSTRING.equals(uri)) // hack for XSLTC attribset16 test
- { // that maps ns1 prefix to "" URI
- name = "xmlns:" + prefix;
-
- /* for something like xmlns:abc="w3.pretend.org"
- * the uri is the value, that is why we pass it in the
- * value, or 5th slot of addAttributeAlways()
- */
- addAttributeAlways(XMLNS_URI, prefix, name,"CDATA",uri, false );
- }
- }
- }
- }
- return pushed;
- }
-
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#comment(char[], int, int)
- */
- public void comment(char[] arg0, int arg1, int arg2) throws SAXException
- {
- flushPending();
- if (m_lexHandler != null)
- m_lexHandler.comment(arg0, arg1, arg2);
-
- if (m_tracer != null)
- super.fireCommentEvent(arg0, arg1, arg2);
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#endCDATA()
- */
- public void endCDATA() throws SAXException
- {
- /* Normally we would do somthing with this but we ignore it.
- * The neccessary call to m_lexHandler.endCDATA() will be made
- * in flushPending().
- *
- * This is so that if we get calls like these:
- * this.startCDATA();
- * this.characters(chars1, off1, len1);
- * this.endCDATA();
- * this.startCDATA();
- * this.characters(chars2, off2, len2);
- * this.endCDATA();
- *
- * that we will only make these calls to the wrapped handlers:
- *
- * m_lexHandler.startCDATA();
- * m_saxHandler.characters(chars1, off1, len1);
- * m_saxHandler.characters(chars1, off2, len2);
- * m_lexHandler.endCDATA();
- *
- * We will merge adjacent CDATA blocks.
- */
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#endDTD()
- */
- public void endDTD() throws SAXException
- {
- if (m_lexHandler != null)
- m_lexHandler.endDTD();
- }
-
- /**
- * @see org.xml.sax.ext.LexicalHandler#startEntity(String)
- */
- public void startEntity(String arg0) throws SAXException
- {
- if (m_lexHandler != null)
- m_lexHandler.startEntity(arg0);
- }
-
- /**
- * @see ExtendedContentHandler#characters(String)
- */
- public void characters(String chars) throws SAXException
- {
- final int length = chars.length();
- if (length > m_charsBuff.length)
- {
- m_charsBuff = new char[length*2 + 1];
- }
- chars.getChars(0, length, m_charsBuff, 0);
- this.characters(m_charsBuff, 0, length);
- }
-
- /////////////////// from XSLTC //////////////
- public ToXMLSAXHandler(ContentHandler handler, String encoding)
- {
- super(handler, encoding);
-
- initCDATA();
- // initNamespaces();
- m_prefixMap = new NamespaceMappings();
- }
-
- public ToXMLSAXHandler(
- ContentHandler handler,
- LexicalHandler lex,
- String encoding)
- {
- super(handler, lex, encoding);
-
- initCDATA();
- // initNamespaces();
- m_prefixMap = new NamespaceMappings();
- }
-
- /**
- * Start an element in the output document. This might be an XML element
- * (<elem>data</elem> type) or a CDATA section.
- */
- public void startElement(
- String elementNamespaceURI,
- String elementLocalName,
- String elementName) throws SAXException
- {
- startElement(
- elementNamespaceURI,elementLocalName,elementName, null);
-
-
- }
- public void startElement(String elementName) throws SAXException
- {
- startElement(null, null, elementName, null);
- }
-
-
- public void characters(char[] ch, int off, int len) throws SAXException
- {
- // We do the first two things in flushPending() but we don't
- // close any open CDATA calls.
- if (m_needToCallStartDocument)
- {
- startDocumentInternal();
- m_needToCallStartDocument = false;
- }
-
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- if (m_elemContext.m_isCdataSection && !m_cdataTagOpen
- && m_lexHandler != null)
- {
- m_lexHandler.startCDATA();
- // We have made a call to m_lexHandler.startCDATA() with
- // no balancing call to m_lexHandler.endCDATA()
- // so we set m_cdataTagOpen true to remember this.
- m_cdataTagOpen = true;
- }
-
- /* If there are any occurances of "]]>" in the character data
- * let m_saxHandler worry about it, we've already warned them with
- * the previous call of m_lexHandler.startCDATA();
- */
- m_saxHandler.characters(ch, off, len);
-
- // time to generate characters event
- if (m_tracer != null)
- fireCharEvent(ch, off, len);
- }
-
-
- /**
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elemName) throws SAXException
- {
- endElement(null, null, elemName);
- }
-
-
- /**
- * Send a namespace declaration in the output document. The namespace
- * declaration will not be include if the namespace is already in scope
- * with the same prefix.
- */
- public void namespaceAfterStartElement(
- final String prefix,
- final String uri)
- throws SAXException
- {
- startPrefixMapping(prefix,uri,false);
- }
-
- /**
- *
- * @see org.xml.sax.ContentHandler#processingInstruction(String, String)
- * Send a processing instruction to the output document
- */
- public void processingInstruction(String target, String data)
- throws SAXException
- {
- flushPending();
-
- // Pass the processing instruction to the SAX handler
- m_saxHandler.processingInstruction(target, data);
-
- // we don't want to leave serializer to fire off this event,
- // so do it here.
- if (m_tracer != null)
- super.fireEscapingEvent(target, data);
- }
-
- /**
- * Undeclare the namespace that is currently pointed to by a given
- * prefix. Inform SAX handler if prefix was previously mapped.
- */
- protected boolean popNamespace(String prefix)
- {
- try
- {
- if (m_prefixMap.popNamespace(prefix))
- {
- m_saxHandler.endPrefixMapping(prefix);
- return true;
- }
- }
- catch (SAXException e)
- {
- // falls through
- }
- return false;
- }
-
- public void startCDATA() throws SAXException
- {
- /* m_cdataTagOpen can only be true here if we have ignored the
- * previous call to this.endCDATA() and the previous call
- * this.startCDATA() before that is still "open". In this way
- * we merge adjacent CDATA. If anything else happened after the
- * ignored call to this.endCDATA() and this call then a call to
- * flushPending() would have been made which would have
- * closed the CDATA and set m_cdataTagOpen to false.
- */
- if (!m_cdataTagOpen )
- {
- flushPending();
- if (m_lexHandler != null) {
- m_lexHandler.startCDATA();
-
- // We have made a call to m_lexHandler.startCDATA() with
- // no balancing call to m_lexHandler.endCDATA()
- // so we set m_cdataTagOpen true to remember this.
- m_cdataTagOpen = true;
- }
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startElement(String, String, String, Attributes)
- */
- public void startElement(
- String namespaceURI,
- String localName,
- String name,
- Attributes atts)
- throws SAXException
- {
- flushPending();
- super.startElement(namespaceURI, localName, name, atts);
-
- // Handle document type declaration (for first element only)
- if (m_needToOutputDocTypeDecl)
- {
- String doctypeSystem = getDoctypeSystem();
- if (doctypeSystem != null && m_lexHandler != null)
- {
- String doctypePublic = getDoctypePublic();
- if (doctypeSystem != null)
- m_lexHandler.startDTD(
- name,
- doctypePublic,
- doctypeSystem);
- }
- m_needToOutputDocTypeDecl = false;
- }
- m_elemContext = m_elemContext.push(namespaceURI, localName, name);
-
- // ensurePrefixIsDeclared depends on the current depth, so
- // the previous increment is necessary where it is.
- if (namespaceURI != null)
- ensurePrefixIsDeclared(namespaceURI, name);
-
- // add the attributes to the collected ones
- if (atts != null)
- addAttributes(atts);
-
-
- // do we really need this CDATA section state?
- m_elemContext.m_isCdataSection = isCdataSection();
-
- }
-
- private void ensurePrefixIsDeclared(String ns, String rawName)
- throws org.xml.sax.SAXException
- {
-
- if (ns != null && ns.length() > 0)
- {
- int index;
- final boolean no_prefix = ((index = rawName.indexOf(":")) < 0);
- String prefix = (no_prefix) ? "" : rawName.substring(0, index);
-
-
- if (null != prefix)
- {
- String foundURI = m_prefixMap.lookupNamespace(prefix);
-
- if ((null == foundURI) || !foundURI.equals(ns))
- {
- this.startPrefixMapping(prefix, ns, false);
-
- if (getShouldOutputNSAttr()) {
- // Bugzilla1133: Generate attribute as well as namespace event.
- // SAX does expect both.
- this.addAttributeAlways(
- "http://www.w3.org/2000/xmlns/",
- no_prefix ? "xmlns" : prefix, // local name
- no_prefix ? "xmlns" : ("xmlns:"+ prefix), // qname
- "CDATA",
- ns,
- false);
- }
- }
-
- }
- }
- }
- /**
- * Adds the given attribute to the set of attributes, and also makes sure
- * that the needed prefix/uri mapping is declared, but only if there is a
- * currently open element.
- *
- * @param uri the URI of the attribute
- * @param localName the local name of the attribute
- * @param rawName the qualified name of the attribute
- * @param type the type of the attribute (probably CDATA)
- * @param value the value of the attribute
- * @param XSLAttribute true if this attribute is coming from an xsl:attribute element
- * @see ExtendedContentHandler#addAttribute(String, String, String, String, String)
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean XSLAttribute)
- throws SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
- ensurePrefixIsDeclared(uri, rawName);
- addAttributeAlways(uri, localName, rawName, type, value, false);
- }
-
- }
-
- /**
- * Try's to reset the super class and reset this class for
- * re-use, so that you don't need to create a new serializer
- * (mostly for performance reasons).
- *
- * @return true if the class was successfuly reset.
- * @see Serializer#reset()
- */
- public boolean reset()
- {
- boolean wasReset = false;
- if (super.reset())
- {
- resetToXMLSAXHandler();
- wasReset = true;
- }
- return wasReset;
- }
-
- /**
- * Reset all of the fields owned by ToXMLSAXHandler class
- *
- */
- private void resetToXMLSAXHandler()
- {
- this.m_escapeSetting = false;
- }
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLStream.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLStream.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/ToXMLStream.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,623 +0,0 @@
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: ToXMLStream.java,v 1.1.2.1 2007/01/09 18:57:21 alexsmirnov Exp $
- */
- package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-
-import org.ajax4jsf.xml.serializer.utils.MsgKey;
-import org.ajax4jsf.xml.serializer.utils.Utils;
-import org.xml.sax.SAXException;
-
-/**
- * This class converts SAX or SAX-like calls to a
- * serialized xml document. The xsl:output method is "xml".
- *
- * This class is used explicitly in code generated by XSLTC,
- * so it is "public", but it should
- * be viewed as internal or package private, this is not an API.
- *
- * @xsl.usage internal
- */
-public final class ToXMLStream extends ToStream
-{
-
- /**
- * remembers if we need to write out "]]>" to close the CDATA
- */
- boolean m_cdataTagOpen = false;
-
-
- /**
- * Map that tells which XML characters should have special treatment, and it
- * provides character to entity name lookup.
- */
- private static CharInfo m_xmlcharInfo =
-// new CharInfo(CharInfo.XML_ENTITIES_RESOURCE);
- CharInfo.getCharInfo(CharInfo.XML_ENTITIES_RESOURCE, Method.XML);
-
- /**
- * Default constructor.
- */
- public ToXMLStream()
- {
- m_charInfo = m_xmlcharInfo;
-
- initCDATA();
- // initialize namespaces
- m_prefixMap = new NamespaceMappings();
-
- }
-
- /**
- * Copy properties from another SerializerToXML.
- *
- * @param xmlListener non-null reference to a SerializerToXML object.
- */
- public void CopyFrom(ToXMLStream xmlListener)
- {
-
- m_writer = xmlListener.m_writer;
-
-
- // m_outputStream = xmlListener.m_outputStream;
- String encoding = xmlListener.getEncoding();
- setEncoding(encoding);
-
- setOmitXMLDeclaration(xmlListener.getOmitXMLDeclaration());
-
- m_ispreserve = xmlListener.m_ispreserve;
- m_preserves = xmlListener.m_preserves;
- m_isprevtext = xmlListener.m_isprevtext;
- m_doIndent = xmlListener.m_doIndent;
- setIndentAmount(xmlListener.getIndentAmount());
- m_startNewLine = xmlListener.m_startNewLine;
- m_needToOutputDocTypeDecl = xmlListener.m_needToOutputDocTypeDecl;
- setDoctypeSystem(xmlListener.getDoctypeSystem());
- setDoctypePublic(xmlListener.getDoctypePublic());
- setStandalone(xmlListener.getStandalone());
- setMediaType(xmlListener.getMediaType());
- m_encodingInfo = xmlListener.m_encodingInfo;
- m_spaceBeforeClose = xmlListener.m_spaceBeforeClose;
- m_cdataStartCalled = xmlListener.m_cdataStartCalled;
-
- }
-
- /**
- * Receive notification of the beginning of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void startDocumentInternal() throws org.xml.sax.SAXException
- {
-
- if (m_needToCallStartDocument)
- {
- super.startDocumentInternal();
- m_needToCallStartDocument = false;
-
- if (m_inEntityRef)
- return;
-
- m_needToOutputDocTypeDecl = true;
- m_startNewLine = false;
- /* The call to getXMLVersion() might emit an error message
- * and we should emit this message regardless of if we are
- * writing out an XML header or not.
- */
- final String version = getXMLVersion();
- if (getOmitXMLDeclaration() == false)
- {
- String encoding = Encodings.getMimeEncoding(getEncoding());
- String standalone;
-
- if (m_standaloneWasSpecified)
- {
- standalone = " standalone=\"" + getStandalone() + "\"";
- }
- else
- {
- standalone = "";
- }
-
- try
- {
- final java.io.Writer writer = m_writer;
- writer.write("<?xml version=\"");
- writer.write(version);
- writer.write("\" encoding=\"");
- writer.write(encoding);
- writer.write('\"');
- writer.write(standalone);
- writer.write("?>");
- if (m_doIndent)
- writer.write(m_lineSep, 0, m_lineSepLen);
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
-
- }
- }
- }
-
- /**
- * Receive notification of the end of a document.
- *
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void endDocument() throws org.xml.sax.SAXException
- {
- flushPending();
- if (m_doIndent && !m_isprevtext)
- {
- try
- {
- outputLineSep();
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- flushWriter();
-
- if (m_tracer != null)
- super.fireEndDoc();
- }
-
- /**
- * Starts a whitespace preserving section. All characters printed
- * within a preserving section are printed without indentation and
- * without consolidating multiple spaces. This is equivalent to
- * the <tt>xml:space="preserve"</tt> attribute. Only XML
- * and HTML serializers need to support this method.
- * <p>
- * The contents of the whitespace preserving section will be delivered
- * through the regular <tt>characters</tt> event.
- *
- * @throws org.xml.sax.SAXException
- */
- public void startPreserving() throws org.xml.sax.SAXException
- {
-
- // Not sure this is really what we want. -sb
- m_preserves.push(true);
-
- m_ispreserve = true;
- }
-
- /**
- * Ends a whitespace preserving section.
- *
- * @see #startPreserving
- *
- * @throws org.xml.sax.SAXException
- */
- public void endPreserving() throws org.xml.sax.SAXException
- {
-
- // Not sure this is really what we want. -sb
- m_ispreserve = m_preserves.isEmpty() ? false : m_preserves.pop();
- }
-
- /**
- * Receive notification of a processing instruction.
- *
- * @param target The processing instruction target.
- * @param data The processing instruction data, or null if
- * none was supplied.
- * @throws org.xml.sax.SAXException Any SAX exception, possibly
- * wrapping another exception.
- *
- * @throws org.xml.sax.SAXException
- */
- public void processingInstruction(String target, String data)
- throws org.xml.sax.SAXException
- {
- if (m_inEntityRef)
- return;
-
- flushPending();
-
- if (target.equals(Result.PI_DISABLE_OUTPUT_ESCAPING))
- {
- startNonEscaping();
- }
- else if (target.equals(Result.PI_ENABLE_OUTPUT_ESCAPING))
- {
- endNonEscaping();
- }
- else
- {
- try
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
- else if (m_needToCallStartDocument)
- startDocumentInternal();
-
- if (shouldIndent())
- indent();
-
- final java.io.Writer writer = m_writer;
- writer.write("<?");
- writer.write(target);
-
- if (data.length() > 0
- && !Character.isSpaceChar(data.charAt(0)))
- writer.write(' ');
-
- int indexOfQLT = data.indexOf("?>");
-
- if (indexOfQLT >= 0)
- {
-
- // See XSLT spec on error recovery of "?>" in PIs.
- if (indexOfQLT > 0)
- {
- writer.write(data.substring(0, indexOfQLT));
- }
-
- writer.write("? >"); // add space between.
-
- if ((indexOfQLT + 2) < data.length())
- {
- writer.write(data.substring(indexOfQLT + 2));
- }
- }
- else
- {
- writer.write(data);
- }
-
- writer.write('?');
- writer.write('>');
-
- // Always output a newline char if not inside of an
- // element. The whitespace is not significant in that
- // case.
- if (m_elemContext.m_currentElemDepth <= 0)
- writer.write(m_lineSep, 0, m_lineSepLen);
-
- m_startNewLine = true;
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
- }
-
- if (m_tracer != null)
- super.fireEscapingEvent(target, data);
- }
-
- /**
- * Receive notivication of a entityReference.
- *
- * @param name The name of the entity.
- *
- * @throws org.xml.sax.SAXException
- */
- public void entityReference(String name) throws org.xml.sax.SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
- closeStartTag();
- m_elemContext.m_startTagOpen = false;
- }
-
- try
- {
- if (shouldIndent())
- indent();
-
- final java.io.Writer writer = m_writer;
- writer.write('&');
- writer.write(name);
- writer.write(';');
- }
- catch(IOException e)
- {
- throw new SAXException(e);
- }
-
- if (m_tracer != null)
- super.fireEntityReference(name);
- }
-
- /**
- * This method is used to add an attribute to the currently open element.
- * The caller has guaranted that this attribute is unique, which means that it
- * not been seen before and will not be seen again.
- *
- * @param name the qualified name of the attribute
- * @param value the value of the attribute which can contain only
- * ASCII printable characters characters in the range 32 to 127 inclusive.
- * @param flags the bit values of this integer give optimization information.
- */
- public void addUniqueAttribute(String name, String value, int flags)
- throws SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
-
- try
- {
- final String patchedName = patchName(name);
- final java.io.Writer writer = m_writer;
- if ((flags & NO_BAD_CHARS) > 0 && m_xmlcharInfo.onlyQuotAmpLtGt)
- {
- // "flags" has indicated that the characters
- // '>' '<' '&' and '"' are not in the value and
- // m_htmlcharInfo has recorded that there are no other
- // entities in the range 32 to 127 so we write out the
- // value directly
-
- writer.write(' ');
- writer.write(patchedName);
- writer.write("=\"");
- writer.write(value);
- writer.write('"');
- }
- else
- {
- writer.write(' ');
- writer.write(patchedName);
- writer.write("=\"");
- writeAttrString(writer, value, this.getEncoding());
- writer.write('"');
- }
- } catch (IOException e) {
- throw new SAXException(e);
- }
- }
- }
-
- /**
- * Add an attribute to the current element.
- * @param uri the URI associated with the element name
- * @param localName local part of the attribute name
- * @param rawName prefix:localName
- * @param type
- * @param value the value of the attribute
- * @param xslAttribute true if this attribute is from an xsl:attribute,
- * false if declared within the elements opening tag.
- * @throws SAXException
- */
- public void addAttribute(
- String uri,
- String localName,
- String rawName,
- String type,
- String value,
- boolean xslAttribute)
- throws SAXException
- {
- if (m_elemContext.m_startTagOpen)
- {
- boolean was_added = addAttributeAlways(uri, localName, rawName, type, value, xslAttribute);
-
-
- /*
- * We don't run this block of code if:
- * 1. The attribute value was only replaced (was_added is false).
- * 2. The attribute is from an xsl:attribute element (that is handled
- * in the addAttributeAlways() call just above.
- * 3. The name starts with "xmlns", i.e. it is a namespace declaration.
- */
- if (was_added && !xslAttribute && !rawName.startsWith("xmlns"))
- {
- String prefixUsed =
- ensureAttributesNamespaceIsDeclared(
- uri,
- localName,
- rawName);
- if (prefixUsed != null
- && rawName != null
- && !rawName.startsWith(prefixUsed))
- {
- // use a different raw name, with the prefix used in the
- // generated namespace declaration
- rawName = prefixUsed + ":" + localName;
-
- }
- }
- addAttributeAlways(uri, localName, rawName, type, value, xslAttribute);
- }
- else
- {
- /*
- * The startTag is closed, yet we are adding an attribute?
- *
- * Section: 7.1.3 Creating Attributes Adding an attribute to an
- * element after a PI (for example) has been added to it is an
- * error. The attributes can be ignored. The spec doesn't explicitly
- * say this is disallowed, as it does for child elements, but it
- * makes sense to have the same treatment.
- *
- * We choose to ignore the attribute which is added too late.
- */
- // Generate a warning of the ignored attributes
-
- // Create the warning message
- String msg = Utils.messages.createMessage(
- MsgKey.ER_ILLEGAL_ATTRIBUTE_POSITION,new Object[]{ localName });
-
- try {
- // Prepare to issue the warning message
- Transformer tran = super.getTransformer();
- ErrorListener errHandler = tran.getErrorListener();
-
-
- // Issue the warning message
- if (null != errHandler && m_sourceLocator != null)
- errHandler.warning(new TransformerException(msg, m_sourceLocator));
- else
- System.out.println(msg);
- }
- catch (Exception e){}
- }
- }
-
- /**
- * @see ExtendedContentHandler#endElement(String)
- */
- public void endElement(String elemName) throws SAXException
- {
- endElement(null, null, elemName);
- }
-
- /**
- * This method is used to notify the serializer of a namespace mapping (or node)
- * that applies to the current element whose startElement() call has already been seen.
- * The official SAX startPrefixMapping(prefix,uri) is to define a mapping for a child
- * element that is soon to be seen with a startElement() call. The official SAX call
- * does not apply to the current element, hence the reason for this method.
- */
- public void namespaceAfterStartElement(
- final String prefix,
- final String uri)
- throws SAXException
- {
-
- // hack for XSLTC with finding URI for default namespace
- if (m_elemContext.m_elementURI == null)
- {
- String prefix1 = getPrefixPart(m_elemContext.m_elementName);
- if (prefix1 == null && EMPTYSTRING.equals(prefix))
- {
- // the elements URI is not known yet, and it
- // doesn't have a prefix, and we are currently
- // setting the uri for prefix "", so we have
- // the uri for the element... lets remember it
- m_elemContext.m_elementURI = uri;
- }
- }
- startPrefixMapping(prefix,uri,false);
- return;
-
- }
-
- /**
- * From XSLTC
- * Declare a prefix to point to a namespace URI. Inform SAX handler
- * if this is a new prefix mapping.
- */
- protected boolean pushNamespace(String prefix, String uri)
- {
- try
- {
- if (m_prefixMap.pushNamespace(
- prefix, uri, m_elemContext.m_currentElemDepth))
- {
- startPrefixMapping(prefix, uri);
- return true;
- }
- }
- catch (SAXException e)
- {
- // falls through
- }
- return false;
- }
- /**
- * Try's to reset the super class and reset this class for
- * re-use, so that you don't need to create a new serializer
- * (mostly for performance reasons).
- *
- * @return true if the class was successfuly reset.
- */
- public boolean reset()
- {
- boolean wasReset = false;
- if (super.reset())
- {
- resetToXMLStream();
- wasReset = true;
- }
- return wasReset;
- }
-
- /**
- * Reset all of the fields owned by ToStream class
- *
- */
- private void resetToXMLStream()
- {
- this.m_cdataTagOpen = false;
-
- }
-
- /**
- * This method checks for the XML version of output document.
- * If XML version of output document is not specified, then output
- * document is of version XML 1.0.
- * If XML version of output doucment is specified, but it is not either
- * XML 1.0 or XML 1.1, a warning message is generated, the XML Version of
- * output document is set to XML 1.0 and processing continues.
- * @return string (XML version)
- */
- private String getXMLVersion()
- {
- String xmlVersion = getVersion();
- if(xmlVersion == null || xmlVersion.equals(XMLVERSION10))
- {
- xmlVersion = XMLVERSION10;
- }
- else if(xmlVersion.equals(XMLVERSION11))
- {
- xmlVersion = XMLVERSION11;
- }
- else
- {
- String msg = Utils.messages.createMessage(
- MsgKey.ER_XML_VERSION_NOT_SUPPORTED,new Object[]{ xmlVersion });
- try
- {
- // Prepare to issue the warning message
- Transformer tran = super.getTransformer();
- ErrorListener errHandler = tran.getErrorListener();
- // Issue the warning message
- if (null != errHandler && m_sourceLocator != null)
- errHandler.warning(new TransformerException(msg, m_sourceLocator));
- else
- System.out.println(msg);
- }
- catch (Exception e){}
- xmlVersion = XMLVERSION10;
- }
- return xmlVersion;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TransformStateSetter.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TransformStateSetter.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TransformStateSetter.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,54 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: TransformStateSetter.java,v 1.1.2.1 2007/01/09 18:57:27 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import javax.xml.transform.Transformer;
-
-import org.w3c.dom.Node;
-/**
- * This interface is meant to be used by a base interface to
- * TransformState, but which as only the setters which have non Xalan
- * specific types in their signature, so that there are no dependancies
- * of the serializer on Xalan.
- *
- * This interface is not a public API, it is only public because it is
- * used by Xalan.
- *
- * @see org.apache.xalan.transformer.TransformState
- * @xsl.usage internal
- */
-public interface TransformStateSetter
-{
-
-
- /**
- * Set the current node.
- *
- * @param n The current node.
- */
- void setCurrentNode(Node n);
-
- /**
- * Reset the state on the given transformer object.
- *
- * @param transformer
- */
- void resetState(Transformer transformer);
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TreeWalker.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TreeWalker.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/TreeWalker.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,535 +0,0 @@
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: TreeWalker.java,v 1.1.2.1 2007/01/09 18:57:17 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.File;
-
-import javax.xml.transform.TransformerException;
-
-import org.ajax4jsf.xml.serializer.utils.AttList;
-import org.ajax4jsf.xml.serializer.utils.DOM2Helper;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.ext.LexicalHandler;
-import org.xml.sax.helpers.LocatorImpl;
-
-/**
- * This class does a pre-order walk of the DOM tree, calling a ContentHandler
- * interface as it goes.
- *
- * This class is a copy of the one in org.apache.xml.utils.
- * It exists to cut the serializers dependancy on that package.
- *
- * @xsl.usage internal
- */
-
-public final class TreeWalker
-{
-
- /** Local reference to a ContentHandler */
- final private ContentHandler m_contentHandler;
- /**
- * If m_contentHandler is a SerializationHandler, then this is
- * a reference to the same object.
- */
- final private SerializationHandler m_Serializer;
-
- // ARGHH!! JAXP Uses Xerces without setting the namespace processing to ON!
- // DOM2Helper m_dh = new DOM2Helper();
-
- /** DomHelper for this TreeWalker */
- final protected DOM2Helper m_dh;
-
- /** Locator object for this TreeWalker */
- final private LocatorImpl m_locator = new LocatorImpl();
-
- /**
- * Get the ContentHandler used for the tree walk.
- *
- * @return the ContentHandler used for the tree walk
- */
- public ContentHandler getContentHandler()
- {
- return m_contentHandler;
- }
-
- public TreeWalker(ContentHandler ch) {
- this(ch,null);
- }
- /**
- * Constructor.
- * @param contentHandler The implemention of the
- * contentHandler operation (toXMLString, digest, ...)
- */
- public TreeWalker(ContentHandler contentHandler, String systemId)
- {
- // Set the content handler
- m_contentHandler = contentHandler;
- if (m_contentHandler instanceof SerializationHandler) {
- m_Serializer = (SerializationHandler) m_contentHandler;
- }
- else
- m_Serializer = null;
-
- // Set the system ID, if it is given
- m_contentHandler.setDocumentLocator(m_locator);
- if (systemId != null)
- m_locator.setSystemId(systemId);
- else {
- try {
- // Bug see Bugzilla 26741
- m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
- }
- catch (SecurityException se) {// user.dir not accessible from applet
- }
- }
-
- // Set the document locator
- if (m_contentHandler != null)
- m_contentHandler.setDocumentLocator(m_locator);
- try {
- // Bug see Bugzilla 26741
- m_locator.setSystemId(System.getProperty("user.dir") + File.separator + "dummy.xsl");
- }
- catch (SecurityException se){// user.dir not accessible from applet
-
- }
- m_dh = new DOM2Helper();
- }
-
- /**
- * Perform a pre-order traversal non-recursive style.
- *
- * Note that TreeWalker assumes that the subtree is intended to represent
- * a complete (though not necessarily well-formed) document and, during a
- * traversal, startDocument and endDocument will always be issued to the
- * SAX listener.
- *
- * @param pos Node in the tree where to start traversal
- *
- * @throws TransformerException
- */
- public void traverse(Node pos) throws org.xml.sax.SAXException
- {
-
- this.m_contentHandler.startDocument();
-
- traverseFragment(pos);
- this.m_contentHandler.endDocument();
- }
-
-/**
- * @param pos
- * @throws SAXException
- */
-public void traverseFragment(Node pos) throws SAXException {
- Node top = pos;
-
- while (null != pos)
- {
- startNode(pos);
-
- Node nextNode = pos.getFirstChild();
-
- while (null == nextNode)
- {
- endNode(pos);
-
- if (top.equals(pos))
- break;
-
- nextNode = pos.getNextSibling();
-
- if (null == nextNode)
- {
- pos = pos.getParentNode();
-
- if ((null == pos) || (top.equals(pos)))
- {
- if (null != pos)
- endNode(pos);
-
- nextNode = null;
-
- break;
- }
- }
- }
-
- pos = nextNode;
- }
-}
-
- /**
- * Perform a pre-order traversal non-recursive style.
-
- * Note that TreeWalker assumes that the subtree is intended to represent
- * a complete (though not necessarily well-formed) document and, during a
- * traversal, startDocument and endDocument will always be issued to the
- * SAX listener.
- *
- * @param pos Node in the tree where to start traversal
- * @param top Node in the tree where to end traversal
- *
- * @throws TransformerException
- */
- public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
- {
-
- this.m_contentHandler.startDocument();
-
- while (null != pos)
- {
- startNode(pos);
-
- Node nextNode = pos.getFirstChild();
-
- while (null == nextNode)
- {
- endNode(pos);
-
- if ((null != top) && top.equals(pos))
- break;
-
- nextNode = pos.getNextSibling();
-
- if (null == nextNode)
- {
- pos = pos.getParentNode();
-
- if ((null == pos) || ((null != top) && top.equals(pos)))
- {
- nextNode = null;
-
- break;
- }
- }
- }
-
- pos = nextNode;
- }
- this.m_contentHandler.endDocument();
- }
-
- /** Flag indicating whether following text to be processed is raw text */
- boolean nextIsRaw = false;
-
- /**
- * Optimized dispatch of characters.
- */
- private final void dispatachChars(Node node)
- throws org.xml.sax.SAXException
- {
- if(m_Serializer != null)
- {
- this.m_Serializer.characters(node);
- }
- else
- {
- String data = ((Text) node).getData();
- this.m_contentHandler.characters(data.toCharArray(), 0, data.length());
- }
- }
-
- /**
- * Start processing given node
- *
- *
- * @param node Node to process
- *
- * @throws org.xml.sax.SAXException
- */
- protected void startNode(Node node) throws org.xml.sax.SAXException
- {
-
-// TODO: <REVIEW>
-// A Serializer implements ContentHandler, but not NodeConsumer
-// so drop this reference to NodeConsumer which would otherwise
-// pull in all sorts of things
-// if (m_contentHandler instanceof NodeConsumer)
-// {
-// ((NodeConsumer) m_contentHandler).setOriginatingNode(node);
-// }
-// TODO: </REVIEW>
-
- if (node instanceof Locator)
- {
- Locator loc = (Locator)node;
- m_locator.setColumnNumber(loc.getColumnNumber());
- m_locator.setLineNumber(loc.getLineNumber());
- m_locator.setPublicId(loc.getPublicId());
- m_locator.setSystemId(loc.getSystemId());
- }
- else
- {
- m_locator.setColumnNumber(0);
- m_locator.setLineNumber(0);
- }
-
- switch (node.getNodeType())
- {
- case Node.COMMENT_NODE :
- {
- String data = ((Comment) node).getData();
-
- if (m_contentHandler instanceof LexicalHandler)
- {
- LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
-
- lh.comment(data.toCharArray(), 0, data.length());
- }
- }
- break;
- case Node.DOCUMENT_FRAGMENT_NODE :
-
- // ??;
- break;
- case Node.DOCUMENT_NODE :
-
- break;
- case Node.ELEMENT_NODE :
- Element elem_node = (Element) node;
- {
- // Make sure the namespace node
- // for the element itself is declared
- // to the ContentHandler
- String uri = elem_node.getNamespaceURI();
- if (uri != null) {
- String prefix = elem_node.getPrefix();
- if (prefix==null)
- prefix="";
- this.m_contentHandler.startPrefixMapping(prefix,uri);
- }
- }
- NamedNodeMap atts = elem_node.getAttributes();
- int nAttrs = atts.getLength();
- // System.out.println("TreeWalker#startNode: "+node.getNodeName());
-
-
- // Make sure the namespace node of
- // each attribute is declared to the ContentHandler
- for (int i = 0; i < nAttrs; i++)
- {
- final Node attr = atts.item(i);
- final String attrName = attr.getNodeName();
- final int colon = attrName.indexOf(':');
- final String prefix;
-
- // System.out.println("TreeWalker#startNode: attr["+i+"] = "+attrName+", "+attr.getNodeValue());
- if (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
- {
- // Use "" instead of null, as Xerces likes "" for the
- // name of the default namespace. Fix attributed
- // to "Steven Murray" <smurray(a)ebt.com>.
- if (colon < 0)
- prefix = "";
- else
- prefix = attrName.substring(colon + 1);
-
- this.m_contentHandler.startPrefixMapping(prefix,
- attr.getNodeValue());
- }
- else if (colon > 0) {
- prefix = attrName.substring(0,colon);
- String uri = attr.getNamespaceURI();
- if (uri != null)
- this.m_contentHandler.startPrefixMapping(prefix,uri);
- }
- }
-
- String ns = m_dh.getNamespaceOfNode(node);
- if(null == ns)
- ns = "";
- this.m_contentHandler.startElement(ns,
- m_dh.getLocalNameOfNode(node),
- node.getNodeName(),
- new AttList(atts, m_dh));
- break;
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- ProcessingInstruction pi = (ProcessingInstruction) node;
- String name = pi.getNodeName();
-
- // String data = pi.getData();
- if (name.equals("xslt-next-is-raw"))
- {
- nextIsRaw = true;
- }
- else
- {
- this.m_contentHandler.processingInstruction(pi.getNodeName(),
- pi.getData());
- }
- }
- break;
- case Node.CDATA_SECTION_NODE :
- {
- boolean isLexH = (m_contentHandler instanceof LexicalHandler);
- LexicalHandler lh = isLexH
- ? ((LexicalHandler) this.m_contentHandler) : null;
-
- if (isLexH)
- {
- lh.startCDATA();
- }
-
- dispatachChars(node);
-
- {
- if (isLexH)
- {
- lh.endCDATA();
- }
- }
- }
- break;
- case Node.TEXT_NODE :
- {
- //String data = ((Text) node).getData();
-
- if (nextIsRaw)
- {
- nextIsRaw = false;
-
- m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_DISABLE_OUTPUT_ESCAPING, "");
- dispatachChars(node);
- m_contentHandler.processingInstruction(javax.xml.transform.Result.PI_ENABLE_OUTPUT_ESCAPING, "");
- }
- else
- {
- dispatachChars(node);
- }
- }
- break;
- case Node.ENTITY_REFERENCE_NODE :
- {
- EntityReference eref = (EntityReference) node;
-
- if (m_contentHandler instanceof LexicalHandler)
- {
- ((LexicalHandler) this.m_contentHandler).startEntity(
- eref.getNodeName());
- }
- else
- {
-
- // warning("Can not output entity to a pure SAX ContentHandler");
- }
- }
- break;
- default :
- }
- }
-
- /**
- * End processing of given node
- *
- *
- * @param node Node we just finished processing
- *
- * @throws org.xml.sax.SAXException
- */
- protected void endNode(Node node) throws org.xml.sax.SAXException
- {
-
- switch (node.getNodeType())
- {
- case Node.DOCUMENT_NODE :
- break;
-
- case Node.ELEMENT_NODE :
- String ns = m_dh.getNamespaceOfNode(node);
- if(null == ns)
- ns = "";
- this.m_contentHandler.endElement(ns,
- m_dh.getLocalNameOfNode(node),
- node.getNodeName());
-
- if (m_Serializer == null) {
- // Don't bother with endPrefixMapping calls if the ContentHandler is a
- // SerializationHandler because SerializationHandler's ignore the
- // endPrefixMapping() calls anyways. . . . This is an optimization.
- Element elem_node = (Element) node;
- NamedNodeMap atts = elem_node.getAttributes();
- int nAttrs = atts.getLength();
-
- // do the endPrefixMapping calls in reverse order
- // of the startPrefixMapping calls
- for (int i = (nAttrs-1); 0 <= i; i--)
- {
- final Node attr = atts.item(i);
- final String attrName = attr.getNodeName();
- final int colon = attrName.indexOf(':');
- final String prefix;
-
- if (attrName.equals("xmlns") || attrName.startsWith("xmlns:"))
- {
- // Use "" instead of null, as Xerces likes "" for the
- // name of the default namespace. Fix attributed
- // to "Steven Murray" <smurray(a)ebt.com>.
- if (colon < 0)
- prefix = "";
- else
- prefix = attrName.substring(colon + 1);
-
- this.m_contentHandler.endPrefixMapping(prefix);
- }
- else if (colon > 0) {
- prefix = attrName.substring(0, colon);
- this.m_contentHandler.endPrefixMapping(prefix);
- }
- }
- {
- String uri = elem_node.getNamespaceURI();
- if (uri != null) {
- String prefix = elem_node.getPrefix();
- if (prefix==null)
- prefix="";
- this.m_contentHandler.endPrefixMapping(prefix);
- }
- }
- }
- break;
- case Node.CDATA_SECTION_NODE :
- break;
- case Node.ENTITY_REFERENCE_NODE :
- {
- EntityReference eref = (EntityReference) node;
-
- if (m_contentHandler instanceof LexicalHandler)
- {
- LexicalHandler lh = ((LexicalHandler) this.m_contentHandler);
-
- lh.endEntity(eref.getNodeName());
- }
- }
- break;
- default :
- }
- }
-} //TreeWalker
-
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Version.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Version.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/Version.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,148 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: Version.java,v 1.1.2.1 2007/01/09 18:57:25 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-/**
- * Administrative class to keep track of the version number of
- * the Serializer release.
- * <P>This class implements the upcoming standard of having
- * org.apache.project-name.Version.getVersion() be a standard way
- * to get version information.</P>
- * @xsl.usage general
- */
-public final class Version
-{
-
- /**
- * Get the basic version string for the current Serializer.
- * Version String formatted like
- * <CODE>"<B>Serializer</B> <B>Java</B> v.r[.dd| <B>D</B>nn]"</CODE>.
- *
- * Futurework: have this read version info from jar manifest.
- *
- * @return String denoting our current version
- */
- public static String getVersion()
- {
- return getProduct()+" "+getImplementationLanguage()+" "
- +getMajorVersionNum()+"."+getReleaseVersionNum()+"."
- +( (getDevelopmentVersionNum() > 0) ?
- ("D"+getDevelopmentVersionNum()) : (""+getMaintenanceVersionNum()));
- }
-
- /**
- * Print the processor version to the command line.
- *
- * @param argv command line arguments, unused.
- */
- public static void main(String argv[])
- {
- System.out.println(getVersion());
- }
-
- /**
- * Name of product: Serializer.
- */
- public static String getProduct()
- {
- return "Serializer";
- }
-
- /**
- * Implementation Language: Java.
- */
- public static String getImplementationLanguage()
- {
- return "Java";
- }
-
-
- /**
- * Major version number.
- * Version number. This changes only when there is a
- * significant, externally apparent enhancement from
- * the previous release. 'n' represents the n'th
- * version.
- *
- * Clients should carefully consider the implications
- * of new versions as external interfaces and behaviour
- * may have changed.
- */
- public static int getMajorVersionNum()
- {
- return 2;
-
- }
-
- /**
- * Release Number.
- * Release number. This changes when:
- * - a new set of functionality is to be added, eg,
- * implementation of a new W3C specification.
- * - API or behaviour change.
- * - its designated as a reference release.
- */
- public static int getReleaseVersionNum()
- {
- return 7;
- }
-
- /**
- * Maintenance Drop Number.
- * Optional identifier used to designate maintenance
- * drop applied to a specific release and contains
- * fixes for defects reported. It maintains compatibility
- * with the release and contains no API changes.
- * When missing, it designates the final and complete
- * development drop for a release.
- */
- public static int getMaintenanceVersionNum()
- {
- return 0;
- }
-
- /**
- * Development Drop Number.
- * Optional identifier designates development drop of
- * a specific release. D01 is the first development drop
- * of a new release.
- *
- * Development drops are works in progress towards a
- * compeleted, final release. A specific development drop
- * may not completely implement all aspects of a new
- * feature, which may take several development drops to
- * complete. At the point of the final drop for the
- * release, the D suffix will be omitted.
- *
- * Each 'D' drops can contain functional enhancements as
- * well as defect fixes. 'D' drops may not be as stable as
- * the final releases.
- */
- public static int getDevelopmentVersionNum()
- {
- try {
- if ((new String("")).length() == 0)
- return 0;
- else
- return Integer.parseInt("");
- } catch (NumberFormatException nfe) {
- return 0;
- }
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterChain.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterChain.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterChain.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,80 +0,0 @@
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: WriterChain.java,v 1.1.2.1 2007/01/09 18:57:16 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-
-/**
- * It is unfortunate that java.io.Writer is a class rather than an interface.
- * The serializer has a number of classes that extend java.io.Writer
- * and which send their ouput to a yet another wrapped Writer or OutputStream.
- *
- * The purpose of this interface is to force such classes to over-ride all of
- * the important methods defined on the java.io.Writer class, namely these:
- * <code>
- * write(int val)
- * write(char[] chars)
- * write(char[] chars, int start, int count)
- * write(String chars)
- * write(String chars, int start, int count)
- * flush()
- * close()
- * </code>
- * In this manner nothing will accidentally go directly to
- * the base class rather than to the wrapped Writer or OutputStream.
- *
- * The purpose of this class is to have a uniform way of chaining the output of one writer to
- * the next writer in the chain. In addition there are methods to obtain the Writer or
- * OutputStream that this object sends its output to.
- *
- * This interface is only for internal use withing the serializer.
- * @xsl.usage internal
- */
-interface WriterChain
-{
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void write(int val) throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void write(char[] chars) throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void write(char[] chars, int start, int count) throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void write(String chars) throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void write(String chars, int start, int count) throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void flush() throws IOException;
- /** This method forces us to over-ride the method defined in java.io.Writer */
- public void close() throws IOException;
-
- /**
- * If this method returns null, getOutputStream() must return non-null.
- * Get the writer that this writer sends its output to.
- *
- * It is possible that the Writer returned by this method does not
- * implement the WriterChain interface.
- */
- public java.io.Writer getWriter();
-
- /**
- * If this method returns null, getWriter() must return non-null.
- * Get the OutputStream that this writer sends its output to.
- */
- public java.io.OutputStream getOutputStream();
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToASCI.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToASCI.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToASCI.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,153 +0,0 @@
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: WriterToASCI.java,v 1.1.2.1 2007/01/09 18:57:21 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Writer;
-
-
-
-/**
- * This class writes ASCII to a byte stream as quickly as possible. For the
- * moment it does not do buffering, though I reserve the right to do some
- * buffering down the line if I can prove that it will be faster even if the
- * output stream is buffered.
- *
- * This class is only used internally within Xalan.
- *
- * @xsl.usage internal
- */
-class WriterToASCI extends Writer implements WriterChain
-{
-
- /** The byte stream to write to. */
- private final OutputStream m_os;
-
- /**
- * Create an unbuffered ASCII writer.
- *
- *
- * @param os The byte stream to write to.
- */
- public WriterToASCI(OutputStream os)
- {
- m_os = os;
- }
-
- /**
- * Write a portion of an array of characters.
- *
- * @param chars Array of characters
- * @param start Offset from which to start writing characters
- * @param length Number of characters to write
- *
- * @exception IOException If an I/O error occurs
- *
- * @throws java.io.IOException
- */
- public void write(char chars[], int start, int length)
- throws java.io.IOException
- {
-
- int n = length+start;
-
- for (int i = start; i < n; i++)
- {
- m_os.write(chars[i]);
- }
- }
-
- /**
- * Write a single character. The character to be written is contained in
- * the 16 low-order bits of the given integer value; the 16 high-order bits
- * are ignored.
- *
- * <p> Subclasses that intend to support efficient single-character output
- * should override this method.
- *
- * @param c int specifying a character to be written.
- * @exception IOException If an I/O error occurs
- */
- public void write(int c) throws IOException
- {
- m_os.write(c);
- }
-
- /**
- * Write a string.
- *
- * @param s String to be written
- *
- * @exception IOException If an I/O error occurs
- */
- public void write(String s) throws IOException
- {
- int n = s.length();
- for (int i = 0; i < n; i++)
- {
- m_os.write(s.charAt(i));
- }
- }
-
- /**
- * Flush the stream. If the stream has saved any characters from the
- * various write() methods in a buffer, write them immediately to their
- * intended destination. Then, if that destination is another character or
- * byte stream, flush it. Thus one flush() invocation will flush all the
- * buffers in a chain of Writers and OutputStreams.
- *
- * @exception IOException If an I/O error occurs
- */
- public void flush() throws java.io.IOException
- {
- m_os.flush();
- }
-
- /**
- * Close the stream, flushing it first. Once a stream has been closed,
- * further write() or flush() invocations will cause an IOException to be
- * thrown. Closing a previously-closed stream, however, has no effect.
- *
- * @exception IOException If an I/O error occurs
- */
- public void close() throws java.io.IOException
- {
- m_os.close();
- }
-
- /**
- * Get the output stream where the events will be serialized to.
- *
- * @return reference to the result stream, or null of only a writer was
- * set.
- */
- public OutputStream getOutputStream()
- {
- return m_os;
- }
-
- /**
- * Get the writer that this writer directly chains to.
- */
- public Writer getWriter()
- {
- return null;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToUTF8Buffered.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToUTF8Buffered.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/WriterToUTF8Buffered.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,501 +0,0 @@
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: WriterToUTF8Buffered.java,v 1.1.2.1 2007/01/09 18:57:15 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.io.Writer;
-
-
-/**
- * This class writes unicode characters to a byte stream (java.io.OutputStream)
- * as quickly as possible. It buffers the output in an internal
- * buffer which must be flushed to the OutputStream when done. This flushing
- * is done via the close() flush() or flushBuffer() method.
- *
- * This class is only used internally within Xalan.
- *
- * @xsl.usage internal
- */
-final class WriterToUTF8Buffered extends Writer implements WriterChain
-{
-
- /** number of bytes that the byte buffer can hold.
- * This is a fixed constant is used rather than m_outputBytes.lenght for performance.
- */
- private static final int BYTES_MAX=16*1024;
- /** number of characters that the character buffer can hold.
- * This is 1/3 of the number of bytes because UTF-8 encoding
- * can expand one unicode character by up to 3 bytes.
- */
- private static final int CHARS_MAX=(BYTES_MAX/3);
-
- // private static final int
-
- /** The byte stream to write to. (sc & sb remove final to compile in JDK 1.1.8) */
- private final OutputStream m_os;
-
- /**
- * The internal buffer where data is stored.
- * (sc & sb remove final to compile in JDK 1.1.8)
- */
- private final byte m_outputBytes[];
-
- private final char m_inputChars[];
-
- /**
- * The number of valid bytes in the buffer. This value is always
- * in the range <tt>0</tt> through <tt>m_outputBytes.length</tt>; elements
- * <tt>m_outputBytes[0]</tt> through <tt>m_outputBytes[count-1]</tt> contain valid
- * byte data.
- */
- private int count;
-
- /**
- * Create an buffered UTF-8 writer.
- *
- *
- * @param out the underlying output stream.
- *
- * @throws UnsupportedEncodingException
- */
- public WriterToUTF8Buffered(OutputStream out)
- throws UnsupportedEncodingException
- {
- m_os = out;
- // get 3 extra bytes to make buffer overflow checking simpler and faster
- // we won't have to keep checking for a few extra characters
- m_outputBytes = new byte[BYTES_MAX + 3];
-
- // Big enough to hold the input chars that will be transformed
- // into output bytes in m_ouputBytes.
- m_inputChars = new char[CHARS_MAX + 2];
- count = 0;
-
-// the old body of this constructor, before the buffersize was changed to a constant
-// this(out, 8*1024);
- }
-
- /**
- * Create an buffered UTF-8 writer to write data to the
- * specified underlying output stream with the specified buffer
- * size.
- *
- * @param out the underlying output stream.
- * @param size the buffer size.
- * @exception IllegalArgumentException if size <= 0.
- */
-// public WriterToUTF8Buffered(final OutputStream out, final int size)
-// {
-//
-// m_os = out;
-//
-// if (size <= 0)
-// {
-// throw new IllegalArgumentException(
-// SerializerMessages.createMessage(SerializerErrorResources.ER_BUFFER_SIZE_LESSTHAN_ZERO, null)); //"Buffer size <= 0");
-// }
-//
-// m_outputBytes = new byte[size];
-// count = 0;
-// }
-
- /**
- * Write a single character. The character to be written is contained in
- * the 16 low-order bits of the given integer value; the 16 high-order bits
- * are ignored.
- *
- * <p> Subclasses that intend to support efficient single-character output
- * should override this method.
- *
- * @param c int specifying a character to be written.
- * @exception IOException If an I/O error occurs
- */
- public void write(final int c) throws IOException
- {
-
- /* If we are close to the end of the buffer then flush it.
- * Remember the buffer can hold a few more bytes than BYTES_MAX
- */
- if (count >= BYTES_MAX)
- flushBuffer();
-
- if (c < 0x80)
- {
- m_outputBytes[count++] = (byte) (c);
- }
- else if (c < 0x800)
- {
- m_outputBytes[count++] = (byte) (0xc0 + (c >> 6));
- m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f));
- }
- else if (c < 0x10000)
- {
- m_outputBytes[count++] = (byte) (0xe0 + (c >> 12));
- m_outputBytes[count++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f));
- }
- else
- {
- m_outputBytes[count++] = (byte) (0xf0 + (c >> 18));
- m_outputBytes[count++] = (byte) (0x80 + ((c >> 12) & 0x3f));
- m_outputBytes[count++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- m_outputBytes[count++] = (byte) (0x80 + (c & 0x3f));
- }
-
- }
-
-
- /**
- * Write a portion of an array of characters.
- *
- * @param chars Array of characters
- * @param start Offset from which to start writing characters
- * @param length Number of characters to write
- *
- * @exception IOException If an I/O error occurs
- *
- * @throws java.io.IOException
- */
- public void write(final char chars[], final int start, final int length)
- throws java.io.IOException
- {
-
- // We multiply the length by three since this is the maximum length
- // of the characters that we can put into the buffer. It is possible
- // for each Unicode character to expand to three bytes.
-
- int lengthx3 = 3*length;
-
- if (lengthx3 >= BYTES_MAX - count)
- {
- // The requested length is greater than the unused part of the buffer
- flushBuffer();
-
- if (lengthx3 > BYTES_MAX)
- {
- /*
- * The requested length exceeds the size of the buffer.
- * Cut the buffer up into chunks, each of which will
- * not cause an overflow to the output buffer m_outputBytes,
- * and make multiple recursive calls.
- * Be careful about integer overflows in multiplication.
- */
- int split = length/CHARS_MAX;
- final int chunks;
- if (split > 1)
- chunks = split;
- else
- chunks = 2;
- int end_chunk = start;
- for (int chunk = 1; chunk <= chunks; chunk++)
- {
- int start_chunk = end_chunk;
- end_chunk = start + (int) ((((long) length) * chunk) / chunks);
-
- // Adjust the end of the chunk if it ends on a high char
- // of a Unicode surrogate pair and low char of the pair
- // is not going to be in the same chunk
- final char c = chars[end_chunk - 1];
- int ic = chars[end_chunk - 1];
- if (c >= 0xD800 && c <= 0xDBFF) {
- // The last Java char that we were going
- // to process is the first of a
- // Java surrogate char pair that
- // represent a Unicode character.
-
- if (end_chunk < start + length) {
- // Avoid spanning by including the low
- // char in the current chunk of chars.
- end_chunk++;
- } else {
- /* This is the last char of the last chunk,
- * and it is the high char of a high/low pair with
- * no low char provided.
- * TODO: error message needed.
- * The char array incorrectly ends in a high char
- * of a high/low surrogate pair, but there is
- * no corresponding low as the high is the last char
- */
- end_chunk--;
- }
- }
-
-
- int len_chunk = (end_chunk - start_chunk);
- this.write(chars,start_chunk, len_chunk);
- }
- return;
- }
- }
-
-
-
- final int n = length+start;
- final byte[] buf_loc = m_outputBytes; // local reference for faster access
- int count_loc = count; // local integer for faster access
- int i = start;
- {
- /* This block could be omitted and the code would produce
- * the same result. But this block exists to give the JIT
- * a better chance of optimizing a tight and common loop which
- * occurs when writing out ASCII characters.
- */
- char c;
- for(; i < n && (c = chars[i])< 0x80 ; i++ )
- buf_loc[count_loc++] = (byte)c;
- }
- for (; i < n; i++)
- {
-
- final char c = chars[i];
-
- if (c < 0x80)
- buf_loc[count_loc++] = (byte) (c);
- else if (c < 0x800)
- {
- buf_loc[count_loc++] = (byte) (0xc0 + (c >> 6));
- buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f));
- }
- /**
- * The following else if condition is added to support XML 1.1 Characters for
- * UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]*
- * Unicode: [1101 10ww] [wwzz zzyy] (high surrogate)
- * [1101 11yy] [yyxx xxxx] (low surrogate)
- * * uuuuu = wwww + 1
- */
- else if (c >= 0xD800 && c <= 0xDBFF)
- {
- char high, low;
- high = c;
- i++;
- low = chars[i];
-
- buf_loc[count_loc++] = (byte) (0xF0 | (((high + 0x40) >> 8) & 0xf0));
- buf_loc[count_loc++] = (byte) (0x80 | (((high + 0x40) >> 2) & 0x3f));
- buf_loc[count_loc++] = (byte) (0x80 | ((low >> 6) & 0x0f) + ((high << 4) & 0x30));
- buf_loc[count_loc++] = (byte) (0x80 | (low & 0x3f));
- }
- else
- {
- buf_loc[count_loc++] = (byte) (0xe0 + (c >> 12));
- buf_loc[count_loc++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f));
- }
- }
- // Store the local integer back into the instance variable
- count = count_loc;
-
- }
-
- /**
- * Write a string.
- *
- * @param s String to be written
- *
- * @exception IOException If an I/O error occurs
- */
- public void write(final String s) throws IOException
- {
-
- // We multiply the length by three since this is the maximum length
- // of the characters that we can put into the buffer. It is possible
- // for each Unicode character to expand to three bytes.
- final int length = s.length();
- int lengthx3 = 3*length;
-
- if (lengthx3 >= BYTES_MAX - count)
- {
- // The requested length is greater than the unused part of the buffer
- flushBuffer();
-
- if (lengthx3 > BYTES_MAX)
- {
- /*
- * The requested length exceeds the size of the buffer,
- * so break it up in chunks that don't exceed the buffer size.
- */
- final int start = 0;
- int split = length/CHARS_MAX;
- final int chunks;
- if (split > 1)
- chunks = split;
- else
- chunks = 2;
- int end_chunk = 0;
- for (int chunk = 1; chunk <= chunks; chunk++)
- {
- int start_chunk = end_chunk;
- end_chunk = start + (int) ((((long) length) * chunk) / chunks);
- s.getChars(start_chunk,end_chunk, m_inputChars,0);
- int len_chunk = (end_chunk - start_chunk);
-
- // Adjust the end of the chunk if it ends on a high char
- // of a Unicode surrogate pair and low char of the pair
- // is not going to be in the same chunk
- final char c = m_inputChars[len_chunk - 1];
- if (c >= 0xD800 && c <= 0xDBFF) {
- // Exclude char in this chunk,
- // to avoid spanning a Unicode character
- // that is in two Java chars as a high/low surrogate
- end_chunk--;
- len_chunk--;
- if (chunk == chunks) {
- /* TODO: error message needed.
- * The String incorrectly ends in a high char
- * of a high/low surrogate pair, but there is
- * no corresponding low as the high is the last char
- * Recover by ignoring this last char.
- */
- }
- }
-
- this.write(m_inputChars,0, len_chunk);
- }
- return;
- }
- }
-
-
- s.getChars(0, length , m_inputChars, 0);
- final char[] chars = m_inputChars;
- final int n = length;
- final byte[] buf_loc = m_outputBytes; // local reference for faster access
- int count_loc = count; // local integer for faster access
- int i = 0;
- {
- /* This block could be omitted and the code would produce
- * the same result. But this block exists to give the JIT
- * a better chance of optimizing a tight and common loop which
- * occurs when writing out ASCII characters.
- */
- char c;
- for(; i < n && (c = chars[i])< 0x80 ; i++ )
- buf_loc[count_loc++] = (byte)c;
- }
- for (; i < n; i++)
- {
-
- final char c = chars[i];
-
- if (c < 0x80)
- buf_loc[count_loc++] = (byte) (c);
- else if (c < 0x800)
- {
- buf_loc[count_loc++] = (byte) (0xc0 + (c >> 6));
- buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f));
- }
- /**
- * The following else if condition is added to support XML 1.1 Characters for
- * UTF-8: [1111 0uuu] [10uu zzzz] [10yy yyyy] [10xx xxxx]*
- * Unicode: [1101 10ww] [wwzz zzyy] (high surrogate)
- * [1101 11yy] [yyxx xxxx] (low surrogate)
- * * uuuuu = wwww + 1
- */
- else if (c >= 0xD800 && c <= 0xDBFF)
- {
- char high, low;
- high = c;
- i++;
- low = chars[i];
-
- buf_loc[count_loc++] = (byte) (0xF0 | (((high + 0x40) >> 8) & 0xf0));
- buf_loc[count_loc++] = (byte) (0x80 | (((high + 0x40) >> 2) & 0x3f));
- buf_loc[count_loc++] = (byte) (0x80 | ((low >> 6) & 0x0f) + ((high << 4) & 0x30));
- buf_loc[count_loc++] = (byte) (0x80 | (low & 0x3f));
- }
- else
- {
- buf_loc[count_loc++] = (byte) (0xe0 + (c >> 12));
- buf_loc[count_loc++] = (byte) (0x80 + ((c >> 6) & 0x3f));
- buf_loc[count_loc++] = (byte) (0x80 + (c & 0x3f));
- }
- }
- // Store the local integer back into the instance variable
- count = count_loc;
-
- }
-
- /**
- * Flush the internal buffer
- *
- * @throws IOException
- */
- public void flushBuffer() throws IOException
- {
-
- if (count > 0)
- {
- m_os.write(m_outputBytes, 0, count);
-
- count = 0;
- }
- }
-
- /**
- * Flush the stream. If the stream has saved any characters from the
- * various write() methods in a buffer, write them immediately to their
- * intended destination. Then, if that destination is another character or
- * byte stream, flush it. Thus one flush() invocation will flush all the
- * buffers in a chain of Writers and OutputStreams.
- *
- * @exception IOException If an I/O error occurs
- *
- * @throws java.io.IOException
- */
- public void flush() throws java.io.IOException
- {
- flushBuffer();
- m_os.flush();
- }
-
- /**
- * Close the stream, flushing it first. Once a stream has been closed,
- * further write() or flush() invocations will cause an IOException to be
- * thrown. Closing a previously-closed stream, however, has no effect.
- *
- * @exception IOException If an I/O error occurs
- *
- * @throws java.io.IOException
- */
- public void close() throws java.io.IOException
- {
- flushBuffer();
- m_os.close();
- }
-
- /**
- * Get the output stream where the events will be serialized to.
- *
- * @return reference to the result stream, or null of only a writer was
- * set.
- */
- public OutputStream getOutputStream()
- {
- return m_os;
- }
-
- public Writer getWriter()
- {
- // Only one of getWriter() or getOutputStream() can return null
- // This type of writer wraps an OutputStream, not a Writer.
- return null;
- }
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/XSLOutputAttributes.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/XSLOutputAttributes.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/XSLOutputAttributes.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,180 +0,0 @@
-/*
- * Copyright 2003-2004 The Apache Software Foundation.
- *
- * 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.
- */
-/*
- * $Id: XSLOutputAttributes.java,v 1.1.2.1 2007/01/09 18:57:14 alexsmirnov Exp $
- */
-package org.ajax4jsf.xml.serializer;
-
-import java.util.Vector;
-
-/**
- * This interface has methods associated with the XSLT xsl:output attribues
- * specified in the stylesheet that effect the format of the document output.
- *
- * In an XSLT stylesheet these attributes appear for example as:
- * <pre>
- * <xsl:output method="xml" omit-xml-declaration="no" indent="yes"/>
- * </pre>
- * The xsl:output attributes covered in this interface are:
- * <pre>
- * version
- * encoding
- * omit-xml-declarations
- * standalone
- * doctype-public
- * doctype-system
- * cdata-section-elements
- * indent
- * media-type
- * </pre>
- *
- * The one attribute not covered in this interface is <code>method</code> as
- * this value is implicitly chosen by the serializer that is created, for
- * example ToXMLStream vs. ToHTMLStream or another one.
- *
- * This interface is only used internally within Xalan.
- *
- * @xsl.usage internal
- */
-interface XSLOutputAttributes
-{
- /**
- * Returns the previously set value of the value to be used as the public
- * identifier in the document type declaration (DTD).
- *
- *@return the public identifier to be used in the DOCTYPE declaration in the
- * output document.
- */
- public String getDoctypePublic();
- /**
- * Returns the previously set value of the value to be used
- * as the system identifier in the document type declaration (DTD).
- * @return the system identifier to be used in the DOCTYPE declaration in
- * the output document.
- *
- */
- public String getDoctypeSystem();
- /**
- * @return the character encoding to be used in the output document.
- */
- public String getEncoding();
- /**
- * @return true if the output document should be indented to visually
- * indicate its structure.
- */
- public boolean getIndent();
-
- /**
- * @return the number of spaces to indent for each indentation level.
- */
- public int getIndentAmount();
- /**
- * @return the mediatype the media-type or MIME type associated with the
- * output document.
- */
- public String getMediaType();
- /**
- * @return true if the XML declaration is to be omitted from the output
- * document.
- */
- public boolean getOmitXMLDeclaration();
- /**
- * @return a value of "yes" if the <code>standalone</code> delaration is to
- * be included in the output document.
- */
- public String getStandalone();
- /**
- * @return the version of the output format.
- */
- public String getVersion();
-
-
-
-
-
-
- /**
- * Sets the value coming from the xsl:output cdata-section-elements
- * stylesheet property.
- *
- * This sets the elements whose text elements are to be output as CDATA
- * sections.
- * @param URI_and_localNames pairs of namespace URI and local names that
- * identify elements whose text elements are to be output as CDATA sections.
- * The namespace of the local element must be the given URI to match. The
- * qName is not given because the prefix does not matter, only the namespace
- * URI to which that prefix would map matters, so the prefix itself is not
- * relevant in specifying which elements have their text to be output as
- * CDATA sections.
- */
- public void setCdataSectionElements(Vector URI_and_localNames);
-
- /** Set the value coming from the xsl:output doctype-public and doctype-system stylesheet properties
- * @param system the system identifier to be used in the DOCTYPE declaration
- * in the output document.
- * @param pub the public identifier to be used in the DOCTYPE declaration in
- * the output document.
- */
- public void setDoctype(String system, String pub);
-
- /** Set the value coming from the xsl:output doctype-public stylesheet attribute.
- * @param doctype the public identifier to be used in the DOCTYPE
- * declaration in the output document.
- */
- public void setDoctypePublic(String doctype);
- /** Set the value coming from the xsl:output doctype-system stylesheet attribute.
- * @param doctype the system identifier to be used in the DOCTYPE
- * declaration in the output document.
- */
- public void setDoctypeSystem(String doctype);
- /**
- * Sets the character encoding coming from the xsl:output encoding stylesheet attribute.
- * @param encoding the character encoding
- */
- public void setEncoding(String encoding);
- /**
- * Sets the value coming from the xsl:output indent stylesheet
- * attribute.
- * @param indent true if the output document should be indented to visually
- * indicate its structure.
- */
- public void setIndent(boolean indent);
- /**
- * Sets the value coming from the xsl:output media-type stylesheet attribute.
- * @param mediatype the media-type or MIME type associated with the output
- * document.
- */
- public void setMediaType(String mediatype);
- /**
- * Sets the value coming from the xsl:output omit-xml-declaration stylesheet attribute
- * @param b true if the XML declaration is to be omitted from the output
- * document.
- */
- public void setOmitXMLDeclaration(boolean b);
- /**
- * Sets the value coming from the xsl:output standalone stylesheet attribute.
- * @param standalone a value of "yes" indicates that the
- * <code>standalone</code> delaration is to be included in the output
- * document.
- */
- public void setStandalone(String standalone);
- /**
- * Sets the value coming from the xsl:output version attribute.
- * @param version the version of the output format.
- */
- public void setVersion(String version);
-
-}
Deleted: root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/package-info.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/package-info.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/ajax4jsf/xml/serializer/package-info.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,4 +0,0 @@
-/**
- * Implementation of XML serializer
- */
-package org.ajax4jsf.xml.serializer;
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/renderkit/TemplateEncoderRendererBase.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -20,38 +20,16 @@
*/
package org.richfaces.renderkit;
-import java.io.BufferedReader;
import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
import java.io.Writer;
-import java.util.Properties;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXResult;
-import org.ajax4jsf.javascript.JSReference;
-import org.ajax4jsf.javascript.ScriptUtils;
+import org.ajax4jsf.io.SAXResponseWriter;
import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
-import org.ajax4jsf.resource.util.URLToStreamHelper;
-import org.ajax4jsf.webapp.tidy.TidyParser;
-import org.ajax4jsf.webapp.tidy.TidyXMLFilter;
import org.richfaces.component.TemplateComponent;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
import org.xml.sax.ContentHandler;
/**
@@ -60,94 +38,17 @@
*
*/
public abstract class TemplateEncoderRendererBase extends HeaderResourcesRendererBase {
- private static TransformerFactory transformerFactory;
-
- private static TransformerFactory getTransformerFactory() {
- synchronized (TemplateEncoderRendererBase.class) {
- if (transformerFactory == null) {
- transformerFactory = TransformerFactory.newInstance();
- }
- }
-
- return transformerFactory;
- }
public final boolean getRendersChildren() {
return true;
}
- public void writeScriptBody(Writer writer, String string) throws IOException {
- if (string != null) {
- Properties tidyProperties = new Properties();
- InputStream propertiesStream = null;
- try {
- propertiesStream = URLToStreamHelper.urlToStreamSafe(
- TidyXMLFilter.class.getResource("tidy.properties"));
- tidyProperties.load(propertiesStream);
- } finally {
- if (propertiesStream != null) {
- propertiesStream.close();
- }
- }
-
- TidyParser tidyParser = new TidyParser(tidyProperties);
- Document parsedHtml = tidyParser.parseHtmlByTidy(new StringReader(string), null);
-
- Element documentElement = null;
-
- if (parsedHtml != null) {
- documentElement = parsedHtml.getDocumentElement();
- }
-
- if (documentElement != null) {
- writer.write("[");
-
- NodeList nodeList = documentElement.getChildNodes();
- Node bodyNode = nodeList.item(nodeList.getLength() - 1);
- NodeList bodyChildren = bodyNode.getChildNodes();
- int bodyChildrenLength = bodyChildren.getLength();
-
- try {
- Transformer transformer;
-
- TransformerFactory factory = getTransformerFactory();
-
- synchronized (factory) {
- transformer = factory.newTransformer();
- }
-
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
- transformer.setOutputProperty(OutputKeys.METHOD, "xml");
-
- ContentHandler contentHandler = createContentHandler(writer);
- Result result = new SAXResult(contentHandler);
-
- for (int i = 0; i < bodyChildrenLength; i++) {
- if (i != 0) {
- writer.write(", ");
- }
- transformer.transform(new DOMSource(bodyChildren.item(i)), result);
- }
- } catch (TransformerException e) {
- throw new IOException(e.getMessage());
- }
-
- writer.write("]");
-
- } else {
- writer.write(ScriptUtils.toScript(JSReference.NULL));
- }
- } else {
- writer.write(ScriptUtils.toScript(JSReference.NULL));
- }
- }
-
protected void writeScriptBody(FacesContext context, UIComponent component, boolean children)
- throws IOException {
+ throws IOException {
ResponseWriter writer = context.getResponseWriter();
- StringWriter dumpingWriter = new StringWriter();
- ResponseWriter clonedWriter = writer.cloneWithWriter(dumpingWriter);
- context.setResponseWriter(clonedWriter);
+ ContentHandler handler = createContentHandler(writer);
+ SAXResponseWriter saxResponseWriter = new SAXResponseWriter(handler);
+ context.setResponseWriter(saxResponseWriter);
TemplateComponent templateComponent = null;
if (component instanceof TemplateComponent) {
@@ -158,22 +59,26 @@
if (templateComponent != null) {
templateComponent.startTemplateEncode();
}
+ saxResponseWriter.startDocument();
+ //TODO - how to handle extra "root" element?
+ saxResponseWriter.startElement("root", component);
+
if (children) {
this.renderChildren(context, component);
} else {
this.renderChild(context, component);
}
+
+ saxResponseWriter.endElement("root");
+ saxResponseWriter.endDocument();
} finally {
if (templateComponent != null) {
templateComponent.endTemplateEncode();
}
- clonedWriter.flush();
context.setResponseWriter(writer);
}
-
- writeScriptBody(writer, dumpingWriter.toString());
}
public void encodeChildren(FacesContext context, UIComponent component)
@@ -191,20 +96,4 @@
return new MacroDefinitionJSContentHandler(writer, "Richfaces.evalMacro(\"", "\", context)");
}
- public static void main(String[] args) throws Exception {
- StringBuffer buffer = new StringBuffer();
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- String s;
- while ((s = reader.readLine()) != null) {
- buffer.append(s);
- }
-
- new TemplateEncoderRendererBase(){
-
- protected Class<? extends UIComponent> getComponentClass() {
- return null;
- }
-
- }.writeScriptBody(new PrintWriter(System.out), buffer.toString());
- }
}
Modified: root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java
===================================================================
--- root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/java/org/richfaces/resource/ResourceHandlerImpl.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -310,7 +310,10 @@
}
//TODO null content type?
- externalContext.setResponseContentType(resource.getContentType());
+ String contentType = resource.getContentType();
+ if (contentType != null) {
+ externalContext.setResponseContentType(contentType);
+ }
//TODO 'HEAD' HTTP method resources - ?
//TODO setup output buffer size according to configuration parameter
Modified: root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml
===================================================================
--- root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/main/resources/META-INF/faces-config.xml 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,7 +1,6 @@
<?xml version="1.0"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<factory>
<render-kit-factory>org.ajax4jsf.renderkit.ChameleonRenderKitFactory</render-kit-factory>
Modified: root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/AllParsingTests.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/AllParsingTests.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/AllParsingTests.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -30,7 +30,6 @@
TestSuite suite = new TestSuite("Test for org.ajax4jsf.io.parser");
//$JUnit-BEGIN$
suite.addTestSuite(ParsingTest.class);
- suite.addTestSuite(FastParserTest.class);
//$JUnit-END$
return suite;
}
Deleted: root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/test/java/org/ajax4jsf/io/parser/FastParserTest.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -1,156 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.ajax4jsf.io.parser;
-
-import java.io.IOException;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.TestCase;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class FastParserTest extends TestCase {
-
-
- /*
- * Test method for 'org.ajax4jsf.io.parser.FastHtmlParser.parse(Reader, Writer)'
- */
- public void testParse() throws Exception {
-
- String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
- "<!-- Test for page comment -->\n" +
-// "<f:view contentType=\"application/xhtml+xml\" \n" +
-// " xmlns:f=\"http://java.sun.com/jsf/core\"\n" +
-// " xmlns:h=\"http://java.sun.com/jsf/html\" \n" +
-// " xmlns:a4j=\"https://ajax4jsf.dev.java.net/ajax\" >\n" +
- "<html xmlns=\"http://www.w3.org/1999/xhtml\" >\n" +
- "<body>";
- String resultString = parseString(toParse);
- int indexOf = resultString.indexOf("<html");
- assertTrue(indexOf>=0);
- int indexOf2 = resultString.indexOf("<head>");
- assertTrue(indexOf2>=0);
- assertTrue(indexOf2>indexOf);
- int indexOf3 = resultString.indexOf("</head>");
- assertTrue(indexOf3>=0);
- assertTrue(indexOf3>indexOf2);
- }
-
- public void testParseWithHead() throws Exception {
-
- String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
- "<!-- Test for page comment -->\n" +
- "<html xmlns=\"http://www.w3.org/1999/xhtml\" ><head></head>\n" +
- "<body>";
- String resultString = parseString(toParse);
- assertTrue(resultString.indexOf("<html")>=0);
- assertTrue(resultString.indexOf("<head>")>0);
- assertTrue(resultString.indexOf("</head>")>0);
- assertTrue(resultString.indexOf("<head>")==resultString.lastIndexOf("<head>"));
- assertTrue(resultString.indexOf("</head>")==resultString.lastIndexOf("</head>"));
- }
-
- public void testParseWithHeadTitle() throws Exception {
-
- String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
- "<!-- Test for page comment -->\n" +
- "<html xmlns=\"http://www.w3.org/1999/xhtml\" ><head><title>Title</title></head>\n" +
- "<body>";
- String resultString = parseString(toParse);
- assertTrue(resultString.indexOf("<html")>=0);
- assertTrue(resultString.indexOf("<head>")>0);
- assertTrue(resultString.indexOf("</head>")>0);
- assertTrue(resultString.indexOf("<script")>0);
- assertTrue(resultString.indexOf("</script>")>0);
- assertTrue(resultString.indexOf("<head>")==resultString.lastIndexOf("<head>"));
- assertTrue(resultString.indexOf("</head>")==resultString.lastIndexOf("</head>"));
- assertTrue(resultString.indexOf("<head>")<resultString.lastIndexOf("<title>"));
- assertTrue(resultString.indexOf("<title>")<resultString.lastIndexOf("<script"));
- assertTrue(resultString.indexOf("<title>")<resultString.lastIndexOf("<link"));
- assertTrue(resultString.indexOf("</head>")>resultString.lastIndexOf("</script"));
- assertTrue(resultString.indexOf("</head>")>resultString.lastIndexOf("<link"));
- }
-
- public void testParseWithHeadTitleMeta() throws Exception {
-
- String toParse="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n" +
- "<!-- Test for page comment -->\n" +
- "<html xmlns=\"http://www.w3.org/1999/xhtml\" ><head><title>Title</title><meta name='xxx' content='yyy'/> </head>\n" +
- "<body>";
- String resultString = parseString(toParse);
- assertTrue(resultString.indexOf("<html")>=0);
- assertTrue(resultString.indexOf("<head>")>0);
- assertTrue(resultString.indexOf("</head>")>0);
- assertTrue(resultString.indexOf("<script")>0);
- assertTrue(resultString.indexOf("</script>")>0);
- assertTrue(resultString.indexOf("<head>")==resultString.lastIndexOf("<head>"));
- assertTrue(resultString.indexOf("</head>")==resultString.lastIndexOf("</head>"));
- assertTrue(resultString.indexOf("<head>")<resultString.lastIndexOf("<title>"));
- assertTrue(resultString.indexOf("<title>")<resultString.lastIndexOf("<script"));
- assertTrue(resultString.indexOf("<title>")<resultString.lastIndexOf("<link"));
- assertTrue(resultString.indexOf("</head>")>resultString.lastIndexOf("</script"));
- assertTrue(resultString.indexOf("</head>")>resultString.lastIndexOf("<link"));
- assertTrue(resultString.indexOf("<meta")>resultString.lastIndexOf("</script"));
- assertTrue(resultString.indexOf("<meta")>resultString.lastIndexOf("<link"));
- }
-
- /**
- * @param toParse
- * @return
- */
- private String parseString(String toParse) throws Exception {
- FastHtmlParser parser = new FastHtmlParser();
- StringReader in = new StringReader(toParse);
- StringWriter out = new StringWriter();
- Document document = DocumentBuilderFactory.newInstance().
- newDocumentBuilder().newDocument();
-
- Element scriptNode = document.createElement("script");
- scriptNode.setAttribute("src", "/some/script.js");
-
- Element linkNode = document.createElement("link");
- linkNode.setAttribute("href", "/some/script.css");
-
- parser.setHeadNodes(new Node[] {
- scriptNode, linkNode
- });
- try {
- parser.parse(in,out);
- } catch (IOException e) {
- assertFalse("Exception in parsing",true);
- e.printStackTrace();
- }
- String resultString = out.toString();
- System.out.println(resultString);
- return resultString;
- }
-
-}
Modified: root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java
===================================================================
--- root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/impl/src/test/java/org/richfaces/renderkit/TemplateEncoderRendererBaseTest.java 2009-07-23 14:00:42 UTC (rev 14981)
@@ -25,6 +25,7 @@
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
+import javax.faces.component.html.HtmlPanelGroup;
import javax.faces.context.ResponseWriter;
import org.richfaces.test.AbstractFacesTest;
@@ -70,4 +71,39 @@
//that should not fail
rendererBase.writeScriptBody(facesContext, c, true);
}
+
+ public void testEncode() throws Exception {
+ StringWriter controlWriter = new StringWriter();
+ ResponseWriter responseWriter = facesContext.getRenderKit().createResponseWriter(controlWriter, "text/html", "UTF-8");
+ facesContext.setResponseWriter(responseWriter);
+
+ TemplateEncoderRendererBase rendererBase = new TemplateEncoderRendererBase() {
+
+ @Override
+ protected Class<? extends UIComponent> getComponentClass() {
+ return UIOutput.class;
+ }
+ };
+
+ HtmlPanelGroup c = new HtmlPanelGroup();
+
+ for (int i = 0; i < 3; i++) {
+ HtmlPanelGroup c1 = new HtmlPanelGroup();
+ c1.setId("panel" + i);
+
+ UIOutput text = new UIOutput();
+ text.setValue("some text");
+
+ c1.getChildren().add(text);
+ UIOutput text2 = new UIOutput();
+ text2.setValue("some text");
+ c.getChildren().add(text2);
+ c.getChildren().add(c1);
+
+ }
+
+ rendererBase.writeScriptBody(facesContext, c, false);
+ System.out.println(controlWriter.toString());
+ }
+
}
Modified: root/framework/trunk/test-base/src/main/resources/org/richfaces/test/web.xml
===================================================================
--- root/framework/trunk/test-base/src/main/resources/org/richfaces/test/web.xml 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/test-base/src/main/resources/org/richfaces/test/web.xml 2009-07-23 14:00:42 UTC (rev 14981)
@@ -18,18 +18,16 @@
<param-value>.xhtml</param-value>
</context-param>
<context-param>
- <param-name>com.sun.faces.validateXml</param-name>
- <param-value>true</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to validate the XML in your
faces-config.xml resources against the DTD. Default
value is false.
</description>
+ <param-name>com.sun.faces.validateXml</param-name>
+ <param-value>true</param-value>
</context-param>
<context-param>
- <param-name>com.sun.faces.verifyObjects</param-name>
- <param-value>true</param-value>
<description>
Set this flag to true if you want the JavaServer Faces
Reference Implementation to verify that all of the application
@@ -37,6 +35,8 @@
renderers, and validators) can be successfully created.
Default value is false.
</description>
+ <param-name>com.sun.faces.verifyObjects</param-name>
+ <param-value>true</param-value>
</context-param>
<!-- Faces Servlet -->
Modified: root/framework/trunk/test-base/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml
===================================================================
--- root/framework/trunk/test-base/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/test-base/src/test/resources/org/richfaces/test/WEB-INF/faces-config.xml 2009-07-23 14:00:42 UTC (rev 14981)
@@ -38,7 +38,6 @@
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
version="2.0">
<!-- our NumberBean we created before -->
Modified: root/framework/trunk/version-matrix/pom.xml
===================================================================
--- root/framework/trunk/version-matrix/pom.xml 2009-07-23 12:58:03 UTC (rev 14980)
+++ root/framework/trunk/version-matrix/pom.xml 2009-07-23 14:00:42 UTC (rev 14981)
@@ -131,8 +131,12 @@
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
-
<dependency>
+ <groupId>org.jboss.seam</groupId>
+ <artifactId>seam-mock</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>net.sourceforge.nekohtml</groupId>
<artifactId>nekohtml</artifactId>
<version>1.9.12</version>
@@ -250,11 +254,6 @@
<artifactId>oscache</artifactId>
<version>2.3</version>
</dependency>
- <!-- dependency>
- <groupId>nekohtml</groupId>
- <artifactId>nekohtml</artifactId>
- <version>0.9.5</version>
- </dependency -->
<!-- -->
<dependency>
<groupId>org.jboss.cache</groupId>
15 years, 5 months
JBoss Rich Faces SVN: r14980 - branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-07-23 08:58:03 -0400 (Thu, 23 Jul 2009)
New Revision: 14980
Modified:
branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
Log:
contextMenu: onmousemove, onmouseout and onmouseover attributes don't work
https://jira.jboss.org/jira/browse/RF-7497
Modified: branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java
===================================================================
--- branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-23 12:00:23 UTC (rev 14979)
+++ branches/community/3.3.X/ui/contextMenu/src/main/java/org/richfaces/renderkit/html/ContextMenuRendererDelegate.java 2009-07-23 12:58:03 UTC (rev 14980)
@@ -130,6 +130,10 @@
styleClass = "";
}
+ writer.writeAttribute(HTML.onmousemove_ATTRIBUTE, layer.getAttributes().get("onmousemove"), null);
+ writer.writeAttribute(HTML.onmouseout_ATTRIBUTE, layer.getAttributes().get("onmouseout"), null);
+ writer.writeAttribute(HTML.onmouseover_ATTRIBUTE, layer.getAttributes().get("onmouseover"), null);
+
writer.writeAttribute(HTML.class_ATTRIBUTE, "rich-menu-list-border " + styleClass, null);
writer.writeAttribute(HTML.style_ATTRIBUTE, "display: none; z-index: 2; " + style, null);
}
15 years, 5 months
JBoss Rich Faces SVN: r14979 - in branches/community/3.3.X/ui: menu-components/src/main/resources/org/richfaces/renderkit/html/scripts and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2009-07-23 08:00:23 -0400 (Thu, 23 Jul 2009)
New Revision: 14979
Modified:
branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
Log:
RF-7508
Modified: branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java
===================================================================
--- branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2009-07-22 23:38:22 UTC (rev 14978)
+++ branches/community/3.3.X/ui/dropdown-menu/src/main/java/org/richfaces/renderkit/html/DropDownMenuRendererBase.java 2009-07-23 12:00:23 UTC (rev 14979)
@@ -22,16 +22,19 @@
package org.richfaces.renderkit.html;
import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import org.ajax4jsf.javascript.JSFunction;
+import org.ajax4jsf.renderkit.RendererUtils;
import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.ajax4jsf.renderkit.RendererUtils.ScriptHashVariableWrapper;
import org.richfaces.component.UIDropDownMenu;
import org.richfaces.component.UIMenuGroup;
-import org.richfaces.renderkit.ScriptOptions;
public class DropDownMenuRendererBase extends AbstractMenuRenderer {
@@ -43,65 +46,52 @@
@Override
protected String getLayerScript(FacesContext context, UIComponent component) {
StringBuffer buffer = new StringBuffer();
+ Map<String, Object> options = new HashMap<String, Object>();
+ RendererUtils utils = getUtils();
JSFunction function = new JSFunction("new RichFaces.Menu.Layer");
function.addParameter(component.getClientId(context)+"_menu");
- function.addParameter(component.getAttributes().get("showDelay"));
-
- if (component instanceof UIDropDownMenu) {
- function.addParameter(component.getAttributes().get("hideDelay"));
- Object selectedClass = component.getAttributes().get("selectedLabelClass");
- if (null != selectedClass && !"".equals(selectedClass)) {
- function.addParameter(selectedClass);
- }
- } else {
- function.addParameter(new Integer(300));
- }
-
+ utils.addToScriptHash(options, "delay", component.getAttributes().get("showDelay"), "300");
+ utils.addToScriptHash(options, "hideDelay", component.getAttributes().get("hideDelay"), "300");
+ utils.addToScriptHash(options, "selectedClass", component.getAttributes().get("selectedLabelClass"));
+
+ if (!options.isEmpty()) {
+ function.addParameter(options);
+ }
+
function.appendScript(buffer);
+ options = new HashMap<String, Object>();
+
if (component instanceof UIMenuGroup) {
buffer.append(".");
function = new JSFunction("asSubMenu");
function.addParameter(component.getParent().getClientId(context)+"_menu");
function.addParameter(component.getClientId(context));
- String evt = (String) component.getAttributes().get("event");
- if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
- }
- function.addParameter(evt);
- ScriptOptions subMenuOptions = new ScriptOptions(component);
- subMenuOptions.addEventHandler("onopen");
- subMenuOptions.addEventHandler("onclose");
- subMenuOptions.addOption("direction");
- subMenuOptions.addOption("highlightParent", Boolean.TRUE);
- function.addParameter(subMenuOptions);
+ utils.addToScriptHash(options, "evtName", component.getAttributes().get("event"), "onmouseover");
+ utils.addToScriptHash(options, "direction", component.getAttributes().get("direction"), "auto");
+ utils.addToScriptHash(options, "onopen", component.getAttributes().get("onopen"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onclose", component.getAttributes().get("onclose"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ if (!options.isEmpty()) {
+ function.addParameter(options);
+ }
function.appendScript(buffer);
-
} else {
buffer.append(".");
function = new JSFunction("asDropDown");
function.addParameter(component.getClientId(context));
- function.addParameter(component.getClientId(context) + "_span");
- String evt = (String) component.getAttributes().get("event");
- if(evt == null || evt.trim().length() == 0){
- evt = "onmouseover";
- }
- function.addParameter(evt);
- function.addParameter("onmouseout");
- ScriptOptions menuOptions = new ScriptOptions(component);
-
- menuOptions.addOption("direction");
- menuOptions.addOption("jointPoint");
- menuOptions.addOption("verticalOffset");
-
-
- menuOptions.addOption("horizontalOffset");
- menuOptions.addEventHandler("oncollapse");
- menuOptions.addEventHandler("onexpand");
- menuOptions.addEventHandler("onitemselect");
- menuOptions.addEventHandler("ongroupactivate");
- menuOptions.addOption("disabled");
- function.addParameter(menuOptions);
+ utils.addToScriptHash(options, "onEvt", component.getAttributes().get("event"), "onmouseover");
+ utils.addToScriptHash(options, "direction", component.getAttributes().get("direction"), "auto");
+ utils.addToScriptHash(options, "jointPoint", component.getAttributes().get("jointPoint"), "auto");
+ utils.addToScriptHash(options, "verticalOffset", component.getAttributes().get("verticalOffset"), "0");
+ utils.addToScriptHash(options, "horizontalOffset", component.getAttributes().get("horizontalOffset"), "0");
+ utils.addToScriptHash(options, "oncollapse", component.getAttributes().get("oncollapse"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onexpand", component.getAttributes().get("onexpand"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "onitemselect", component.getAttributes().get("onitemselect"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "ongroupactivate", component.getAttributes().get("ongroupactivate"), null, ScriptHashVariableWrapper.EVENT_HANDLER);
+ utils.addToScriptHash(options, "disabled", component.getAttributes().get("disabled"));
+ if (!options.isEmpty()) {
+ function.addParameter(options);
+ }
function.appendScript(buffer);
}
Modified: branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js
===================================================================
--- branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-07-22 23:38:22 UTC (rev 14978)
+++ branches/community/3.3.X/ui/menu-components/src/main/resources/org/richfaces/renderkit/html/scripts/menu.js 2009-07-23 12:00:23 UTC (rev 14979)
@@ -552,8 +552,8 @@
direction = sDir.indexOf('BOTTOM-RIGHT')!= -1?3:direction;
direction = sDir.indexOf('BOTTOM-LEFT') != -1?4:direction;
}
- var hOffset = options.horizontalOffset;
- var vOffset = options.verticalOffset;
+ var hOffset = options.horizontalOffset || 0;
+ var vOffset = options.verticalOffset || 0;
var listPos = this.listPositions(jointPoint, direction);
var layerPos;
@@ -741,18 +741,16 @@
RichFaces.Menu.Layer = Class.create();
RichFaces.Menu.Layer.prototype = {
- initialize: function(id,delay, hideDelay, selectedClass){
+
+ delay : 300,
+ hideDelay : 300,
+
+ initialize: function(id, options){
RichFaces.Menu.Layers.listl.push(id);
this.id = id;
this.layer = $(id);
this.level = 0;
- this.delay = delay;
- if (hideDelay){
- this.hideDelay=hideDelay;
- }
- else{
- this.hideDelay=hideDelay;
- }
+ Object.extend(this, options);
RichFaces.Menu.fitLayerToContent(this.layer);
this.items = new Array();
RichFaces.Menu.Layers.layers[id] = this;
@@ -854,9 +852,6 @@
A4J.AJAX.AddListener(listener);
} */
- if (selectedClass) {
- this.selectedClass = selectedClass;
- }
},
getLabel : function() {
@@ -1028,8 +1023,8 @@
RichFaces.Menu.Layers.LMPopUpL(this.id, false,e);
// if (this.eventOnClose) this.eventOnClose();
},
- asDropDown: function(topLevel, bindElementId, onEvt, offEvt, options){
- this.options = options || {};
+ asDropDown: function(topLevel, options){
+ this.options = options = options || {};
if (this.options.ongroupactivate){
this.eventOnGroupActivate = this.options.ongroupactivate.bindAsEventListener(this);
}
@@ -1065,15 +1060,6 @@
}
};
- if(!onEvt){
- onEvt = 'onmouseover';
- }
- onEvt = this.eventJsToPrototype(onEvt);
- if(!offEvt){
- offEvt = 'onmouseout';
- }
- offEvt = this.eventJsToPrototype(offEvt);
-
var addBinding = function(elementId, eventName, handler) {
var binding = new RichFaces.Menu.Layer.Binding(elementId, eventName, handler);
this.bindings.push(binding);
@@ -1081,7 +1067,7 @@
}.bind(this);
//if (onEvt == 'mouseover') {
- addBinding(topLevel, onEvt, function(e) {
+ addBinding(topLevel, this.eventJsToPrototype(options.onEvt || "mouseover"), function(e) {
menuOn.call(this, e);
mouseover.call(this, e);
}.bindAsEventListener(this));
@@ -1090,23 +1076,18 @@
// addBinding(topLevel, 'mouseover', mouseover.bindAsEventListener(this));
//}
- if (offEvt == 'mouseout') {
- addBinding(topLevel, offEvt, function(e) {
- menuOff.call(this, e);
- mouseout.call(this, e);
- }.bindAsEventListener(this));
- } else {
- addBinding(bindElementId, offEvt, menuOff.bindAsEventListener(this));
- addBinding(topLevel, 'mouseout', mouseout.bindAsEventListener(this));
- }
+ addBinding(topLevel, 'mouseout', function(e) {
+ menuOff.call(this, e);
+ mouseout.call(this, e);
+ }.bindAsEventListener(this));
RichFaces.Menu.Layers.horizontals[this.id] = topLevel;
// }
return this;
},
- asSubMenu: function(parentv, refLayerName, evtName, options){
- this.options = options || {};
+ asSubMenu: function(parentv, refLayerName, options){
+ this.options = options = options || {};
if (this.options.onclose){
this.eventOnClose = this.options.onclose.bindAsEventListener(this);
}
@@ -1114,19 +1095,12 @@
this.eventOnOpen = this.options.onopen.bindAsEventListener(this);
}
- if(!evtName){
- evtName = 'onmouseover';
- }
- evtName = this.eventJsToPrototype(evtName);
this.level = RichFaces.Menu.Layers.layers[parentv].level + 1;
RichFaces.Menu.Layers.father[this.id] = parentv;
- if(!refLayerName){
- refLayerName = parentv;
- }
var refLayer = $(refLayerName);
this.refItem = RichFaces.Menu.Layers.layers[parentv].items[refLayerName];
this.refItem.childMenu = this;
- var binding = new RichFaces.Menu.Layer.Binding(refLayerName, evtName, this.showMe.bindAsEventListener(this));
+ var binding = new RichFaces.Menu.Layer.Binding(refLayerName, this.eventJsToPrototype(options.evtName || "mouseover"), this.showMe.bindAsEventListener(this));
this.bindings.push(binding);
binding.refresh();
15 years, 5 months