Java Code Examples for java.io.Serializable#toString()
The following examples show how to use
java.io.Serializable#toString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ST_Array.java From ofdrw with Apache License 2.0 | 6 votes |
public ST_Array(Serializable... arr) { if (arr == null) { throw new IllegalArgumentException("参数不能为空"); } array = new ArrayList<>(arr.length); for (Serializable item : arr) { if (item instanceof String || item == null) { String str = (String) item; if (item == null || str.trim().length() == 0) { throw new IllegalArgumentException("数组元素为空"); } else { item = str; } } else if (item instanceof Double) { item = STBase.fmt((Double) item); } else if (item instanceof Number) { item = item.toString(); } array.add(item.toString()); } }
Example 2
Source File: UploadId.java From tus-java-server with MIT License | 6 votes |
/** * Create a new {@link UploadId} instance based on the provided object using it's toString method. * @param inputObject The object to use for constructing the ID */ public UploadId(Serializable inputObject) { String inputValue = (inputObject == null ? null : inputObject.toString()); Validate.notBlank(inputValue, "The upload ID value cannot be blank"); this.originalObject = inputObject; URLCodec codec = new URLCodec(); //Check if value is not encoded already try { if (inputValue != null && inputValue.equals(codec.decode(inputValue, UPLOAD_ID_CHARSET))) { this.urlSafeValue = codec.encode(inputValue, UPLOAD_ID_CHARSET); } else { //value is already encoded, use as is this.urlSafeValue = inputValue; } } catch (DecoderException | UnsupportedEncodingException e) { log.warn("Unable to URL encode upload ID value", e); this.urlSafeValue = inputValue; } }
Example 3
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 6 votes |
public static IndexQueryStrategySPI getIndexQueryStrategy(final Map<String, Serializable> params) throws GeoWavePluginException { final Serializable param = params.get(QUERY_INDEX_STRATEGY_KEY); final String strategy = ((param == null) || param.toString().trim().isEmpty()) ? DEFAULT_QUERY_INDEX_STRATEGY : param.toString(); final Iterator<IndexQueryStrategySPI> it = getInxexQueryStrategyList(); while (it.hasNext()) { final IndexQueryStrategySPI spi = it.next(); if (spi.toString().equals(strategy)) { return spi; } } // This would only get hit if the default query index strategy is removed from the spi registry. return null; }
Example 4
Source File: RepositoryDescriptorDAOImpl.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
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; }
Example 5
Source File: SystemTemplateLocationsConstraint.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@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); } }
Example 6
Source File: GeoWavePluginConfig.java From geowave with Apache License 2.0 | 5 votes |
public static URL getAuthorizationURL(final Map<String, Serializable> params) throws GeoWavePluginException { final Serializable param = params.get(AUTH_URL_KEY); if ((param == null) || param.toString().trim().isEmpty()) { return null; } else { try { return new URL(param.toString()); } catch (final MalformedURLException e) { throw new GeoWavePluginException( "Accumulo Plugin: malformed Authorization Service URL " + param.toString()); } } }
Example 7
Source File: EncodingUtils.java From flink with Apache License 2.0 | 5 votes |
public static String encodeObjectToString(Serializable obj) { try { final byte[] bytes = InstantiationUtil.serializeObject(obj); return new String(BASE64_ENCODER.encode(bytes), UTF_8); } catch (Exception e) { throw new ValidationException( "Unable to serialize object '" + obj.toString() + "' of class '" + obj.getClass().getName() + "'."); } }
Example 8
Source File: SerializableToStringCustomConverter.java From scheduling with GNU Affero General Public License v3.0 | 5 votes |
@Override public String convertTo(Serializable source, String destination) { if (source == null) { return null; } try { return source.toString(); } catch (Exception e) { logger.error("Error when converting result to json", e); return null; } }
Example 9
Source File: PropertyAuditFilter.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * @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; }
Example 10
Source File: RuntimeMaster.java From incubator-nemo with Apache License 2.0 | 5 votes |
@Override public void onMessageWithContext(final ControlMessage.Message message, final MessageContext messageContext) { switch (message.getType()) { case RequestBroadcastVariable: final Serializable broadcastId = SerializationUtils.deserialize(message.getRequestbroadcastVariableMsg().getBroadcastId().toByteArray()); final Object broadcastVariable = BroadcastManagerMaster.getBroadcastVariable(broadcastId); if (broadcastVariable == null) { throw new IllegalStateException(broadcastId.toString()); } messageContext.reply( ControlMessage.Message.newBuilder() .setId(RuntimeIdManager.generateMessageId()) .setListenerId(MessageEnvironment.RUNTIME_MASTER_MESSAGE_LISTENER_ID) .setType(ControlMessage.MessageType.InMasterBroadcastVariable) .setBroadcastVariableMsg(ControlMessage.InMasterBroadcastVariableMessage.newBuilder() .setRequestId(message.getId()) // TODO #206: Efficient Broadcast Variable Serialization .setVariable(ByteString.copyFrom(SerializationUtils.serialize((Serializable) broadcastVariable))) .build()) .build()); break; default: throw new IllegalMessageException( new Exception("This message should not be requested to Master :" + message.getType())); } }
Example 11
Source File: BandElementConditionEditPanel.java From nextreports-designer with Apache License 2.0 | 5 votes |
public static String getPropertyValueAsString(Serializable propertyValue) { if (propertyValue instanceof Color) { Color color = (Color)propertyValue; return "R:" + color.getRed() + " G:" + color.getGreen() + " B:"+color.getBlue(); } else if (propertyValue instanceof Font) { Font font = (Font)propertyValue; return font.getFamily() + "," + font.getStyle() + "," + font.getSize(); } else { return propertyValue.toString(); } }
Example 12
Source File: StringUtils.java From charging_pile_cloud with MIT License | 5 votes |
/** * serializable toString * * @param serializable * @return */ public static String toString(Serializable serializable) { if (null == serializable) { return null; } try { return (String) serializable; } catch (Exception e) { return serializable.toString(); } }
Example 13
Source File: UtilFS.java From deep-spark with Apache License 2.0 | 5 votes |
public static TextFileDataTable createTextFileMetaDataFromConfig(ExtractorConfig<Cells> extractorConfig, DeepSparkContext deepSparkContext) { Serializable separator = extractorConfig.getValues().get(ExtractorConstants.FS_FILE_SEPARATOR); String catalogName = (String) extractorConfig.getValues().get(ExtractorConstants.CATALOG); String tableName = (String) extractorConfig.getValues().get(ExtractorConstants.TABLE); final String splitSep = separator.toString(); if(extractorConfig.getValues().get(ExtractorConstants.FS_FILEDATATABLE)!=null ){ final TextFileDataTable textFileDataTable = (TextFileDataTable)extractorConfig.getValues().get(ExtractorConstants.FS_FILEDATATABLE); return textFileDataTable; }else if(extractorConfig.getValues().get(ExtractorConstants.FS_SCHEMA)!=null){ final ArrayList<SchemaMap<?>> columns = (ArrayList<SchemaMap<?>>) extractorConfig.getValues().get (ExtractorConstants.FS_SCHEMA); final TextFileDataTable textFileDataTableTemp = new TextFileDataTable(new TableName(catalogName, tableName), columns); textFileDataTableTemp.setLineSeparator(splitSep); return textFileDataTableTemp; }else{ final TextFileDataTable textFileDataTableTmp = createTextFileFromSchemaFile(buildFilePath(extractorConfig), deepSparkContext); textFileDataTableTmp.setLineSeparator(splitSep); return textFileDataTableTmp; } }
Example 14
Source File: DefaultWebSessionManager.java From nano-framework with Apache License 2.0 | 5 votes |
private void storeSessionId(final Serializable currentId, final HttpServletRequest request, final HttpServletResponse response) { if (currentId == null) { String msg = "sessionId cannot be null when persisting for subsequent requests."; throw new IllegalArgumentException(msg); } final String idString = currentId.toString(); final Cookie cookie = getSessionIdCookie(); cookie.setValue(idString); cookie.saveTo(request, response); LOGGER.debug("Set session ID cookie for session with id {}", idString); }
Example 15
Source File: FilterSourceImpl.java From lams with GNU General Public License v2.0 | 5 votes |
public FilterSourceImpl( MappingDocument mappingDocument, JaxbHbmFilterType filterElement) { super( mappingDocument ); this.name = filterElement.getName(); String explicitAutoAliasInjectionSetting = filterElement.getAutoAliasInjection(); String conditionAttribute = filterElement.getCondition(); String conditionContent = null; for ( Serializable content : filterElement.getContent() ) { if ( String.class.isInstance( content ) ) { final String str = content.toString(); if ( !StringHelper.isEmptyOrWhiteSpace( str ) ) { conditionContent = str.trim(); } } else { final JaxbHbmFilterAliasMappingType aliasMapping = JaxbHbmFilterAliasMappingType.class.cast( content ); if ( StringHelper.isNotEmpty( aliasMapping.getTable() ) ) { aliasTableMap.put( aliasMapping.getAlias(), aliasMapping.getTable() ); } else if ( StringHelper.isNotEmpty( aliasMapping.getEntity() ) ) { aliasEntityMap.put( aliasMapping.getAlias(), aliasMapping.getTable() ); } else { throw new MappingException( "filter alias must define either table or entity attribute", mappingDocument.getOrigin() ); } } } this.condition = Helper.coalesce( conditionContent, conditionAttribute ); this.autoAliasInjection = StringHelper.isNotEmpty( explicitAutoAliasInjectionSetting ) ? Boolean.valueOf( explicitAutoAliasInjectionSetting ) : true; }
Example 16
Source File: DominoUtils.java From org.openntf.domino with Apache License 2.0 | 5 votes |
/** * To unid. * * @param value * the value * @return a 32-character hexadecimal string that can be used as a UNID, uniquely and deterministically based on the value argument */ public static String toUnid(final Serializable value) { if (value instanceof CharSequence && DominoUtils.isUnid((CharSequence) value)) { return value.toString(); } String hash = DominoUtils.md5(value); while (hash.length() < 32) { hash = "0" + hash; } return hash.toUpperCase(); }
Example 17
Source File: ValueString.java From pentaho-kettle with Apache License 2.0 | 4 votes |
@Override public void setSerializable( Serializable ser ) { ser.toString(); }
Example 18
Source File: JSONConversionComponent.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * 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; }
Example 19
Source File: NodeStoreInspector.java From alfresco-repository with GNU Lesser General Public License v3.0 | 4 votes |
/** * Output the node * * @param iIndent int * @param nodeService NodeService * @param nodeRef NodeRef * @return String */ private static String outputNode(int iIndent, NodeService nodeService, NodeRef nodeRef) { StringBuilder builder = new StringBuilder(); try { QName nodeType = nodeService.getType(nodeRef); builder. append(getIndent(iIndent)). append("node: "). append(nodeRef.getId()). append(" ("). append(nodeType.getLocalName()); Collection<QName> aspects = nodeService.getAspects(nodeRef); for (QName aspect : aspects) { builder. append(", "). append(aspect.getLocalName()); } builder.append(")\n"); Map<QName, Serializable> props = nodeService.getProperties(nodeRef); for (QName name : props.keySet()) { String valueAsString = "null"; Serializable value = props.get(name); if (value != null) { valueAsString = value.toString(); } builder. append(getIndent(iIndent+1)). append("@"). append(name.getLocalName()). append(" = "). append(valueAsString). append("\n"); } Collection<ChildAssociationRef> childAssocRefs = nodeService.getChildAssocs(nodeRef); for (ChildAssociationRef childAssocRef : childAssocRefs) { builder. append(getIndent(iIndent+1)). append("-> "). append(childAssocRef.getQName().toString()). append(" ("). append(childAssocRef.getQName().toString()). append(")\n"); builder.append(outputNode(iIndent+2, nodeService, childAssocRef.getChildRef())); } Collection<AssociationRef> assocRefs = nodeService.getTargetAssocs(nodeRef, RegexQNamePattern.MATCH_ALL); for (AssociationRef assocRef : assocRefs) { builder. append(getIndent(iIndent+1)). append("-> associated to "). append(assocRef.getTargetRef().getId()). append("\n"); } } catch (InvalidNodeRefException invalidNode) { invalidNode.printStackTrace(); } return builder.toString(); }
Example 20
Source File: JGrowlAjaxBehavior.java From nextreports-server with Apache License 2.0 | 4 votes |
private String renderFeedback() { // this.getComponent().getFeedbackMessage(); FeedbackMessages fm = Session.get().getFeedbackMessages(); Iterator<FeedbackMessage> iter = fm.iterator(); StringBuilder sb = new StringBuilder(); while (iter.hasNext()) { FeedbackMessage message = iter.next(); if ((message.getReporter() != null) || message.isRendered()) { // if a component-level message, don't show it continue; } // if we are info stick set to info else set to message level String cssClassSuffix = ""; switch (message.getLevel()) { case INFO_STICKY: case INFO_FADE: cssClassSuffix = "INFO"; break; case ERROR_STICKY: cssClassSuffix = "ERROR"; break; default: cssClassSuffix = message.getLevelAsString(); break; } Serializable serializable = message.getMessage(); // grab the message, if it's null use an empty string String msg = (serializable == null) ? StringUtils.EMPTY : serializable.toString(); sb.append("$.jGrowl(\"").append(escape(msg)).append('\"'); sb.append(", {"); // set the css style, i.e. the theme sb.append("theme: \'jgrowl-").append(cssClassSuffix).append("\'"); // set afterOpen String afterOpen = getAfterOpenJavaScript(); if (StringUtils.isNotEmpty(afterOpen)) { sb.append(", afterOpen: " + getAfterOpenJavaScript()); } // set sticky if (message.getLevel() > FeedbackMessage.INFO) { sb.append(", sticky: true"); } else { // default is 3000 (3sec) sb.append(", life: 5000"); } sb.append("});"); message.markRendered(); } return sb.toString(); }