You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/01/26 15:16:06 UTC
cvs commit: ws-axis/c/src/soap/xsd/constraints Enumeration.cpp Enumeration.hpp
dicka 2005/01/26 06:16:06
Modified: c/src/soap Makefile.am
c/src/soap/xsd Boolean.cpp Boolean.hpp IAnySimpleType.cpp
IAnySimpleType.hpp
c/vc AxisClientDLL.dsp AxisServerDLL.dsp
Added: c/src/soap/xsd/constraints Enumeration.cpp Enumeration.hpp
Log:
Adding constraint validation/processing to XSD SOAP objects. Addition of Enumeration constraint.
Submitted by: Adrian Dick
Revision Changes Path
1.36 +2 -1 ws-axis/c/src/soap/Makefile.am
Index: Makefile.am
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/Makefile.am,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- Makefile.am 26 Jan 2005 09:55:54 -0000 1.35
+++ Makefile.am 26 Jan 2005 14:16:06 -0000 1.36
@@ -77,7 +77,8 @@
xsd/constraints/MaxInclusive.cpp \
xsd/constraints/MaxExclusive.cpp \
xsd/constraints/TotalDigits.cpp \
- xsd/constraints/FractionDigits.cpp
+ xsd/constraints/FractionDigits.cpp \
+ xsd/constraints/Enumeration.cpp
libsoap_la_LIBADD = $(LDFLAGS)
INCLUDES = -I../../include
1.4 +16 -0 ws-axis/c/src/soap/xsd/Boolean.cpp
Index: Boolean.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Boolean.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Boolean.cpp 20 Jan 2005 09:51:23 -0000 1.3
+++ Boolean.cpp 26 Jan 2005 14:16:06 -0000 1.4
@@ -60,4 +60,20 @@
return new WhiteSpace(COLLAPSE);
}
+Enumeration* Boolean::getEnumeration()
+{
+ static AxisChar* BooleanEnumerationValue1 = "true";
+ static AxisChar* BooleanEnumerationValue2 = "false";
+ static AxisChar* BooleanEnumerationValue3 = "1";
+ static AxisChar* BooleanEnumerationValue4 = "0";
+ AxisChar* enumerationValues[] =
+ {
+ BooleanEnumerationValue1,
+ BooleanEnumerationValue2,
+ BooleanEnumerationValue3,
+ BooleanEnumerationValue4
+ };
+ return new Enumeration(enumerationValues, sizeof(enumerationValues)/sizeof(AxisChar*));
+}
+
AXIS_CPP_NAMESPACE_END
1.4 +6 -0 ws-axis/c/src/soap/xsd/Boolean.hpp
Index: Boolean.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/xsd/Boolean.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Boolean.hpp 20 Jan 2005 09:51:23 -0000 1.3
+++ Boolean.hpp 26 Jan 2005 14:16:06 -0000 1.4
@@ -67,6 +67,12 @@
* @return WhiteSpace object set to collapse whitespace
*/
WhiteSpace* getWhiteSpace();
+
+ /**
+ * Creates an Enumeration object to collapse whitespace
+ * @return Enumeration object set to collapse whitespace
+ */
+ Enumeration* getEnumeration();
};
AXIS_CPP_NAMESPACE_END
1.4 +12 -0 ws-axis/c/src/soap/xsd/IAnySimpleType.cpp
Index: IAnySimpleType.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/xsd/IAnySimpleType.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IAnySimpleType.cpp 20 Jan 2005 09:51:23 -0000 1.3
+++ IAnySimpleType.cpp 26 Jan 2005 14:16:06 -0000 1.4
@@ -27,6 +27,13 @@
}
delete pattern;
+ Enumeration* enumeration = getEnumeration();
+ if (enumeration->isSet())
+ {
+ enumeration->validateEnumeration(serializedValue);
+ }
+ delete enumeration;
+
if (m_Buf)
{
delete [] m_Buf;
@@ -111,4 +118,9 @@
return new Pattern();
}
+Enumeration* IAnySimpleType::getEnumeration()
+{
+ return new Enumeration();
+}
+
AXIS_CPP_NAMESPACE_END
1.4 +8 -0 ws-axis/c/src/soap/xsd/IAnySimpleType.hpp
Index: IAnySimpleType.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/soap/xsd/IAnySimpleType.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IAnySimpleType.hpp 20 Jan 2005 09:51:23 -0000 1.3
+++ IAnySimpleType.hpp 26 Jan 2005 14:16:06 -0000 1.4
@@ -26,6 +26,7 @@
#include "../AxisSoapException.h"
#include "constraints/WhiteSpace.hpp"
#include "constraints/Pattern.hpp"
+#include "constraints/Enumeration.hpp"
AXIS_CPP_NAMESPACE_START
@@ -104,6 +105,13 @@
* @return WhiteSpace object
*/
virtual WhiteSpace* getWhiteSpace();
+
+ /**
+ * Creates an Enumeration object. Enumeration is not defined for IAnySimpleType
+ * so an unset Enumeration object is created.
+ * @return Enumeration object
+ */
+ virtual Enumeration* getEnumeration();
/**
* Create a Pattern object with no rules
1.46 +4 -0 ws-axis/c/vc/AxisClientDLL.dsp
Index: AxisClientDLL.dsp
===================================================================
RCS file: /home/cvs/ws-axis/c/vc/AxisClientDLL.dsp,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- AxisClientDLL.dsp 26 Jan 2005 09:55:55 -0000 1.45
+++ AxisClientDLL.dsp 26 Jan 2005 14:16:06 -0000 1.46
@@ -246,6 +246,10 @@
# End Source File
# Begin Source File
+SOURCE=..\src\soap\xsd\constraints\Enumeration.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\src\xml\Event.cpp
# End Source File
# Begin Source File
1.45 +4 -0 ws-axis/c/vc/AxisServerDLL.dsp
Index: AxisServerDLL.dsp
===================================================================
RCS file: /home/cvs/ws-axis/c/vc/AxisServerDLL.dsp,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- AxisServerDLL.dsp 26 Jan 2005 09:55:55 -0000 1.44
+++ AxisServerDLL.dsp 26 Jan 2005 14:16:06 -0000 1.45
@@ -242,6 +242,10 @@
# End Source File
# Begin Source File
+SOURCE=..\src\soap\xsd\constraints\Enumeration.cpp
+# End Source File
+# Begin Source File
+
SOURCE=..\src\xml\Event.cpp
# End Source File
# Begin Source File
1.1 ws-axis/c/src/soap/xsd/constraints/Enumeration.cpp
Index: Enumeration.cpp
===================================================================
#include "Enumeration.hpp"
AXIS_CPP_NAMESPACE_START
Enumeration::Enumeration():m_Enumeration(NULL), m_NumberOfValues(0)
{
m_isSet = false;
}
Enumeration::Enumeration(AxisChar** enumeration, int numberOfValues)
{
m_Enumeration = new AxisChar*[numberOfValues];
memcpy(m_Enumeration, enumeration, (numberOfValues * sizeof(AxisChar*)));
m_NumberOfValues = numberOfValues;
m_isSet = true;
}
Enumeration::~Enumeration()
{
if(m_Enumeration)
{
delete [] m_Enumeration;
m_Enumeration = NULL;
}
}
void Enumeration::validateEnumeration(const AxisChar* value) throw (AxisSoapException)
{
for ( int count = 0 ; count < m_NumberOfValues ; count++)
{
if ( strcmp ( m_Enumeration[count], value ) == 0 )
{
return;
}
}
/*
* If we got this far we didn't find a matching value
* So throw an AxisSoapException
*/
AxisString exceptionMessage =
"Value to be serialized does not match any of the values specified by Enmeration for this type. MinInclusive = ";
for ( int element = 0 ; element < m_NumberOfValues ; element++)
{
exceptionMessage += m_Enumeration[element];
exceptionMessage += ", ";
}
exceptionMessage += "Value = ";
exceptionMessage += value;
exceptionMessage += ".";
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
const_cast<AxisChar*>(exceptionMessage.c_str()));
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/constraints/Enumeration.hpp
Index: Enumeration.hpp
===================================================================
/*
* 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.
*/
/*
* @file Enumeration.hpp
*/
#if !defined(_ENUMERATION_HPP____OF_AXIS_INCLUDED_)
#define _ENUMERATION_HPP____OF_AXIS_INCLUDED_
#include "IConstrainingFacet.hpp"
#include "../../AxisSoapException.h"
AXIS_CPP_NAMESPACE_START
/**
* @class Enumeration
*
* @author Adrian Dick (adrian.dick@uk.ibm.com)
*
*/
class Enumeration : public IConstrainingFacet {
public:
Enumeration();
Enumeration(AxisChar** enumeration, int numberOfValues);
~Enumeration();
void validateEnumeration(const AxisChar* value) throw (AxisSoapException);
private:
AxisChar** m_Enumeration;
int m_NumberOfValues;
};
AXIS_CPP_NAMESPACE_END
#endif