List of usage examples for org.dom4j Element attribute
Attribute attribute(QName qName);
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineEditText(Element tagElement) { int characterId = RecordXMLReader.getCharacterId(tagElement); Rect bounds = RecordXMLReader.readRect(RecordXMLReader.getElement("bounds", tagElement)); String var = tagElement.attributeValue("variable"); DefineEditText defineEditText = new DefineEditText(characterId, bounds, var); if (RecordXMLReader.getBooleanAttribute("wordwrap", tagElement)) { defineEditText.setWordWrap(true); }/*from w w w. j a v a2 s .co m*/ if (RecordXMLReader.getBooleanAttribute("multiline", tagElement)) { defineEditText.setMultiline(true); } if (RecordXMLReader.getBooleanAttribute("password", tagElement)) { defineEditText.setPassword(true); } if (RecordXMLReader.getBooleanAttribute("readonly", tagElement)) { defineEditText.setReadOnly(true); } if (RecordXMLReader.getBooleanAttribute("autosize", tagElement)) { defineEditText.setAutoSize(true); } if (RecordXMLReader.getBooleanAttribute("noselect", tagElement)) { defineEditText.setNoSelect(true); } if (RecordXMLReader.getBooleanAttribute("border", tagElement)) { defineEditText.setBorder(true); } if (RecordXMLReader.getBooleanAttribute("border", tagElement)) { defineEditText.setBorder(true); } if (RecordXMLReader.getBooleanAttribute("html", tagElement)) { defineEditText.setHtml(true); } if (RecordXMLReader.getBooleanAttribute("useoutlines", tagElement)) { defineEditText.setUseOutlines(true); } Attribute maxLength = tagElement.attribute("maxlength"); if (maxLength != null) { defineEditText.setMaxLength(Integer.parseInt(maxLength.getValue())); } Element initialText = tagElement.element("initialtext"); if (initialText != null) { defineEditText.setInitialText(initialText.getText()); } Element color = tagElement.element("color"); if (color != null) { defineEditText.setTextColor(RecordXMLReader.readRGBA(color)); } Element font = tagElement.element("font"); if (font != null) { defineEditText.setFont(RecordXMLReader.getIntAttribute("fontid", font), RecordXMLReader.getIntAttribute("height", font)); } Element layout = tagElement.element("layout"); if (layout != null) { String alignString = getStringAttribute("align", layout); short align; if (alignString.equals("center")) { align = DefineEditText.ALIGN_CENTER; } else if (alignString.equals("justify")) { align = DefineEditText.ALIGN_JUSTIFY; } else if (alignString.equals("right")) { align = DefineEditText.ALIGN_RIGHT; } else { align = DefineEditText.ALIGN_LEFT; } int leftMargin = RecordXMLReader.getIntAttribute("leftmargin", layout); int rightMargin = RecordXMLReader.getIntAttribute("rightmargin", layout); int indent = RecordXMLReader.getIntAttribute("indent", layout); int leading = RecordXMLReader.getIntAttribute("leading", layout); defineEditText.setLayout(align, leftMargin, rightMargin, indent, leading); } return defineEditText; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineFont2(Element tagElement) { int characterId = RecordXMLReader.getCharacterId(tagElement); String fontName = getStringAttribute("fontname", tagElement); Shape[] glyphShapes = null;//from w ww. j a v a2 s .c om char[] codeTable = null; short[] advanceTable = null; Rect[] boundsTable = null; boolean hasLayout = false; Element glyphShapeTableElement = tagElement.element("glyphshapetable"); if (glyphShapeTableElement != null) { List glyphElements = glyphShapeTableElement.elements(); int numGlyphs = glyphElements.size(); advanceTable = new short[numGlyphs]; boundsTable = new Rect[numGlyphs]; glyphShapes = new Shape[numGlyphs]; codeTable = new char[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { Element glyphElement = (Element) glyphElements.get(i); codeTable[i] = getStringAttribute("char", glyphElement).charAt(0); glyphShapes[i] = RecordXMLReader.readShape(RecordXMLReader.getElement("shape", glyphElement)); Attribute advance = glyphElement.attribute("advance"); if (advance != null) { hasLayout = true; advanceTable[i] = Short.parseShort(advance.getValue()); boundsTable[i] = RecordXMLReader.readRect(RecordXMLReader.getElement("bounds", glyphElement)); } } } DefineFont2 defineFont2 = new DefineFont2(characterId, fontName, glyphShapes, codeTable); if (hasLayout) { Element layout = RecordXMLReader.getElement("layout", tagElement); short ascent = RecordXMLReader.getShortAttribute("ascent", layout); short descent = RecordXMLReader.getShortAttribute("descent", layout); short leading = RecordXMLReader.getShortAttribute("leading", layout); KerningRecord[] kerningTable = null; Element kerningTableElement = layout.element("kerningtable"); if (kerningTableElement != null) { List recordElements = kerningTableElement.elements(); int arrayLength = recordElements.size(); kerningTable = new KerningRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); char left = getStringAttribute("left", recordElement).charAt(0); char right = getStringAttribute("right", recordElement).charAt(0); short adjustment = RecordXMLReader.getShortAttribute("adjust", recordElement); kerningTable[i] = new KerningRecord(left, right, adjustment); } } defineFont2.setLayout(ascent, descent, leading, advanceTable, boundsTable, kerningTable); } if (RecordXMLReader.getBooleanAttribute("ansi", tagElement)) { defineFont2.setANSI(true); } if (RecordXMLReader.getBooleanAttribute("shiftjis", tagElement)) { defineFont2.setShiftJIS(true); } if (RecordXMLReader.getBooleanAttribute("bold", tagElement)) { defineFont2.setBold(true); } if (RecordXMLReader.getBooleanAttribute("italic", tagElement)) { defineFont2.setItalic(true); } if (RecordXMLReader.getBooleanAttribute("smalltext", tagElement)) { defineFont2.setSmallText(true); } defineFont2.setLanguageCode(readLangCode(tagElement)); return defineFont2; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readDefineFont3(Element tagElement) { int characterId = RecordXMLReader.getCharacterId(tagElement); String fontName = getStringAttribute("fontname", tagElement); Shape[] glyphShapes = null;/*from w w w .ja v a 2s .c om*/ char[] codeTable = null; short[] advanceTable = null; Rect[] boundsTable = null; boolean hasLayout = false; Element glyphShapeTableElement = tagElement.element("glyphshapetable"); if (glyphShapeTableElement != null) { List glyphElements = glyphShapeTableElement.elements(); int numGlyphs = glyphElements.size(); advanceTable = new short[numGlyphs]; boundsTable = new Rect[numGlyphs]; glyphShapes = new Shape[numGlyphs]; codeTable = new char[numGlyphs]; for (int i = 0; i < numGlyphs; i++) { Element glyphElement = (Element) glyphElements.get(i); codeTable[i] = getStringAttribute("char", glyphElement).charAt(0); glyphShapes[i] = RecordXMLReader.readShape(RecordXMLReader.getElement("shape", glyphElement)); Attribute advance = glyphElement.attribute("advance"); if (advance != null) { hasLayout = true; advanceTable[i] = Short.parseShort(advance.getValue()); boundsTable[i] = RecordXMLReader.readRect(RecordXMLReader.getElement("bounds", glyphElement)); } } } DefineFont3 defineFont3 = new DefineFont3(characterId, fontName, glyphShapes, codeTable); if (hasLayout) { Element layout = RecordXMLReader.getElement("layout", tagElement); short ascent = RecordXMLReader.getShortAttribute("ascent", layout); short descent = RecordXMLReader.getShortAttribute("descent", layout); short leading = RecordXMLReader.getShortAttribute("leading", layout); KerningRecord[] kerningTable = null; Element kerningTableElement = layout.element("kerningtable"); if (kerningTableElement != null) { List recordElements = kerningTableElement.elements(); int arrayLength = recordElements.size(); kerningTable = new KerningRecord[arrayLength]; for (int i = 0; i < arrayLength; i++) { Element recordElement = (Element) recordElements.get(i); char left = getStringAttribute("left", recordElement).charAt(0); char right = getStringAttribute("right", recordElement).charAt(0); short adjustment = RecordXMLReader.getShortAttribute("adjust", recordElement); kerningTable[i] = new KerningRecord(left, right, adjustment); } } defineFont3.setLayout(ascent, descent, leading, advanceTable, boundsTable, kerningTable); } if (RecordXMLReader.getBooleanAttribute("bold", tagElement)) { defineFont3.setBold(true); } if (RecordXMLReader.getBooleanAttribute("italic", tagElement)) { defineFont3.setItalic(true); } if (RecordXMLReader.getBooleanAttribute("smalltext", tagElement)) { defineFont3.setSmallText(true); } defineFont3.setLanguageCode(readLangCode(tagElement)); return defineFont3; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readEnableDebugger(Element tagElement) { Attribute password = tagElement.attribute("password"); return new EnableDebugger((password == null) ? null : password.getValue()); }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readEnableDebugger2(Element tagElement) { Attribute password = tagElement.attribute("password"); return new EnableDebugger2((password == null) ? null : password.getValue()); }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readPlaceObject2(Element tagElement) { int depth = RecordXMLReader.getIntAttribute("depth", tagElement); PlaceObject2 placeObject2 = new PlaceObject2(depth); Attribute characterId = tagElement.attribute("charid"); if (characterId != null) { placeObject2.setCharacterId(Integer.parseInt(characterId.getValue())); }/*from w w w . ja v a 2 s . co m*/ Attribute name = tagElement.attribute("name"); if (name != null) { placeObject2.setName(name.getValue()); } if (RecordXMLReader.getBooleanAttribute("move", tagElement)) { placeObject2.setMove(); } Element matrix = tagElement.element("matrix"); if (matrix != null) { placeObject2.setMatrix(RecordXMLReader.readMatrix(matrix)); } Element colorTransform = tagElement.element("cxformwithalpha"); if (colorTransform != null) { placeObject2.setColorTransform(RecordXMLReader.readCXformWithAlpha(colorTransform)); } Attribute ratio = tagElement.attribute("ratio"); if (ratio != null) { placeObject2.setRatio(Integer.parseInt(ratio.getValue())); } Attribute clipDepth = tagElement.attribute("clipdepth"); if (clipDepth != null) { placeObject2.setClipDepth(Integer.parseInt(clipDepth.getValue())); } Element clipActions = tagElement.element("clipactions"); if (clipActions != null) { placeObject2.setClipActions(RecordXMLReader.readClipActions(clipActions)); } return placeObject2; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readPlaceObject3(Element tagElement) { int depth = RecordXMLReader.getIntAttribute("depth", tagElement); PlaceObject3 placeObject3 = new PlaceObject3(depth); Attribute characterId = tagElement.attribute("charid"); if (characterId != null) { placeObject3.setCharacterId(Integer.parseInt(characterId.getValue())); }/* www. j av a 2s.com*/ Attribute name = tagElement.attribute("name"); if (name != null) { placeObject3.setName(name.getValue()); } if (RecordXMLReader.getBooleanAttribute("move", tagElement)) { placeObject3.setMove(); } Element matrix = tagElement.element("matrix"); if (matrix != null) { placeObject3.setMatrix(RecordXMLReader.readMatrix(matrix)); } Element colorTransform = tagElement.element("cxformwithalpha"); if (colorTransform != null) { placeObject3.setColorTransform(RecordXMLReader.readCXformWithAlpha(colorTransform)); } Attribute ratio = tagElement.attribute("ratio"); if (ratio != null) { placeObject3.setRatio(Integer.parseInt(ratio.getValue())); } Attribute clipDepth = tagElement.attribute("clipdepth"); if (clipDepth != null) { placeObject3.setClipDepth(Integer.parseInt(clipDepth.getValue())); } Element clipActions = tagElement.element("clipactions"); if (clipActions != null) { placeObject3.setClipActions(RecordXMLReader.readClipActions(clipActions)); } Attribute blendMode = tagElement.attribute("blendmode"); if (blendMode != null) { placeObject3.setBlendMode(BlendMode.getFromDescription(blendMode.getValue())); } placeObject3.setCacheAsBitmap(RecordXMLReader.getBooleanAttribute("cacheasbitmap", tagElement)); Element filters = tagElement.element("filters"); if (filters != null) { placeObject3.setFilters(RecordXMLReader.readFilters(filters)); } return placeObject3; }
From source file:com.jswiff.xml.TagXMLReader.java
License:Open Source License
private static Tag readProtect(Element tagElement) { Attribute password = tagElement.attribute("password"); return new Protect((password == null) ? null : password.getValue()); }
From source file:com.liferay.portal.tools.service.builder.ServiceBuilder.java
License:Open Source License
private void _parseEntity(Element entityElement) throws Exception { String ejbName = entityElement.attributeValue("name"); String humanName = entityElement.attributeValue("human-name"); String table = entityElement.attributeValue("table"); if (Validator.isNull(table)) { table = ejbName;/*from ww w . ja v a 2s . c om*/ if (_badTableNames.contains(ejbName)) { table += StringPool.UNDERLINE; } if (_autoNamespaceTables) { table = _portletShortName + StringPool.UNDERLINE + ejbName; } } boolean uuid = GetterUtil.getBoolean(entityElement.attributeValue("uuid")); boolean uuidAccessor = GetterUtil.getBoolean(entityElement.attributeValue("uuid-accessor")); boolean localService = GetterUtil.getBoolean(entityElement.attributeValue("local-service")); boolean remoteService = GetterUtil.getBoolean(entityElement.attributeValue("remote-service"), true); String persistenceClass = GetterUtil.getString(entityElement.attributeValue("persistence-class"), _packagePath + ".service.persistence.impl." + ejbName + "PersistenceImpl"); String finderClass = ""; File originalFinderImpl = new File(_outputPath + "/service/persistence/" + ejbName + "FinderImpl.java"); File newFinderImpl = new File(_outputPath + "/service/persistence/impl/" + ejbName + "FinderImpl.java"); if (originalFinderImpl.exists()) { FileUtils.moveFile(originalFinderImpl, newFinderImpl); String content = FileUtils.readFileToString(newFinderImpl); StringBundler sb = new StringBundler(); sb.append("package " + _packagePath + ".service.persistence.impl;\n\n"); sb.append("import " + _packagePath + ".service.persistence." + ejbName + "Finder;\n"); sb.append("import " + _packagePath + ".service.persistence." + ejbName + "Util;"); content = StringUtil.replace(content, "package " + _packagePath + ".service.persistence;", sb.toString()); writeFileRaw(newFinderImpl, content, _modifiedFileNames); } if (newFinderImpl.exists()) { finderClass = _packagePath + ".service.persistence.impl." + ejbName + "FinderImpl"; } String dataSource = entityElement.attributeValue("data-source"); String sessionFactory = entityElement.attributeValue("session-factory"); String txManager = entityElement.attributeValue("tx-manager"); boolean cacheEnabled = GetterUtil.getBoolean(entityElement.attributeValue("cache-enabled"), true); boolean jsonEnabled = GetterUtil.getBoolean(entityElement.attributeValue("json-enabled"), remoteService); boolean mvccEnabled = GetterUtil.getBoolean(entityElement.attributeValue("mvcc-enabled"), _mvccEnabled); boolean trashEnabled = GetterUtil.getBoolean(entityElement.attributeValue("trash-enabled")); boolean deprecated = GetterUtil.getBoolean(entityElement.attributeValue("deprecated")); boolean dynamicUpdateEnabled = GetterUtil.getBoolean(entityElement.attributeValue("dynamic-update-enabled"), mvccEnabled); List<EntityColumn> pkList = new ArrayList<>(); List<EntityColumn> regularColList = new ArrayList<>(); List<EntityColumn> blobList = new ArrayList<>(); List<EntityColumn> collectionList = new ArrayList<>(); List<EntityColumn> columnList = new ArrayList<>(); boolean permissionedModel = false; List<Element> columnElements = entityElement.elements("column"); if (uuid) { Element columnElement = DocumentHelper.createElement("column"); columnElement.addAttribute("name", "uuid"); columnElement.addAttribute("type", "String"); columnElements.add(0, columnElement); } if (mvccEnabled && !columnElements.isEmpty()) { Element columnElement = DocumentHelper.createElement("column"); columnElement.addAttribute("name", "mvccVersion"); columnElement.addAttribute("type", "long"); columnElements.add(0, columnElement); } for (Element columnElement : columnElements) { String columnName = columnElement.attributeValue("name"); if (columnName.equals("resourceBlockId") && !ejbName.equals("ResourceBlock")) { permissionedModel = true; } String columnDBName = columnElement.attributeValue("db-name"); if (Validator.isNull(columnDBName)) { columnDBName = columnName; if (_badColumnNames.contains(columnName)) { columnDBName += StringPool.UNDERLINE; } } String columnType = columnElement.attributeValue("type"); boolean primary = GetterUtil.getBoolean(columnElement.attributeValue("primary")); boolean accessor = GetterUtil.getBoolean(columnElement.attributeValue("accessor")); boolean filterPrimary = GetterUtil.getBoolean(columnElement.attributeValue("filter-primary")); String collectionEntity = columnElement.attributeValue("entity"); String mappingTable = columnElement.attributeValue("mapping-table"); if (Validator.isNotNull(mappingTable)) { if (_badTableNames.contains(mappingTable)) { mappingTable += StringPool.UNDERLINE; } if (_autoNamespaceTables) { mappingTable = _portletShortName + StringPool.UNDERLINE + mappingTable; } } String idType = columnElement.attributeValue("id-type"); String idParam = columnElement.attributeValue("id-param"); boolean convertNull = GetterUtil.getBoolean(columnElement.attributeValue("convert-null"), true); boolean lazy = GetterUtil.getBoolean(columnElement.attributeValue("lazy"), true); boolean localized = GetterUtil.getBoolean(columnElement.attributeValue("localized")); boolean colJsonEnabled = GetterUtil.getBoolean(columnElement.attributeValue("json-enabled"), jsonEnabled); boolean containerModel = GetterUtil.getBoolean(columnElement.attributeValue("container-model")); boolean parentContainerModel = GetterUtil .getBoolean(columnElement.attributeValue("parent-container-model")); EntityColumn col = new EntityColumn(columnName, columnDBName, columnType, primary, accessor, filterPrimary, collectionEntity, mappingTable, idType, idParam, convertNull, lazy, localized, colJsonEnabled, containerModel, parentContainerModel); if (primary) { pkList.add(col); } if (columnType.equals("Collection")) { collectionList.add(col); } else { regularColList.add(col); if (columnType.equals("Blob")) { blobList.add(col); } } columnList.add(col); if (Validator.isNotNull(collectionEntity) && Validator.isNotNull(mappingTable)) { EntityMapping entityMapping = new EntityMapping(mappingTable, ejbName, collectionEntity); if (!_entityMappings.containsKey(mappingTable)) { _entityMappings.put(mappingTable, entityMapping); } } } EntityOrder order = null; Element orderElement = entityElement.element("order"); if (orderElement != null) { boolean asc = true; if ((orderElement.attribute("by") != null) && orderElement.attributeValue("by").equals("desc")) { asc = false; } List<EntityColumn> orderColsList = new ArrayList<>(); order = new EntityOrder(asc, orderColsList); List<Element> orderColumnElements = orderElement.elements("order-column"); for (Element orderColElement : orderColumnElements) { String orderColName = orderColElement.attributeValue("name"); boolean orderColCaseSensitive = GetterUtil .getBoolean(orderColElement.attributeValue("case-sensitive"), true); boolean orderColByAscending = asc; String orderColBy = GetterUtil.getString(orderColElement.attributeValue("order-by")); if (orderColBy.equals("asc")) { orderColByAscending = true; } else if (orderColBy.equals("desc")) { orderColByAscending = false; } EntityColumn col = Entity.getColumn(orderColName, columnList); col.setOrderColumn(true); col = (EntityColumn) col.clone(); col.setCaseSensitive(orderColCaseSensitive); col.setOrderByAscending(orderColByAscending); orderColsList.add(col); } } List<EntityFinder> finderList = new ArrayList<>(); List<Element> finderElements = entityElement.elements("finder"); if (uuid) { if (columnList.contains(new EntityColumn("companyId"))) { Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "Uuid_C"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "companyId"); finderElements.add(0, finderElement); } if (columnList.contains(new EntityColumn("groupId"))) { Element finderElement = DocumentHelper.createElement("finder"); if (ejbName.equals("Layout")) { finderElement.addAttribute("name", "UUID_G_P"); } else { finderElement.addAttribute("name", "UUID_G"); } finderElement.addAttribute("return-type", ejbName); finderElement.addAttribute("unique", "true"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "groupId"); if (ejbName.equals("Layout")) { finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "privateLayout"); } finderElements.add(0, finderElement); } Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "Uuid"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "uuid"); finderElements.add(0, finderElement); } if (permissionedModel) { Element finderElement = DocumentHelper.createElement("finder"); finderElement.addAttribute("name", "ResourceBlockId"); finderElement.addAttribute("return-type", "Collection"); Element finderColumnElement = finderElement.addElement("finder-column"); finderColumnElement.addAttribute("name", "resourceBlockId"); finderElements.add(0, finderElement); } String alias = TextFormatter.format(ejbName, TextFormatter.I); if (_badAliasNames.contains(StringUtil.toLowerCase(alias))) { alias += StringPool.UNDERLINE; } for (Element finderElement : finderElements) { String finderName = finderElement.attributeValue("name"); String finderReturn = finderElement.attributeValue("return-type"); boolean finderUnique = GetterUtil.getBoolean(finderElement.attributeValue("unique")); String finderWhere = finderElement.attributeValue("where"); if (Validator.isNotNull(finderWhere)) { for (EntityColumn column : columnList) { String name = column.getName(); finderWhere = StringUtil.replace(finderWhere, name, alias + "." + name); } } boolean finderDBIndex = GetterUtil.getBoolean(finderElement.attributeValue("db-index"), true); List<EntityColumn> finderColsList = new ArrayList<>(); List<Element> finderColumnElements = finderElement.elements("finder-column"); for (Element finderColumnElement : finderColumnElements) { String finderColName = finderColumnElement.attributeValue("name"); boolean finderColCaseSensitive = GetterUtil .getBoolean(finderColumnElement.attributeValue("case-sensitive"), true); String finderColComparator = GetterUtil.getString(finderColumnElement.attributeValue("comparator"), "="); String finderColArrayableOperator = GetterUtil .getString(finderColumnElement.attributeValue("arrayable-operator")); EntityColumn col = Entity.getColumn(finderColName, columnList); if (!col.isFinderPath()) { col.setFinderPath(true); } col = (EntityColumn) col.clone(); col.setCaseSensitive(finderColCaseSensitive); col.setComparator(finderColComparator); col.setArrayableOperator(finderColArrayableOperator); col.validate(); finderColsList.add(col); } finderList.add(new EntityFinder(finderName, finderReturn, finderUnique, finderWhere, finderDBIndex, finderColsList)); } List<Entity> referenceList = new ArrayList<>(); List<String> unresolvedReferenceList = new ArrayList<>(); if (_build) { List<Element> referenceElements = entityElement.elements("reference"); Set<String> referenceSet = new TreeSet<>(); for (Element referenceElement : referenceElements) { String referencePackage = referenceElement.attributeValue("package-path"); String referenceEntity = referenceElement.attributeValue("entity"); referenceSet.add(referencePackage + "." + referenceEntity); } if (!_packagePath.equals("com.liferay.counter")) { referenceSet.add("com.liferay.counter.Counter"); } if (_autoImportDefaultReferences) { referenceSet.add("com.liferay.portal.ClassName"); referenceSet.add("com.liferay.portal.Resource"); referenceSet.add("com.liferay.portal.User"); } for (String referenceName : referenceSet) { try { referenceList.add(getEntity(referenceName)); } catch (RuntimeException re) { unresolvedReferenceList.add(referenceName); } } } List<String> txRequiredList = new ArrayList<>(); List<Element> txRequiredElements = entityElement.elements("tx-required"); for (Element txRequiredEl : txRequiredElements) { String txRequired = txRequiredEl.getText(); txRequiredList.add(txRequired); } boolean resourceActionModel = _resourceActionModels.contains(_packagePath + ".model." + ejbName); _ejbList.add(new Entity(_packagePath, _portletName, _portletShortName, ejbName, humanName, table, alias, uuid, uuidAccessor, localService, remoteService, persistenceClass, finderClass, dataSource, sessionFactory, txManager, cacheEnabled, dynamicUpdateEnabled, jsonEnabled, mvccEnabled, trashEnabled, deprecated, pkList, regularColList, blobList, collectionList, columnList, order, finderList, referenceList, unresolvedReferenceList, txRequiredList, resourceActionModel)); }
From source file:com.lingxiang2014.util.SettingUtils.java
License:Open Source License
public static void set(Setting setting) { try {//from w ww. j a v a2 s.c o m File shopxxXmlFile = new ClassPathResource(CommonAttributes.SHOPXX_XML_PATH).getFile(); Document document = new SAXReader().read(shopxxXmlFile); List<Element> elements = document.selectNodes("/shopxx/setting"); for (Element element : elements) { try { String name = element.attributeValue("name"); String value = beanUtils.getProperty(setting, name); Attribute attribute = element.attribute("value"); attribute.setValue(value); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } } FileOutputStream fileOutputStream = null; XMLWriter xmlWriter = null; try { OutputFormat outputFormat = OutputFormat.createPrettyPrint(); outputFormat.setEncoding("UTF-8"); outputFormat.setIndent(true); outputFormat.setIndent(" "); outputFormat.setNewlines(true); fileOutputStream = new FileOutputStream(shopxxXmlFile); xmlWriter = new XMLWriter(fileOutputStream, outputFormat); xmlWriter.write(document); } catch (Exception e) { e.printStackTrace(); } finally { if (xmlWriter != null) { try { xmlWriter.close(); } catch (IOException e) { } } IOUtils.closeQuietly(fileOutputStream); } Ehcache cache = cacheManager.getEhcache(Setting.CACHE_NAME); cache.put(new net.sf.ehcache.Element(Setting.CACHE_KEY, setting)); } catch (Exception e) { e.printStackTrace(); } }