本文整理汇总了Java中java.io.Serializable.toString方法的典型用法代码示例。如果您正苦于以下问题:Java Serializable.toString方法的具体用法?Java Serializable.toString怎么用?Java Serializable.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.Serializable
的用法示例。
在下文中一共展示了Serializable.toString方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisplayLabel
import java.io.Serializable; //导入方法依赖的package包/类
@Override
public String getDisplayLabel(String constraintAllowableValue, MessageLookup messageLookup)
{
if (constraintAllowableValue.startsWith("N"))
{
Serializable nameProperty = nodeService.getProperty(new NodeRef(constraintAllowableValue.substring(1)),
ContentModel.PROP_NAME);
return nameProperty.toString();
}
else if (constraintAllowableValue.equals(SystemTemplateLocationsConstraint.NULL_SYSTEM_TEMPLATE))
{
String message = messageLookup.getMessage(SystemTemplateLocationsConstraint.NULL_SYSTEM_TEMPLATE_MESSAGE,
I18NUtil.getLocale());
return message == null ? constraintAllowableValue : message;
}
else
{
return constraintAllowableValue.substring(constraintAllowableValue.lastIndexOf("/") + 1);
}
}
示例2: getDescriptor
import java.io.Serializable; //导入方法依赖的package包/类
public String getDescriptor(final String key)
{
String strValue = null;
final QName qname = QName.createQName(key, RepositoryDescriptorDAOImpl.this.namespaceService);
final Serializable value = this.properties.get(qname);
if (value != null)
{
if (value instanceof Collection)
{
final Collection<?> coll = (Collection<?>) value;
if (coll.size() > 0)
{
strValue = coll.iterator().next().toString();
}
}
else
{
strValue = value.toString();
}
}
return strValue;
}
示例3: findCacheValue
import java.io.Serializable; //导入方法依赖的package包/类
/**
* Looks for a key that contains the toString() of the value
*/
private Object findCacheValue(SimpleCache<Serializable, ValueHolder<Serializable>> cache, Serializable key)
{
Collection<Serializable> keys = cache.getKeys();
for (Serializable keyInCache : keys)
{
String keyInCacheStr = keyInCache.toString();
String keyStr = key.toString();
if (keyInCacheStr.endsWith(keyStr))
{
Object value = TransactionalCache.getSharedCacheValue(cache, keyInCache);
return value;
}
}
return null;
}
示例4: create
import java.io.Serializable; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public final RestResponse create(@Validated @RequestBody final DtoT dto)
throws DtoCrudException {
Serializable id = doInsert(dto);
String location = getMappingUrlOfController() + "/" + id.toString();
return RestResponse.of(ResponseEntity
.status(HttpStatus.CREATED)
.header("Location", location)
.build());
}
示例5: accept
import java.io.Serializable; //导入方法依赖的package包/类
/**
* @param rootPath String
* @return boolean
*/
@Override
public boolean accept(String rootPath, Map<String, Serializable> auditMap)
{
String[] root = splitPath(rootPath);
String rootProperty = getPropertyName(PROPERY_NAME_PREFIX, getPropertyName(root));
String defaultRootProperty = getDefaultRootProperty(root);
if ("true".equalsIgnoreCase(getProperty(rootProperty, defaultRootProperty, ENABLED)))
{
for (Map.Entry<String, Serializable> entry : auditMap.entrySet())
{
Serializable value = entry.getValue();
if (value == null)
{
value = "null";
}
String stringValue = (value instanceof String) ? (String)value : value.toString();
String[] key = splitPath(entry.getKey());
String propertyValue = getProperty(rootProperty, defaultRootProperty, key);
if (!acceptValue(stringValue, propertyValue, rootProperty, key))
{
if (logger.isDebugEnabled())
{
logger.debug("Rejected \n\t "+rootPath+'/'+entry.getKey()+"="+stringValue+
"\n\t"+getPropertyName(rootProperty, getPropertyName(key))+"="+propertyValue);
}
return false;
}
}
}
return true;
}
示例6: decorate
import java.io.Serializable; //导入方法依赖的package包/类
/**
* @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable)
*/
@SuppressWarnings("unchecked")
public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value)
{
String username = value.toString();
String firstName = null;
String lastName = null;
JSONObject map = new JSONObject();
map.put("userName", username);
// DO NOT change this to just use getPersonOrNullImpl
// - there is Cloud THOR prod hack see personServiceImpl.personExists
// - and THOR-293
if (username.isEmpty())
{
firstName = "";
lastName = "";
}
else if (this.personService.personExists(username))
{
NodeRef personRef = this.personService.getPerson(username, false);
firstName = (String)this.nodeService.getProperty(personRef, ContentModel.PROP_FIRSTNAME);
lastName = (String)this.nodeService.getProperty(personRef, ContentModel.PROP_LASTNAME);
}
else if (username.equals("System") || username.startsWith("[email protected]"))
{
firstName = "System";
lastName = "User";
}
else
{
map.put("isDeleted", true);
return map;
}
map.put("firstName", firstName);
map.put("lastName", lastName);
map.put("displayName", ((firstName != null ? firstName + " " : "") + (lastName != null ? lastName : "")).replaceAll("^\\s+|\\s+$", ""));
return map;
}
示例7: serializeToJSONString
import java.io.Serializable; //导入方法依赖的package包/类
public String serializeToJSONString(Serializable value)
{
if (value != null && typeConverter.INSTANCE.getConverter(value.getClass(), String.class) == null)
{
// There is no converter
return value.toString();
}
else
{
return typeConverter.INSTANCE.convert(String.class, value);
}
}
示例8: encode
import java.io.Serializable; //导入方法依赖的package包/类
@Override
public String encode(final Serializable value) {
return value.toString();
}
示例9: decode
import java.io.Serializable; //导入方法依赖的package包/类
@Override
public String decode(final Serializable value) {
return value.toString();
}
示例10: propertyToJSON
import java.io.Serializable; //导入方法依赖的package包/类
/**
* Handles the work of converting values to JSON.
*
* @param nodeRef NodeRef
* @param propertyName QName
* @param key String
* @param value Serializable
* @return the JSON value
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object propertyToJSON(final NodeRef nodeRef, final QName propertyName, final String key, final Serializable value)
{
if (value != null)
{
// Has a decorator has been registered for this property?
if (propertyDecorators.containsKey(propertyName))
{
JSONAware jsonAware = propertyDecorators.get(propertyName).decorate(propertyName, nodeRef, value);
if (jsonAware != null)
{
return jsonAware;
}
}
else
{
// Built-in data type processing
if (value instanceof Date)
{
JSONObject dateObj = new JSONObject();
dateObj.put("value", JSONObject.escape(value.toString()));
dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date)value)));
return dateObj;
}
else if (value instanceof List)
{
// Convert the List to a JSON list by recursively calling propertyToJSON
List<Object> jsonList = new ArrayList<Object>(((List<Serializable>) value).size());
for (Serializable listItem : (List<Serializable>) value)
{
jsonList.add(propertyToJSON(nodeRef, propertyName, key, listItem));
}
return jsonList;
}
else if (value instanceof Double)
{
return (Double.isInfinite((Double)value) || Double.isNaN((Double)value) ? null : value.toString());
}
else if (value instanceof Float)
{
return (Float.isInfinite((Float)value) || Float.isNaN((Float)value) ? null : value.toString());
}
else
{
return value.toString();
}
}
}
return null;
}
示例11: assertVirtualNode
import java.io.Serializable; //导入方法依赖的package包/类
protected void assertVirtualNode(NodeRef nodeRef, Map<QName, Serializable> expectedProperties)
{
assertNotNull(Reference.fromNodeRef(nodeRef));
assertTrue(nodeService.hasAspect(nodeRef,
VirtualContentModel.ASPECT_VIRTUAL));
Set<QName> aspects = nodeService.getAspects(nodeRef);
assertTrue("Smart virtual node missing virtual aspect",aspects.contains(VirtualContentModel.ASPECT_VIRTUAL));
//ACE-5303 injected properties title and description require the titled aspect
assertTrue("Smaft virtual node missing titled aspect",aspects.contains(ContentModel.ASPECT_TITLED));
Map<QName, Serializable> nodeProperties = nodeService.getProperties(nodeRef);
List<QName> mandatoryProperties = Arrays.asList(ContentModel.PROP_STORE_IDENTIFIER,
ContentModel.PROP_STORE_PROTOCOL,
ContentModel.PROP_LOCALE,
ContentModel.PROP_MODIFIED,
ContentModel.PROP_MODIFIER,
ContentModel.PROP_CREATED,
ContentModel.PROP_CREATOR,
ContentModel.PROP_NODE_DBID,
ContentModel.PROP_DESCRIPTION);
Set<QName> missingPropreties = new HashSet<>(mandatoryProperties);
missingPropreties.removeAll(nodeProperties.keySet());
assertTrue("Mandatory properties are missing" + missingPropreties,
missingPropreties.isEmpty());
assertFalse("ACE-5303 : ContentModel.PROP_TITLE should remain unset",nodeProperties.containsKey(ContentModel.PROP_TITLE));
Set<Entry<QName, Serializable>> epEntries = expectedProperties.entrySet();
StringBuilder unexpectedBuilder = new StringBuilder();
for (Entry<QName, Serializable> entry : epEntries)
{
Serializable actualValue = nodeProperties.get(entry.getKey());
Serializable expectedValue = expectedProperties.get(entry.getKey());
boolean fail = false;
String expectedValueStr = null;
if (expectedValue != null)
{
expectedValueStr = expectedValue.toString();
if (!expectedValue.equals(actualValue))
{
fail = true;
}
}
else if (actualValue != null)
{
fail = true;
expectedValueStr = "<null>";
}
if (fail)
{
unexpectedBuilder.append("\n");
unexpectedBuilder.append(entry.getKey());
unexpectedBuilder.append(" expected[");
unexpectedBuilder.append(expectedValueStr);
unexpectedBuilder.append("] != actua[");
unexpectedBuilder.append(actualValue);
unexpectedBuilder.append("]");
}
}
String unexpectedStr = unexpectedBuilder.toString();
assertTrue("Unexpected property values : " + unexpectedStr,
unexpectedStr.isEmpty());
}
示例12: toDisplayPath
import java.io.Serializable; //导入方法依赖的package包/类
/**
* Return the human readable form of the specified node Path. Slow version of the method
* that extracts the name of each node in the Path from the supplied NodeService.
*
* @return human readable form of the Path excluding the final element
*/
public String toDisplayPath(NodeService nodeService, PermissionService permissionService)
{
StringBuilder buf = new StringBuilder(64);
for (int i=0; i<elements.size()-1; i++)
{
String elementString = null;
Element element = elements.get(i);
if (element instanceof ChildAssocElement)
{
ChildAssociationRef elementRef = ((ChildAssocElement)element).getRef();
if (elementRef.getParentRef() != null)
{
Serializable nameProp = null;
if (permissionService.hasPermission(
elementRef.getChildRef(), PermissionService.READ) == AccessStatus.ALLOWED)
{
nameProp = nodeService.getProperty(elementRef.getChildRef(), ContentModel.PROP_NAME);
// use the name property if we are allowed access to it
elementString = nameProp.toString();
}
else
{
// revert to using QName if not
elementString = elementRef.getQName().getLocalName();
}
}
}
else
{
elementString = element.getElementString();
}
if (elementString != null)
{
buf.append("/");
buf.append(elementString);
}
}
return buf.toString();
}
示例13: serializeValue
import java.io.Serializable; //导入方法依赖的package包/类
/**
* Serialize value as string.
*
* @param value the value
* @return the string
*/
protected String serializeValue(final Serializable value) {
return value.toString();
}