PropertyIsLike.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file PropertyIsLike.cpp
22 
23  \brief It is intended to encode a character string comparison operator with pattern matching.
24  */
25 
26 // TerraLib
27 #include "Globals.h"
28 #include "Literal.h"
29 #include "PropertyIsLike.h"
30 #include "PropertyName.h"
31 
32 
34  : ComparisonOp(Globals::sm_propertyIsLike),
35  m_property(nullptr),
36  m_literalValue(nullptr)
37 {
38 }
39 
41 {
42  delete m_property;
43  delete m_literalValue;
44 }
45 
47 {
48  delete m_property;
49  m_property = p;
50 }
51 
53 {
54  return m_property;
55 }
56 
58 {
59  delete m_literalValue;
60  m_literalValue = l;
61 }
62 
64 {
65  return m_literalValue;
66 }
67 
68 void te::fe::PropertyIsLike::setWildCard(const std::string& w)
69 {
70  m_wildCard = w;
71 }
72 
73 const std::string& te::fe::PropertyIsLike::getWildCard() const
74 {
75  return m_wildCard;
76 }
77 
78 void te::fe::PropertyIsLike::setSingleChar(const std::string& s)
79 {
80  m_singleChar = s;
81 }
82 
83 const std::string& te::fe::PropertyIsLike::getSingleChar() const
84 {
85  return m_singleChar;
86 }
87 
88 void te::fe::PropertyIsLike::setEscapeChar(const std::string& e)
89 {
90  m_escapeChar = e;
91 }
92 
93 const std::string& te::fe::PropertyIsLike::getEscapeChar() const
94 {
95  return m_escapeChar;
96 }
97 
99 {
100  PropertyIsLike* propIsLike = new PropertyIsLike();
101 
102  if(m_property)
103  propIsLike->setPropertyName(new PropertyName(m_property->getName()));
104 
105  if(m_literalValue)
106  propIsLike->setLiteral(new Literal(m_literalValue->getValue()));
107 
108  propIsLike->setWildCard(*(new std::string(m_wildCard)));
109 
110  propIsLike->setSingleChar(m_singleChar);
111 
112  propIsLike->setEscapeChar(m_escapeChar);
113 
114  return propIsLike;
115 }
116 
const std::string & getName() const
It returns the property name.
void setLiteral(Literal *l)
It sets the literal value of the operator.
std::string m_singleChar
The singleChar_ character matches exactly one character. (Mandatory)
std::string m_escapeChar
The escapeChar_ character is used to escape the meaning of the wildCard_, singleChar_ and escapeChar_...
PropertyName * getPropertyName() const
It returns the property name.
const std::string & getWildCard() const
It returns the wild character.
This class can be used to represent literal values.
A comparison operator is used to form expressions that evaluate the mathematical comparison between t...
Definition: ComparisonOp.h:49
void setEscapeChar(const std::string &e)
It sets the escape character.
An static class with global definitions.
void setWildCard(const std::string &w)
It sets the wild character.
Literal * m_literalValue
Mandatory.
Literal * getLiteral() const
It returns the literal value.
PropertyName * m_property
Mandatory.
const std::string & getSingleChar() const
It returns the single wild character.
PropertyIsLike()
It initializes a new PropertyIsLike.
It is intended to encode a character string comparison operator with pattern matching.
void setSingleChar(const std::string &s)
It sets the wild single character.
This class is used to encode the name of any property of an object.
An static class with global definitions.
te::gm::Polygon * p
const std::string & getEscapeChar() const
It returns the escape character.
~PropertyIsLike()
Destructor.
void setPropertyName(PropertyName *p)
It sets the property name.
This class can be used to represent literal values.
Definition: fe/Literal.h:56
const std::string & getValue() const
It returns the literal value.
Definition: fe/Literal.cpp:36
ComparisonOp * clone() const
It creates a new copy of this object.
std::string m_wildCard
The wildCard_ character matches zero or more characters. (Mandatory)
It is intended to encode a character string comparison operator with pattern matching.