List of usage examples for java.lang Enum name
String name
To view the source code for java.lang Enum name.
Click Source Link
From source file:org.structr.core.graph.IndexNodeCommand.java
private void addNode(final AbstractNode node) { try {/* w ww. j av a2 s.com*/ String uuid = node.getProperty(AbstractNode.uuid); // Don't touch non-structr node if (uuid == null) { return; } for (Enum index : (NodeIndex[]) arguments.get("indices")) { Set<PropertyKey> properties = EntityContext.getSearchableProperties(node.getClass(), index.name()); for (PropertyKey key : properties) { addProperty(node, key, index.name()); } } Node dbNode = node.getNode(); if ((dbNode.hasProperty(Location.latitude.dbName())) && (dbNode.hasProperty(Location.longitude.dbName()))) { LayerNodeIndex layerIndex = (LayerNodeIndex) indices.get(NodeIndex.layer.name()); try { synchronized (layerIndex) { layerIndex.add(dbNode, "", ""); } // If an exception is thrown here, the index was deleted // and has to be recreated. } catch (NotFoundException nfe) { logger.log(Level.SEVERE, "Could not add node to layer index because the db could not find the node", nfe); } catch (Exception e) { logger.log(Level.SEVERE, "Could not add node to layer index", e); // final Map<String, String> config = new HashMap<String, String>(); // // config.put(LayerNodeIndex.LAT_PROPERTY_KEY, Location.Key.latitude.name()); // config.put(LayerNodeIndex.LON_PROPERTY_KEY, Location.Key.longitude.name()); // config.put(SpatialIndexProvider.GEOMETRY_TYPE, LayerNodeIndex.POINT_PARAMETER); // // layerIndex = new LayerNodeIndex("layerIndex", graphDb, config); // logger.log(Level.WARNING, "Created layer node index due to exception", e); // // indices.put(NodeIndex.layer.name(), layerIndex); // // // try again // layerIndex.add(dbNode, "", ""); } } } catch (Throwable t) { t.printStackTrace(); logger.log(Level.WARNING, "Unable to add node {0}: {1}", new Object[] { node.getNode().getId(), t.getMessage() }); } }
From source file:org.structr.core.graph.IndexNodeCommand.java
private void removeNode(final AbstractNode node) { try {//w w w . ja va 2 s . c o m String uuid = node.getProperty(AbstractNode.uuid); // Don't touch non-structr node if (uuid == null) { return; } for (Enum index : (NodeIndex[]) arguments.get("indices")) { Set<PropertyKey> properties = EntityContext.getSearchableProperties(node.getClass(), index.name()); for (PropertyKey key : properties) { removeProperty(node, key, index.name()); } } Node dbNode = node.getNode(); if ((dbNode.hasProperty(Location.latitude.dbName())) && (dbNode.hasProperty(Location.longitude.dbName()))) { LayerNodeIndex layerIndex = (LayerNodeIndex) indices.get(NodeIndex.layer.name()); try { synchronized (layerIndex) { layerIndex.remove(dbNode, "", ""); } // If an exception is thrown here, the index was deleted // and has to be recreated. } catch (NotFoundException nfe) { logger.log(Level.SEVERE, "Could not remove node from layer index because the db could not find the node", nfe); } catch (Exception e) { logger.log(Level.SEVERE, "Could not remove node from layer index", e); // final Map<String, String> config = new HashMap<String, String>(); // // config.put(LayerNodeIndex.LAT_PROPERTY_KEY, Location.Key.latitude.name()); // config.put(LayerNodeIndex.LON_PROPERTY_KEY, Location.Key.longitude.name()); // config.put(SpatialIndexProvider.GEOMETRY_TYPE, LayerNodeIndex.POINT_PARAMETER); // // layerIndex = new LayerNodeIndex("layerIndex", graphDb, config); // logger.log(Level.WARNING, "Created layer node index due to exception", e); // // indices.put(NodeIndex.layer.name(), layerIndex); // // // try again // layerIndex.add(dbNode, "", ""); } } } catch (Throwable t) { t.printStackTrace(); logger.log(Level.WARNING, "Unable to remove node {0}: {1}", new Object[] { node.getNode().getId(), t.getMessage() }); } }
From source file:com.ottogroup.bi.spqr.repository.CachedComponentClassLoader.java
/** * Initializes the class loader by pointing it to folder holding managed JAR files * @param componentFolder/*from w ww. j a va2 s. c o m*/ * @throws IOException * @throws RequiredInputMissingException */ public void initialize(final String componentFolder) throws IOException, RequiredInputMissingException { /////////////////////////////////////////////////////////////////// // validate input if (StringUtils.isBlank(componentFolder)) throw new RequiredInputMissingException("Missing required value for parameter 'componentFolder'"); File folder = new File(componentFolder); if (!folder.isDirectory()) throw new IOException("Provided input '" + componentFolder + "' does not reference a valid folder"); File[] jarFiles = folder.listFiles(); if (jarFiles == null || jarFiles.length < 1) throw new RequiredInputMissingException("No JAR files found in folder '" + componentFolder + "'"); // /////////////////////////////////////////////////////////////////// logger.info("Initializing component classloader [folder=" + componentFolder + "]"); // step through jar files, ensure it is a file and iterate through its contents for (File jarFile : jarFiles) { if (jarFile.isFile()) { JarInputStream jarInputStream = null; try { jarInputStream = new JarInputStream(new FileInputStream(jarFile)); JarEntry jarEntry = null; while ((jarEntry = jarInputStream.getNextJarEntry()) != null) { String jarEntryName = jarEntry.getName(); // if the current file references a class implementation, replace slashes by dots, strip // away the class suffix and add a reference to the classes-2-jar mapping if (StringUtils.endsWith(jarEntryName, ".class")) { jarEntryName = jarEntryName.substring(0, jarEntryName.length() - 6).replace('/', '.'); this.byteCode.put(jarEntryName, loadBytes(jarInputStream)); } else { // ...and add a mapping for resource to jar file as well this.resources.put(jarEntryName, loadBytes(jarInputStream)); } } } catch (Exception e) { logger.error("Failed to read from JAR file '" + jarFile.getAbsolutePath() + "'. Error: " + e.getMessage()); } finally { try { jarInputStream.close(); } catch (Exception e) { logger.error("Failed to close open JAR file '" + jarFile.getAbsolutePath() + "'. Error: " + e.getMessage()); } } } } logger.info("Analyzing " + this.byteCode.size() + " classes for component annotation"); // load classes from jars marked component files and extract the deployment descriptors for (String cjf : this.byteCode.keySet()) { try { Class<?> c = loadClass(cjf); Annotation spqrComponentAnnotation = getSPQRComponentAnnotation(c); if (spqrComponentAnnotation != null) { Method spqrAnnotationTypeMethod = spqrComponentAnnotation.getClass() .getMethod(ANNOTATION_TYPE_METHOD, (Class[]) null); Method spqrAnnotationNameMethod = spqrComponentAnnotation.getClass() .getMethod(ANNOTATION_NAME_METHOD, (Class[]) null); Method spqrAnnotationVersionMethod = spqrComponentAnnotation.getClass() .getMethod(ANNOTATION_VERSION_METHOD, (Class[]) null); Method spqrAnnotationDescriptionMethod = spqrComponentAnnotation.getClass() .getMethod(ANNOTATION_DESCRIPTION_METHOD, (Class[]) null); @SuppressWarnings("unchecked") Enum<MicroPipelineComponentType> o = (Enum<MicroPipelineComponentType>) spqrAnnotationTypeMethod .invoke(spqrComponentAnnotation, (Object[]) null); final MicroPipelineComponentType componentType = Enum.valueOf(MicroPipelineComponentType.class, o.name()); final String componentName = (String) spqrAnnotationNameMethod.invoke(spqrComponentAnnotation, (Object[]) null); final String componentVersion = (String) spqrAnnotationVersionMethod .invoke(spqrComponentAnnotation, (Object[]) null); final String componentDescription = (String) spqrAnnotationDescriptionMethod .invoke(spqrComponentAnnotation, (Object[]) null); this.managedComponents.put(getManagedComponentKey(componentName, componentVersion), new ComponentDescriptor(c.getName(), componentType, componentName, componentVersion, componentDescription)); logger.info("pipeline component found [type=" + componentType + ", name=" + componentName + ", version=" + componentVersion + "]"); ; } } catch (Throwable e) { e.printStackTrace(); logger.error("Failed to load class '" + cjf + "'. Error: " + e.getMessage()); } } }
From source file:org.cloudgraph.store.mapping.StoreMapping.java
private CloudGraphStoreMapping deriveMapping() throws NoSuchFieldException, SecurityException { if (log.isDebugEnabled()) log.debug("deriving mapping"); CloudGraphStoreMapping result = new CloudGraphStoreMapping(); for (Class<?> c : this.annotatedClasses) { org.cloudgraph.store.mapping.annotation.Table tableAnnot = c .getAnnotation(org.cloudgraph.store.mapping.annotation.Table.class); if (log.isDebugEnabled()) log.debug("discovered " + tableAnnot.name() + " table mapping"); Table table = new Table(); result.getTables().add(table);//w w w .j a v a 2 s. c om table.setName(tableAnnot.name()); table.setDataColumnFamilyName(tableAnnot.dataColumnFamilyName()); table.setTombstoneRows(tableAnnot.tombstoneRows()); table.setTombstoneRowsOverwriteable(tableAnnot.tombstoneRowsOverwriteable()); table.setUniqueChecks(tableAnnot.uniqueChecks()); if (tableAnnot.hashAlgorithm().ordinal() != HashAlgorithmName.NONE.ordinal()) { HashAlgorithm hash = new HashAlgorithm(); hash.setName(tableAnnot.hashAlgorithm()); table.setHashAlgorithm(hash); } // add properties DataGraph dataGraph = new DataGraph(); table.getDataGraphs().add(dataGraph); org.plasma.sdo.annotation.Type typeAnnot = c.getAnnotation(org.plasma.sdo.annotation.Type.class); String typeName = typeAnnot.name(); if (typeName == null || typeName.trim().length() == 0) typeName = c.getSimpleName(); // use the enumeration class name dataGraph.setType(typeName); org.plasma.sdo.annotation.Namespace namespaceAnnot = c.getPackage() .getAnnotation(org.plasma.sdo.annotation.Namespace.class); dataGraph.setUri(namespaceAnnot.uri()); if (log.isDebugEnabled()) log.debug("added data graph for type: " + dataGraph.getUri() + "#" + dataGraph.getType()); ColumnKeyModel columnModel = new ColumnKeyModel(); columnModel.setFieldDelimiter("|"); columnModel.setReferenceMetadataDelimiter("#"); columnModel.setSequenceDelimiter("@"); dataGraph.setColumnKeyModel(columnModel); ColumnKeyField pkgColKeyField = new ColumnKeyField(); pkgColKeyField.setName(MetaFieldName.PKG); columnModel.getColumnKeyFields().add(pkgColKeyField); ColumnKeyField typeColKeyField = new ColumnKeyField(); typeColKeyField.setName(MetaFieldName.TYPE); columnModel.getColumnKeyFields().add(typeColKeyField); ColumnKeyField propColKeyField = new ColumnKeyField(); propColKeyField.setName(MetaFieldName.PROPERTY); columnModel.getColumnKeyFields().add(propColKeyField); RowKeyModel rowKeyModel = new RowKeyModel(); dataGraph.setRowKeyModel(rowKeyModel); rowKeyModel.setFieldDelimiter(tableAnnot.rowKeyFieldDelimiter()); for (Object o : c.getEnumConstants()) { Enum<?> enm = (Enum<?>) o; Field field = c.getField(enm.name()); org.cloudgraph.store.mapping.annotation.RowKeyField rowKeyFieldAnnot = field .getAnnotation(org.cloudgraph.store.mapping.annotation.RowKeyField.class); if (rowKeyFieldAnnot != null) { RowKeyField rowKeyField = new RowKeyField(); rowKeyModel.getRowKeyFields().add(rowKeyField); DataField userDefinedField = new DataField(); rowKeyField.setDataField(userDefinedField); userDefinedField.setPath(field.getName()); userDefinedField.setCodecType(rowKeyFieldAnnot.codecType()); } } } return result; }
From source file:org.mule.module.extension.internal.capability.xml.schema.SchemaBuilder.java
private LocalSimpleType createEnumSimpleType(DataType enumType) { LocalSimpleType enumValues = new LocalSimpleType(); Restriction restriction = new Restriction(); enumValues.setRestriction(restriction); restriction.setBase(SchemaConstants.STRING); Class<? extends Enum> enumClass = (Class<? extends Enum>) enumType.getRawType(); for (Enum value : enumClass.getEnumConstants()) { NoFixedFacet noFixedFacet = objectFactory.createNoFixedFacet(); noFixedFacet.setValue(value.name()); JAXBElement<NoFixedFacet> enumeration = objectFactory.createEnumeration(noFixedFacet); enumValues.getRestriction().getFacets().add(enumeration); }// ww w .j av a 2s . co m return enumValues; }
From source file:icom.jpa.bdk.dao.EmailMessageDAO.java
public void copyObjectState(ManagedObjectProxy obj, Object bdkObject, Projection proj) { if (bdkObject instanceof EmailMessageContent) { EmailMessageContentUtil.copyObjectState(obj, bdkObject, proj); return;/* w ww . j av a 2 s. c o m*/ } super.copyObjectState(obj, bdkObject, proj); EmailMessage bdkMessage = (EmailMessage) bdkObject; Persistent pojoIdentifiable = obj.getPojoObject(); PersistenceContext context = obj.getPersistenceContext(); BdkProjectionManager projManager = (BdkProjectionManager) obj.getProviderProxy(); Projection lastLoadedProjection = projManager.getLastLoadedProjection(obj); if (isBetweenProjections(UnifiedMessageInfo.Attributes.userCreationDate.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); // sent time is represented by user created on time of artifact if (bdkEmailMessageContent != null) { assignAttributeValue(pojoIdentifiable, ArtifactInfo.Attributes.userCreationDate.name(), bdkEmailMessageContent.getSentDate()); } } catch (Exception ex) { // ignore } } if (isBetweenProjections(EntityInfo.Attributes.name.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); RawString bdkSubject = bdkEmailMessageContent.getSubject(); if (bdkSubject != null) { String name = bdkSubject.getString(); // TODO handle unsupported character set exception // subject is represented by name of entity assignAttributeValue(pojoIdentifiable, EntityInfo.Attributes.name.name(), name); } else { assignAttributeValue(pojoIdentifiable, EntityInfo.Attributes.name.name(), null); } } catch (Exception ex) { // ignore } } if (isBetweenProjections(UnifiedMessageInfo.Attributes.toReceivers.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); Collection<EmailRecipient> bdkRecipients = bdkEmailMessageContent.getTOReceivers(); marshallAssignEmbeddableObjects(obj, UnifiedMessageInfo.Attributes.toReceivers.name(), bdkRecipients, Vector.class, proj); } catch (Exception ex) { // ignore } } if (isBetweenProjections(UnifiedMessageInfo.Attributes.ccReceivers.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); Collection<EmailRecipient> bdkRecipients = bdkEmailMessageContent.getCCReceivers(); marshallAssignEmbeddableObjects(obj, UnifiedMessageInfo.Attributes.ccReceivers.name(), bdkRecipients, Vector.class, proj); } catch (Exception ex) { // ignore } } if (isBetweenProjections(UnifiedMessageInfo.Attributes.bccReceivers.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); Collection<EmailRecipient> bdkRecipients = bdkEmailMessageContent.getBCCReceivers(); marshallAssignEmbeddableObjects(obj, UnifiedMessageInfo.Attributes.bccReceivers.name(), bdkRecipients, Vector.class, proj); } catch (Exception ex) { // ignore } } if (isBetweenProjections(MessageInfo.Attributes.sender.name(), lastLoadedProjection, proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); EmailParticipant bdkSender = bdkEmailMessageContent.getSender(); marshallAssignEmbeddableObject(obj, MessageInfo.Attributes.sender.name(), bdkSender, proj); } catch (Exception ex) { // ignore } } if ( /* always copy content !isPartOfProjection(MessageInfo.Attributes.content.name(), lastLoadedProjection) &&*/ isPartOfProjection(MessageInfo.Attributes.content.name(), proj)) { try { EmailMessageContent bdkEmailMessageContent = bdkMessage.getContent(); Content bdkChildContent = bdkEmailMessageContent.getBody(); if (bdkChildContent != null) { boolean createDependentProxy = true; Object pojoContent = getAttributeValue(pojoIdentifiable, MessageInfo.Attributes.content.name()); if (pojoContent != null) { ManagedObjectProxy contentObj = (ManagedObjectProxy) getAttributeValue(pojoContent, AbstractBeanInfo.Attributes.mop.name()); if (contentObj != null) { StreamInfo subBeanInfo = (StreamInfo) context.getBeanInfo(pojoContent); subBeanInfo.detachHierarchy(contentObj); contentObj.getProviderProxy().copyLoadedProjection(contentObj, bdkChildContent, proj); assignAttributeValue(pojoContent, AbstractBeanInfo.Attributes.mop.name(), contentObj); createDependentProxy = false; } } if (createDependentProxy) { ManagedObjectProxy contentObj = getNonIdentifiableDependentProxy(context, bdkChildContent, obj, MessageInfo.Attributes.content.name()); contentObj.getProviderProxy().copyLoadedProjection(contentObj, bdkChildContent, proj); assignAttributeValue(pojoIdentifiable, MessageInfo.Attributes.content.name(), contentObj.getPojoObject()); } } } catch (Exception ex) { // ignore } } if (!isPartOfProjection(UnifiedMessageInfo.Attributes.flags.name(), lastLoadedProjection) && isPartOfProjection(UnifiedMessageInfo.Attributes.flags.name(), proj)) { try { Collection<String> enumConstantNames = new ArrayList<String>(); List<MessageFlag> bdkFlags = bdkMessage.getFlags(); if (bdkFlags != null) { for (Enum<?> bdkFlag : bdkFlags) { String bdkFlagName = bdkFlag.name(); String pojoFlagName = bdkToPojoFlagNameMap.get(bdkFlagName); enumConstantNames.add(pojoFlagName); } } EnumSet<?> pojoFlags = instantiateEnumSet(BeanHandler.getBeanPackageName(), IcomBeanEnumeration.UnifiedMessageFlagEnum.name(), enumConstantNames); assignAttributeValue(pojoIdentifiable, UnifiedMessageInfo.Attributes.flags.name(), pojoFlags); } catch (Exception ex) { // ignore } } if (!isPartOfProjection(UnifiedMessageInfo.Attributes.editMode.name(), lastLoadedProjection) && isPartOfProjection(UnifiedMessageInfo.Attributes.editMode.name(), proj)) { try { String modeName = getMessageMode(bdkMessage); // draft, delivered (sent or received), other (new) assignEnumConstant(pojoIdentifiable, UnifiedMessageInfo.Attributes.editMode.name(), BeanHandler.getBeanPackageName(), IcomBeanEnumeration.UnifiedMessageEditModeEnum.name(), modeName); } catch (Exception ex) { // ignore } } if (!isPartOfProjection(UnifiedMessageInfo.Attributes.channel.name(), lastLoadedProjection) && isPartOfProjection(UnifiedMessageInfo.Attributes.channel.name(), proj)) { try { EmailMessageType type = bdkMessage.getType(); String bdkChannelName = null; if (type != null) { bdkChannelName = type.name(); } else { bdkChannelName = EmailMessageType.EMAIL.name(); } String pojoChannelName = EmailMessageDAO.bdkToPojoChannelTypeNameMap.get(bdkChannelName); assignEnumConstant(pojoIdentifiable, UnifiedMessageInfo.Attributes.channel.name(), BeanHandler.getBeanPackageName(), IcomBeanEnumeration.UnifiedMessageChannelEnum.name(), pojoChannelName); } catch (Exception ex) { // ignore } } if (!isPartOfProjection(UnifiedMessageInfo.Attributes.messageDispositionNotificationRequested.name(), lastLoadedProjection) && isPartOfProjection(UnifiedMessageInfo.Attributes.messageDispositionNotificationRequested.name(), proj)) { try { /* boolean receiptRequested = bdkMessage.isReceiptRequested(); assignAttributeValue(pojoIdentifiable, UnifiedMessageInfo.Attributes.messageDispositionNotificationRequested.name(), new Boolean(receiptRequested)); */ } catch (Exception ex) { // ignore } } if (!isPartOfProjection(UnifiedMessageInfo.Attributes.size.name(), lastLoadedProjection) && isPartOfProjection(UnifiedMessageInfo.Attributes.size.name(), proj)) { try { long size = bdkMessage.getSize(); assignAttributeValue(pojoIdentifiable, UnifiedMessageInfo.Attributes.size.name(), new Long(size)); } catch (Exception ex) { // ignore } } }
From source file:com.datatorrent.stram.webapp.OperatorDiscoverer.java
public JSONObject describeClass(Class<?> clazz) throws Exception { JSONObject desc = new JSONObject(); desc.put("name", clazz.getName()); if (clazz.isEnum()) { @SuppressWarnings("unchecked") Class<Enum<?>> enumClass = (Class<Enum<?>>) clazz; ArrayList<String> enumNames = Lists.newArrayList(); for (Enum<?> e : enumClass.getEnumConstants()) { enumNames.add(e.name()); }/*from ww w . j ava2 s. c o m*/ desc.put("enum", enumNames); } UI_TYPE ui_type = UI_TYPE.getEnumFor(clazz); if (ui_type != null) { desc.put("uiType", ui_type.getName()); } desc.put("properties", getClassProperties(clazz, 0)); return desc; }
From source file:net.sourceforge.vulcan.spring.SpringBeanXmlEncoder.java
void encodeEnum(Element propertyNode, Enum<?> e) { final Element factory = new Element("bean"); propertyNode.addContent(factory);//from w w w . java2 s . c o m if (factoryExpert.needsFactory(e)) { encodeBeanByFactory(factory, e); return; } factory.setAttribute("class", FieldRetrievingFactoryBean.class.getName()); final Element targetClass = new Element("property"); targetClass.setAttribute("name", "targetClass"); encodeAsValue(targetClass, e.getDeclaringClass().getName()); final Element targetField = new Element("property"); targetField.setAttribute("name", "targetField"); encodeAsValue(targetField, e.name()); factory.addContent(targetClass); factory.addContent(targetField); }
From source file:com.nesscomputing.jackson.NessObjectMapperProvider.java
@Override public ObjectMapper get() { final ObjectMapper mapper = new ObjectMapper(jsonFactory); // Set the features for (Map.Entry<Enum<?>, Boolean> entry : featureMap.entrySet()) { final Enum<?> key = entry.getKey(); if (key instanceof JsonGenerator.Feature) { mapper.configure(((JsonGenerator.Feature) key), entry.getValue()); } else if (key instanceof JsonParser.Feature) { mapper.configure(((JsonParser.Feature) key), entry.getValue()); } else if (key instanceof SerializationFeature) { mapper.configure(((SerializationFeature) key), entry.getValue()); } else if (key instanceof DeserializationFeature) { mapper.configure(((DeserializationFeature) key), entry.getValue()); } else if (key instanceof MapperFeature) { mapper.configure(((MapperFeature) key), entry.getValue()); } else {// w ww.j av a2 s . c o m throw new IllegalArgumentException("Can not configure ObjectMapper with " + key.name()); } } for (Module module : modules) { mapper.registerModule(module); } // by default, don't serialize null values. mapper.setSerializationInclusion(Include.NON_NULL); return mapper; }
From source file:com.prowidesoftware.swift.model.AbstractSwiftMessage.java
/** * @see #getProperty(String)/* ww w.j a v a2 s . c o m*/ */ @SuppressWarnings("rawtypes") public String getProperty(Enum key) { return getProperty(key.name()); }