Newer
Older
Alberto Massari
committed
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
Boris Kolpackov
committed
*
Alberto Massari
committed
* http://www.apache.org/licenses/LICENSE-2.0
Boris Kolpackov
committed
*
Alberto Massari
committed
* 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.
*/
#include "DOMXPathResultImpl.hpp"
#include <xercesc/dom/DOMNode.hpp>
#include <xercesc/dom/DOMXPathException.hpp>
XERCES_CPP_NAMESPACE_BEGIN
Boris Kolpackov
committed
DOMXPathResultImpl::DOMXPathResultImpl(ResultType type,
Boris Kolpackov
committed
MemoryManager* const manager)
: fType(type),
fMemoryManager(manager),
fIndex (0)
Alberto Massari
committed
{
Boris Kolpackov
committed
fSnapshot = new (fMemoryManager) RefVectorOf<DOMNode>(13, false, fMemoryManager);
Alberto Massari
committed
}
DOMXPathResultImpl::~DOMXPathResultImpl()
{
delete fSnapshot;
}
Boris Kolpackov
committed
//
//
Boris Kolpackov
committed
DOMXPathResult::ResultType DOMXPathResultImpl::getResultType() const
Alberto Massari
committed
{
Boris Kolpackov
committed
return fType;
Alberto Massari
committed
}
Boris Kolpackov
committed
const DOMTypeInfo* DOMXPathResultImpl::getTypeInfo() const
Alberto Massari
committed
{
Boris Kolpackov
committed
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
bool DOMXPathResultImpl::isNode() const
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
Alberto Massari
committed
}
bool DOMXPathResultImpl::getBooleanValue() const
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
Boris Kolpackov
committed
int DOMXPathResultImpl::getIntegerValue() const
Alberto Massari
committed
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
Boris Kolpackov
committed
double DOMXPathResultImpl::getNumberValue() const
Alberto Massari
committed
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
Boris Kolpackov
committed
const XMLCh* DOMXPathResultImpl::getStringValue() const
Alberto Massari
committed
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
Boris Kolpackov
committed
DOMNode* DOMXPathResultImpl::getNodeValue() const
Alberto Massari
committed
{
Boris Kolpackov
committed
if(fType == ANY_UNORDERED_NODE_TYPE || fType == FIRST_ORDERED_NODE_TYPE)
{
return fSnapshot->size() > 0 ? fSnapshot->elementAt(0) : 0;
}
else if (fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
{
return fIndex < fSnapshot->size() ? fSnapshot->elementAt(fIndex) : 0;
}
else
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
Alberto Massari
committed
}
Boris Kolpackov
committed
bool DOMXPathResultImpl::iterateNext()
Alberto Massari
committed
{
Boris Kolpackov
committed
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
Alberto Massari
committed
}
Boris Kolpackov
committed
bool DOMXPathResultImpl::getInvalidIteratorState() const
Alberto Massari
committed
{
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
}
Boris Kolpackov
committed
bool DOMXPathResultImpl::snapshotItem(XMLSize_t index)
Alberto Massari
committed
{
if(fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
Boris Kolpackov
committed
{
fIndex = index;
return fIndex < fSnapshot->size();
}
else
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
Alberto Massari
committed
}
Boris Kolpackov
committed
XMLSize_t DOMXPathResultImpl::getSnapshotLength() const
Alberto Massari
committed
{
if(fType==UNORDERED_NODE_SNAPSHOT_TYPE || fType==ORDERED_NODE_SNAPSHOT_TYPE)
Boris Kolpackov
committed
return fSnapshot->size();
else
throw DOMXPathException(DOMXPathException::TYPE_ERR, 0, fMemoryManager);
Alberto Massari
committed
}
Boris Kolpackov
committed
void DOMXPathResultImpl::release()
Alberto Massari
committed
{
Boris Kolpackov
committed
DOMXPathResultImpl* me = this;
Alberto Massari
committed
delete me;
}
Boris Kolpackov
committed
//
//
Boris Kolpackov
committed
void DOMXPathResultImpl::reset(ResultType type)
Boris Kolpackov
committed
{
fType = type;
fSnapshot->removeAllElements();
fIndex = 0;
}
void DOMXPathResultImpl::addResult(DOMNode* node)
{
fSnapshot->addElement(node);
}
Alberto Massari
committed
XERCES_CPP_NAMESPACE_END