Lucene++ - a full-featured, c++ search engine
API Documentation


 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Token.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2011 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef TOKEN_H
8 #define TOKEN_H
9 
10 #include "Attribute.h"
11 #include "AttributeSource.h"
12 
13 namespace Lucene
14 {
76  class LPPAPI Token : public Attribute
77  {
78  public:
80  Token();
81 
85  Token(int32_t start, int32_t end);
86 
91  Token(int32_t start, int32_t end, const String& type);
92 
97  Token(int32_t start, int32_t end, int32_t flags);
98 
104  Token(const String& text, int32_t start, int32_t end);
105 
112  Token(const String& text, int32_t start, int32_t end, const String& type);
113 
120  Token(const String& text, int32_t start, int32_t end, int32_t flags);
121 
123  Token(CharArray startTermBuffer, int32_t termBufferOffset, int32_t termBufferLength, int32_t start, int32_t end);
124 
125  virtual ~Token();
126 
128 
129  public:
130  static const String& DEFAULT_TYPE();
131 
132  protected:
133  static const int32_t MIN_BUFFER_SIZE;
134 
135  CharArray _termBuffer;
136  int32_t _termLength;
137  int32_t _startOffset;
138  int32_t _endOffset;
139  String _type;
140  int32_t flags;
143 
144  public:
164  virtual void setPositionIncrement(int32_t positionIncrement);
165 
168  virtual int32_t getPositionIncrement();
169 
175  virtual String term();
176 
181  virtual void setTermBuffer(const wchar_t* buffer, int32_t offset, int32_t length);
182 
185  virtual void setTermBuffer(const String& buffer);
186 
191  virtual void setTermBuffer(const String& buffer, int32_t offset, int32_t length);
192 
196  virtual CharArray termBuffer();
197 
199  virtual wchar_t* termBufferArray();
200 
207  virtual CharArray resizeTermBuffer(int32_t newSize);
208 
210  virtual int32_t termLength();
211 
216  virtual void setTermLength(int32_t length);
217 
223  virtual int32_t startOffset();
224 
227  virtual void setStartOffset(int32_t offset);
228 
231  virtual int32_t endOffset();
232 
235  virtual void setEndOffset(int32_t offset);
236 
239  virtual void setOffset(int32_t startOffset, int32_t endOffset);
240 
242  virtual String type();
243 
246  virtual void setType(const String& type);
247 
253  virtual int32_t getFlags();
254 
256  virtual void setFlags(int32_t flags);
257 
259  virtual PayloadPtr getPayload();
260 
262  virtual void setPayload(PayloadPtr payload);
263 
264  virtual String toString();
265 
267  virtual void clear();
268 
269  virtual LuceneObjectPtr clone(LuceneObjectPtr other = LuceneObjectPtr());
270 
273  TokenPtr clone(CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset);
274 
275  virtual bool equals(LuceneObjectPtr other);
276  virtual int32_t hashCode();
277 
281  TokenPtr reinit(CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset, const String& newType);
282 
286  TokenPtr reinit(CharArray newTermBuffer, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset);
287 
291  TokenPtr reinit(const String& newTerm, int32_t newStartOffset, int32_t newEndOffset, const String& newType);
292 
296  TokenPtr reinit(const String& newTerm, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset, const String& newType);
297 
301  TokenPtr reinit(const String& newTerm, int32_t newStartOffset, int32_t newEndOffset);
302 
306  TokenPtr reinit(const String& newTerm, int32_t newTermOffset, int32_t newTermLength, int32_t newStartOffset, int32_t newEndOffset);
307 
309  void reinit(TokenPtr prototype);
310 
312  void reinit(TokenPtr prototype, const String& newTerm);
313 
315  void reinit(TokenPtr prototype, CharArray newTermBuffer, int32_t offset, int32_t length);
316 
317  virtual void copyTo(AttributePtr target);
318 
320  static AttributeFactoryPtr TOKEN_ATTRIBUTE_FACTORY();
321 
322  protected:
324  void ConstructToken(int32_t start, int32_t end, const String& type, int32_t flags);
325 
329  void growTermBuffer(int32_t newSize);
330 
331  void initTermBuffer();
332 
334  void clearNoTermBuffer();
335  };
336 
340  {
341  public:
343  virtual ~TokenAttributeFactory();
344 
346 
347  protected:
348  AttributeFactoryPtr delegate;
349 
350  public:
351  virtual AttributePtr createAttributeInstance(const String& className);
352  virtual bool equals(LuceneObjectPtr other);
353  virtual int32_t hashCode();
354  };
355 }
356 
357 #endif

clucene.sourceforge.net