001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.data.wfs;
017:
018: import java.util.List;
019:
020: import org.geotools.filter.FidFilter;
021: import org.xml.sax.SAXException;
022:
023: /**
024: * DOCUMENT ME!
025: *
026: * @author dzwiers
027: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/wfs/src/main/java/org/geotools/data/wfs/TransactionResult.java $
028: */
029: public class TransactionResult {
030: /**
031: * no status
032: */
033: public static final int NO_STATUS = 0;
034: /**
035: * success
036: */
037: public static final int SUCCESS = 1;
038: /**
039: * failed
040: */
041: public static final int FAILED = 2;
042: /**
043: * partial
044: */
045: public static final int PARTIAL = 4;
046: /**
047: * A list of the fids returned in the TransactionResult in the order they were received.
048: * The first element is the FID of the first InsertResults response.
049: */
050: private List insertResult;
051: private int status;
052:
053: private SAXException error;
054:
055: private TransactionResult() {
056: // should not be used
057: }
058:
059: /**
060: *
061: * @param status
062: * @param insertResult
063: * @param error
064: */
065: public TransactionResult(int status, List insertResult,
066: SAXException error) {
067: this .status = status;
068: this .insertResult = insertResult;
069: this .error = error;
070: }
071:
072: /**
073: *
074: * @param status
075: * @param insertResult
076: * @param locator nullable
077: * @param message
078: */
079: public TransactionResult(int status, List insertResult,
080: String locator, String message) {
081: this .status = status;
082: this .insertResult = insertResult;
083: error = new SAXException(message + ":"
084: + ((locator == null) ? "" : locator));
085: }
086:
087: /**
088: *
089: * @param s
090: * @return one of the constant status'
091: */
092: public static int parseStatus(String s) {
093: if ("SUCCESS".equalsIgnoreCase(s)) {
094: return SUCCESS;
095: }
096:
097: if ("FAILED".equalsIgnoreCase(s)) {
098: return FAILED;
099: }
100:
101: if ("PARTIAL".equalsIgnoreCase(s)) {
102: return PARTIAL;
103: }
104:
105: return NO_STATUS;
106: }
107:
108: /**
109: *
110: * @param i
111: * @return String representation of the constant value in i
112: */
113: public static String printStatus(int i) {
114: switch (i) {
115: case SUCCESS:
116: return "SUCCESS";
117:
118: case FAILED:
119: return "FAILED";
120:
121: case PARTIAL:
122: return "PARTIAL";
123:
124: default:
125: return "";
126: }
127: }
128:
129: /**
130: * DOCUMENT ME!
131: *
132: * @return Returns the error.
133: */
134: public SAXException getError() {
135: return error;
136: }
137:
138: /**
139: * A list of the fids returned in the TransactionResult in the order they were received.
140: * The first element is the FID of the first InsertResults response.
141: *
142: * @return list of the fids returned in the TransactionResult in the order they were received.
143: */
144: public List getInsertResult() {
145: return insertResult;
146: }
147:
148: /**
149: * DOCUMENT ME!
150: *
151: * @return Returns the status.
152: */
153: public int getStatus() {
154: return status;
155: }
156: }
|