2 * Copyright 2007 Google Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License. You may obtain a copy of
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 * License for the specific language governing permissions and limitations under
16 package com
.google
.appengine
.api
.datastore
;
18 import java
.io
.Serializable
;
21 * {@code Text} wraps around a string of unlimited size.
23 * Ordinary Java strings stored as properties in {@code Entity}
24 * objects are limited to 500 characters. However, {@code Text}
25 * objects can also be stored in properties, and are unlimited in
26 * size. However, they will not be indexed for query purposes.
29 public final class Text
implements Serializable
{
31 public static final long serialVersionUID
= -8389037235415462280L;
36 * This constructor exists for frameworks (e.g. Google Web Toolkit)
37 * that require it for serialization purposes. It should not be
40 @SuppressWarnings("unused")
45 * Construct a new {@code Text} object with the specified value.
46 * This object cannot be modified after construction.
48 public Text(String value
) {
53 * Return the value of this {@code Text}. Can be {@code null}.
55 public String
getValue() {
60 public int hashCode() {
64 return value
.hashCode();
68 * Two {@code Text} objects are considered equal if their content
69 * strings match exactly.
72 public boolean equals(Object object
) {
73 if (object
instanceof Text
) {
74 Text key
= (Text
) object
;
76 return key
.value
== null;
78 return value
.equals(key
.value
);
84 * Returns the first 70 characters of the underlying string.
87 public String
toString() {
89 return "<Text: null>";
92 if (text
.length() > 70) {
93 text
= text
.substring(0, 70) + "...";
95 return "<Text: " + text
+ ">";