protected void testCopy(Element element) throws Exception { assertTrue("Not null", element != null); int attributeCount = element.attributeCount(); int nodeCount = element.nodeCount(); Element copy = element.createCopy(); assertEquals("Node size not equal after copy", element.nodeCount(), nodeCount); assertTrue("Same attribute size after copy", element.attributeCount() == attributeCount); assertTrue("Copy has same node size", copy.nodeCount() == nodeCount); assertTrue("Copy has same attribute size", copy.attributeCount() == attributeCount); for (int i = 0; i < attributeCount; i++) { Attribute attr1 = element.attribute(i); Attribute attr2 = copy.attribute(i); assertTrue("Attribute: " + i + " name is equal", attr1.getName().equals(attr2.getName())); assertTrue("Attribute: " + i + " value is equal", attr1.getValue().equals(attr2.getValue())); } for (int i = 0; i < nodeCount; i++) { Node node1 = element.node(i); Node node2 = copy.node(i); assertTrue("Node: " + i + " type is equal", node1.getNodeType() == node2.getNodeType()); assertTrue("Node: " + i + " value is equal", node1.getText().equals(node2.getText())); } }
public static List<List<String>> attributeValuesInSets( List<String> urlList, List<String> attributeNames) throws MalformedURLException { List<List<String>> allAttributes = new ArrayList<List<String>>(); Attribute p = null; String key = null; int index = -1; for (int j = 0; j < attributeNames.size(); j++) { allAttributes.add(new ArrayList<String>()); // Add empty value to each list allAttributes.get(j).add(""); } for (int i = 0; i < urlList.size(); i++) { // System.out.println(urlList.get(i)); // allAttributes.add(new ArrayList<String>()); List<Attribute> attributeList = getQueryAttributes(urlList.get(i)); for (int j = 0; j < attributeList.size(); j++) { p = attributeList.get(j); key = p.getName(); index = attributeNames.indexOf(key); if (p.getValue() != null && p.getValue().trim().length() > 0) if (index != -1) if (allAttributes.get(index).indexOf(p.getValue().trim()) == -1) allAttributes.get(index).add(p.getValue().trim()); } } return allAttributes; }
/** * Add an attribute to the section * * @param attribute the attribute to be added. * @return the value of the attribute if it is a name attribute - null other wise * @throws ManifestException if the attribute already exists in this section. */ public String addAttributeAndCheck(Attribute attribute) throws ManifestException { if (attribute.getName() == null || attribute.getValue() == null) { throw new ManifestException("Attributes must have name and value"); } if (attribute.getKey().equalsIgnoreCase(ATTRIBUTE_NAME)) { warnings.addElement( "\"" + ATTRIBUTE_NAME + "\" attributes " + "should not occur in the main section and must be the " + "first element in all other sections: \"" + attribute.getName() + ": " + attribute.getValue() + "\""); return attribute.getValue(); } if (attribute.getKey().startsWith(ATTRIBUTE_FROM.toLowerCase())) { warnings.addElement( "Manifest attributes should not start " + "with \"" + ATTRIBUTE_FROM + "\" in \"" + attribute.getName() + ": " + attribute.getValue() + "\""); } else { // classpath attributes go into a vector String attributeKey = attribute.getKey(); if (attributeKey.equalsIgnoreCase(ATTRIBUTE_CLASSPATH)) { Attribute classpathAttribute = (Attribute) attributes.get(attributeKey); if (classpathAttribute == null) { storeAttribute(attribute); } else { warnings.addElement( "Multiple Class-Path attributes " + "are supported but violate the Jar " + "specification and may not be correctly " + "processed in all environments"); Enumeration e = attribute.getValues(); while (e.hasMoreElements()) { String value = (String) e.nextElement(); classpathAttribute.addValue(value); } } } else if (attributes.containsKey(attributeKey)) { throw new ManifestException( "The attribute \"" + attribute.getName() + "\" may not occur more " + "than once in the same section"); } else { storeAttribute(attribute); } } return null; }
@Test public void testAtt() { String nsUri = "nsUri"; String prefix = "prefix"; String localName = "localName"; String value = "value"; Attribute att = new Attribute(nsUri, localName, value); Assert.assertEquals(nsUri, att.getNamespace()); Assert.assertEquals(localName, att.getName()); Assert.assertEquals(value, att.getValue()); String nsUri2 = "nsUri2"; String prefix2 = "prefix2"; String localName2 = "localName2"; String value2 = "value2"; att.setNsURI(nsUri2); att.setName(localName2); att.setValue(value2); Assert.assertEquals(nsUri2, att.getNamespace()); Assert.assertEquals(localName2, att.getName()); Assert.assertEquals(value2, att.getValue()); }
public static List<TradingPriceTracking> getPriceTrackingItem(String res, String title) throws Exception { List<TradingPriceTracking> list = new ArrayList<TradingPriceTracking>(); Document document = formatStr2Doc(res); Element rootElt = document.getRootElement(); Element searchResult = rootElt.element("searchResult"); Iterator items = searchResult.elementIterator("item"); while (items.hasNext()) { TradingPriceTracking priceTracking = new TradingPriceTracking(); Element item = (Element) items.next(); priceTracking.setItemid(SamplePaseXml.getSpecifyElementText(item, "itemId")); priceTracking.setCategoryid( SamplePaseXml.getSpecifyElementText(item, "primaryCategory", "categoryId")); priceTracking.setCategoryname( SamplePaseXml.getSpecifyElementText(item, "primaryCategory", "categoryName")); priceTracking.setCurrentprice( SamplePaseXml.getSpecifyElementText(item, "sellingStatus", "currentPrice")); priceTracking.setSellerusername( SamplePaseXml.getSpecifyElementText(item, "sellerInfo", "sellerUserName")); priceTracking.setTitle(SamplePaseXml.getSpecifyElementText(item, "title")); priceTracking.setBidcount( SamplePaseXml.getSpecifyElementText(item, "sellingStatus", "bidCount")); priceTracking.setPictureurl(SamplePaseXml.getSpecifyElementText(item, "galleryURL")); String starttime = SamplePaseXml.getSpecifyElementText(item, "listingInfo", "startTime"); String endtime = SamplePaseXml.getSpecifyElementText(item, "listingInfo", "endTime"); if (StringUtils.isNotBlank(starttime)) { priceTracking.setStarttime(DateUtils.returnDate(starttime)); } if (StringUtils.isNotBlank(endtime)) { priceTracking.setEndtime(DateUtils.returnDate(endtime)); } Element sellingStatus = item.element("sellingStatus"); String currencyId1 = ""; if (sellingStatus != null) { Element currentPrice = sellingStatus.element("currentPrice"); if (currentPrice != null) { Attribute currencyId = currentPrice.attribute("currencyId"); if (currencyId != null) { currencyId1 = currencyId.getValue(); } } } priceTracking.setCurrencyid(currencyId1); Element shippingInfo = item.element("shippingInfo"); if (shippingInfo != null) { Element shippingServiceCost = shippingInfo.element("shippingServiceCost"); if (shippingServiceCost != null) { Attribute shippingcurrencyId = shippingServiceCost.attribute("currencyId"); if (shippingcurrencyId != null) { priceTracking.setShippingcurrencyid(shippingcurrencyId.getValue()); } priceTracking.setShippingservicecost(shippingServiceCost.getTextTrim()); } } priceTracking.setQuerytitle(title); list.add(priceTracking); } return list; }
public void extend(TemplateDocument doc, FragmentList f, boolean normalize) throws BehaviorInstantiationException { ParentNode extended; if (extendedTag == null) { extended = extendedDocument; } else { extended = extendedTag; } ArrayList<TemplateNode> children = doc.getChildren(); for (TemplateNode node : children) { if (node instanceof Tag) { Tag tag = (Tag) node; Tag overriden = null; Attribute overrides = tag.getDynamicAttribute( new DynamicAttributeKey(Cambridge.DefaultNamespaceURI, "a", "overrides")); if (overrides != null) { overriden = extendedDocument.locateTag(overrides.getValue()); } else { Attribute id = tag.getAttribute("id"); if (id == null && tag.isDynamic()) { id = tag.getAttribute(tag.getNameSpace(), "id"); } if (id != null) { overriden = extended.getElementById(id.getValue()); } } if (overriden != null) { overriden.getParent().replaceChild((TemplateNode) overriden, (TemplateNode) tag); } } else if (node instanceof SetDirective) { int index = 0; if (extended == extendedDocument && extendedDocument.getChildren().size() > 0 && extendedDocument.getChildren().get(0) instanceof ExtendsDirective) { index = 1; } extended.insertChild(index, node); } } if (extendedDocument.getChildren().size() > 0 && extendedDocument.getChildren().get(0) instanceof ExtendsDirective) { ((ExtendsDirective) extendedDocument.getChildren().get(0)).extend(extendedDocument, f, false); } if (normalize) { if (extendedTag != null) { extendedTag.normalize(extendedDocument, f); } else { f.addAll(extendedDocument.normalize()); } } }
/** * Add an attribute to the manifest - it is added to the main section. * * @param attribute the attribute to be added. * @throws ManifestException if the attribute is not valid. */ public void addConfiguredAttribute(Attribute attribute) throws ManifestException { if (attribute.getKey() == null || attribute.getValue() == null) { throw new ManifestException("Attributes must have name and value"); } if (attribute.getKey().equalsIgnoreCase(ATTRIBUTE_MANIFEST_VERSION)) { manifestVersion = attribute.getValue(); } else { mainSection.addConfiguredAttribute(attribute); } }
/** * Render the given Item as XML using an XMLStreamWriter * * @param writer to XMLStreamWriter to write to * @param item the Item to render */ public static void renderImpl(XMLStreamWriter writer, Item item) { try { writer.writeStartElement("item"); if (item.getIdentifier() != null) { writer.writeAttribute("id", item.getIdentifier()); } writer.writeAttribute("class", item.getClassName() == null ? "" : item.getClassName()); if (item.getImplementations() != null && !"".equals(item.getImplementations())) { writer.writeAttribute("implements", item.getImplementations()); } writer.writeCharacters(ENDL); TreeSet<Attribute> attrs = new TreeSet<Attribute>(new RendererComparator()); attrs.addAll(item.getAttributes()); for (Attribute attr : attrs) { if (!"".equals(attr.getValue())) { writer.writeEmptyElement("attribute"); writer.writeAttribute("name", attr.getName()); writer.writeAttribute("value", attr.getValue()); writer.writeCharacters(ENDL); } } TreeSet<Reference> refs = new TreeSet<Reference>(new RendererComparator()); refs.addAll(item.getReferences()); for (Reference ref : refs) { writer.writeEmptyElement("reference"); writer.writeAttribute("name", ref.getName()); writer.writeAttribute("ref_id", ref.getRefId()); writer.writeCharacters(ENDL); } TreeSet<ReferenceList> cols = new TreeSet<ReferenceList>(new RendererComparator()); cols.addAll(item.getCollections()); for (ReferenceList refList : cols) { writer.writeStartElement("collection"); writer.writeAttribute("name", refList.getName()); for (String ref : refList.getRefIds()) { writer.writeEmptyElement("reference"); writer.writeAttribute("ref_id", ref); } writer.writeEndElement(); writer.writeCharacters(ENDL); } writer.writeEndElement(); writer.writeCharacters(ENDL); } catch (XMLStreamException e) { throw new RuntimeException("unexpected exception while accessing a XMLStreamWriter", e); } }
/** * Computes the difference between two attributes using the given distance metric. This function * takes care of things like dynamic attributes and null values. This one allows reclamation of a * difference object. * * @param alpha the target attribute * @param alphaSpan the target attribute's span * @param beta the candidate attribute * @param betaSpan the candidate attribute's framespan * @param blackout the blackout data * @param blackoutSpan when the blackout is defined * @param ignore the don't-care data * @param ignoreSpan the don't-care framespan * @param frame the frame to compare * @param cfd information about the media * @param old cached difference object * @return the new difference object, or the same one, changed * @throws IgnoredValueException if the whole of the data on the frame was ignored */ public static Measurable.Difference helpGetDiff( Attribute alpha, FrameSpan alphaSpan, Attribute beta, FrameSpan betaSpan, Attribute blackout, FrameSpan blackoutSpan, Attribute ignore, FrameSpan ignoreSpan, int frame, CanonicalFileDescriptor cfd, Measurable.Difference old) throws IgnoredValueException { if (alpha == null || alpha.getValue(alphaSpan, frame) == null) { return new Distances.DefaultDifference( null, (beta != null) ? beta.getValue(betaSpan, frame) : null, (blackout != null) ? blackout.getValue(blackoutSpan, frame) : null, (ignore != null) ? ignore.getValue(ignoreSpan, frame) : null, cfd); } else { Measurable a = alpha.getValue(alphaSpan, frame); return a.getDifference( (beta != null) ? beta.getValue(betaSpan, frame) : null, (blackout != null) ? blackout.getValue(blackoutSpan, frame) : null, (ignore != null) ? ignore.getValue(ignoreSpan, frame) : null, cfd, old); } }
/** * Get the value of the attribute with the name given. * * @param attributeName the name of the attribute to be returned. * @return the attribute's value or null if the attribute does not exist in the section */ public String getAttributeValue(String attributeName) { Attribute attribute = getAttribute(attributeName.toLowerCase()); if (attribute == null) { return null; } return attribute.getValue(); }
@Override public boolean onHttpRequestSend(HttpMessage message) { if (isActive() && SAMLUtils.hasSAMLMessage(message)) { try { SAMLMessage samlMessage = new SAMLMessage(message); // change the params for (Attribute attribute : configuration.getAutoChangeAttributes()) { String value = attribute.getValue().toString(); boolean changed = samlMessage.changeAttributeValueTo(attribute.getName(), value); if (changed) { log.debug(attribute.getName() + ": value changed to " + value); } } // change the original message HttpMessage changedMessege = samlMessage.getChangedMessage(); if (changedMessege != message) { // check for reference, if they are same the message is already changed, // else the header and body are changed message.setRequestBody(changedMessege.getRequestBody()); message.setRequestHeader(changedMessege.getRequestHeader()); } } catch (SAMLException ignored) { } } return true; }
/** * This will invoke the <code>startElement</code> callback in the <code>ContentHandler</code>. * * @param element <code>Element</code> used in callbacks. * @param nsAtts <code>List</code> of namespaces to declare with the element or <code>null</code>. */ private void startElement(Element element, Attributes nsAtts) throws JDOMException { String namespaceURI = element.getNamespaceURI(); String localName = element.getName(); String rawName = element.getQualifiedName(); // Allocate attribute list. AttributesImpl atts = (nsAtts != null) ? new AttributesImpl(nsAtts) : new AttributesImpl(); List attributes = element.getAttributes(); Iterator i = attributes.iterator(); while (i.hasNext()) { Attribute a = (Attribute) i.next(); atts.addAttribute( a.getNamespaceURI(), a.getName(), a.getQualifiedName(), getAttributeTypeName(a.getAttributeType()), a.getValue()); } try { contentHandler.startElement(namespaceURI, localName, rawName, atts); } catch (SAXException se) { throw new JDOMException("Exception in startElement", se); } }
/** * Read the numeric format string out of the styles table for this cell. Stores the result in the * Cell. * * @param startElement * @param cell */ void setFormatString(StartElement startElement, StreamingCell cell) { Attribute cellStyle = startElement.getAttributeByName(new QName("s")); String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null; XSSFCellStyle style = null; if (cellStyleString != null) { style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString)); } else if (stylesTable.getNumCellStyles() > 0) { style = stylesTable.getStyleAt(0); } if (style != null) { cell.setNumericFormatIndex(style.getDataFormat()); String formatString = style.getDataFormatString(); if (formatString != null) { cell.setNumericFormat(formatString); } else { cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex())); } } else { cell.setNumericFormatIndex(null); cell.setNumericFormat(null); } }
// 解析价格跟踪 public static List<TradingPriceTracking> getPriceTrackingItemByItemId(String res) throws Exception { List<TradingPriceTracking> priceTrackings = new ArrayList<TradingPriceTracking>(); Document document = formatStr2Doc(res); Element rootElt = document.getRootElement(); Iterator items = rootElt.elementIterator("Item"); while (items.hasNext()) { TradingPriceTracking priceTracking = new TradingPriceTracking(); Element item = (Element) items.next(); priceTracking.setItemid(SamplePaseXml.getSpecifyElementText(item, "ItemID")); priceTracking.setTitle(SamplePaseXml.getSpecifyElementText(item, "Title")); priceTracking.setCurrentprice( SamplePaseXml.getSpecifyElementText(item, "ConvertedCurrentPrice")); priceTracking.setBidcount(SamplePaseXml.getSpecifyElementText(item, "BidCount")); Element ConvertedCurrentPrice = item.element("ConvertedCurrentPrice"); String endtime = SamplePaseXml.getSpecifyElementText(item, "EndTime"); if (StringUtils.isNotBlank(endtime)) { priceTracking.setEndtime(DateUtils.returnDate(endtime)); } String currencyId1 = ""; if (ConvertedCurrentPrice != null) { Attribute currencyId = ConvertedCurrentPrice.attribute("currencyId"); if (currencyId != null) { currencyId1 = currencyId.getValue(); } } priceTracking.setCurrencyid(currencyId1); priceTrackings.add(priceTracking); } return priceTrackings; }
public static boolean isAnywhere(Rule r) { if (null == r.getAttributes()) return false; for (Attribute any : anywheres) { if (any.getValue() == r.getAttribute(any.getKey())) return true; } return false; }
/** * Get an attribute value by key. * * @param key the attribute key * @return the attribute value if set; or empty string if not set. * @see #hasKey(String) */ public String get(String key) { Validate.notEmpty(key); if (attributes == null) return ""; Attribute attr = attributes.get(key); return attr != null ? attr.getValue() : ""; }
public String get(String key) { Validate.notEmpty(key); if (this.attributes == null) { return UnsupportedUrlFragment.DISPLAY_NAME; } Attribute attr = (Attribute) this.attributes.get(key.toLowerCase()); return attr != null ? attr.getValue() : UnsupportedUrlFragment.DISPLAY_NAME; }
private String getAttributeValue(List<Attribute> attributes, String name) { for (Attribute attribute : attributes) { if (attribute.getName().equals(name)) { return attribute.getValue(); } } return null; }
public String getAttribute(String attributeName) { for (Attribute a : attributes) { if (attributeName.equalsIgnoreCase(a.getName())) { return a.getValue(); } } return null; }
/** Convert the attributes in the given XML Element into a Map of name/value pairs. */ protected static Map createAttributeMap(Element el) { Log.debug("Creating attribute map for " + el); Map attributes = new HashMap(); Iterator iter = el.getAttributes().iterator(); while (iter.hasNext()) { Attribute att = (Attribute) iter.next(); attributes.put(att.getName(), att.getValue()); } return attributes; }
/** * Returns the value of an attribute on the outline or null. * * @param name name of the attribute. */ public String getAttributeValue(final String name) { final List<Attribute> attributes = Collections.synchronizedList(getAttributes()); for (int i = 0; i < attributes.size(); i++) { final Attribute a = attributes.get(i); if (a.getName() != null && a.getName().equals(name)) { return a.getValue(); } } return null; }
/* ------------------------------------------------------------ */ public void setAttribute(Attribute attr) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { if (attr == null) return; if (log.isDebugEnabled()) log.debug("setAttribute " + attr.getName() + "=" + attr.getValue()); Method setter = (Method) _setter.get(attr.getName()); if (setter == null) throw new AttributeNotFoundException(attr.getName()); try { Object o = _object; if (setter.getDeclaringClass().isInstance(this)) o = this; setter.invoke(o, new Object[] {attr.getValue()}); } catch (IllegalAccessException e) { log.warn(LogSupport.EXCEPTION, e); throw new AttributeNotFoundException(e.toString()); } catch (InvocationTargetException e) { log.warn(LogSupport.EXCEPTION, e); throw new ReflectionException((Exception) e.getTargetException()); } }
/** * Clone this section * * @return the cloned Section * @since Ant 1.5.2 */ public Object clone() { Section cloned = new Section(); cloned.setName(name); Enumeration e = getAttributeKeys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); Attribute attribute = getAttribute(key); cloned.storeAttribute(new Attribute(attribute.getName(), attribute.getValue())); } return cloned; }
/** * Gets the selected node in the tags tree and applies all attributes fro the attributes list to * it. Do nothing if no node is selected. */ public void apply() { JTree tree = (JTree) document.getTagById("tagsTree").getComponent(); if (tree.getSelectionPath() != null) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) tree.getSelectionPath().getLastPathComponent(); Tag tag = (Tag) node.getUserObject(); for (Attribute attr : attributes) { tag.setAttribute(attr.getName(), attr.getValue()); } tag.applyAttributes(tag.getComponent()); } }
public String getTree() { String str = "<" + name; if (attributes != null) { for (Attribute attribute : attributes) { str += " " + attribute.getName() + " = \"" + attribute.getValue() + "\" "; } } str += ">"; str += value + "</" + name + ">\n"; return str; }
/** Marshall the given parameter object, and output to a SdkJsonGenerator */ public void marshall(Attribute attribute, StructuredJsonGenerator jsonGenerator) { if (attribute == null) { throw new AmazonClientException("Invalid argument passed to marshall(...)"); } try { jsonGenerator.writeStartObject(); if (attribute.getName() != null) { jsonGenerator.writeFieldName("name").writeValue(attribute.getName()); } if (attribute.getValue() != null) { jsonGenerator.writeFieldName("value").writeValue(attribute.getValue()); } jsonGenerator.writeEndObject(); } catch (Throwable t) { throw new AmazonClientException("Unable to marshall request to JSON: " + t.getMessage(), t); } }
private Uid doUpdate() throws IOException, JSchException { if (uid == null || StringUtil.isBlank(uid.getUidValue())) { throw new IllegalArgumentException("No Uid attribute provided in the attributes"); } LOG.info("Update user: "******"Wrong object class"); } if (objectClass.equals(ObjectClass.ACCOUNT)) { if (!EvaluateCommandsResultOutput.evaluateUserOrGroupExists( unixConnection.execute( UnixConnector.getCommandGenerator().userExists(uid.getUidValue())))) { throw new ConnectorException("User " + uid + " do not exists"); } for (Attribute attr : attrs) { if (attr.is(Name.NAME) || attr.is(Uid.NAME)) { newUserName = (String) attr.getValue().get(0); } else if (attr.is(OperationalAttributes.PASSWORD_NAME)) { password = Utilities.getPlainPassword((GuardedString) attr.getValue().get(0)); } else if (attr.is(OperationalAttributes.ENABLE_NAME)) { status = Boolean.parseBoolean(attr.getValue().get(0).toString()); } else if (attr.is(configuration.getCommentAttribute())) { comment = attr.getValue().get(0).toString(); } else if (attr.is(configuration.getShellAttribute())) { shell = (String) attr.getValue().get(0).toString(); } else if (attr.is(configuration.getHomeDirectoryAttribute())) { homeDirectory = (String) attr.getValue().get(0).toString(); } } unixConnection.execute( UnixConnector.getCommandGenerator() .updateUser( uid.getUidValue(), newUserName, password, status, comment, shell, homeDirectory)); // unixConnection.execute("mv /home/" + uid.getUidValue() + " /home/" + // newUserName); unixConnection.execute( UnixConnector.getCommandGenerator().moveHomeDirectory(uid.getUidValue(), newUserName)); if (!status) { unixConnection.execute(UnixConnector.getCommandGenerator().lockUser(uid.getUidValue())); } else { unixConnection.execute(UnixConnector.getCommandGenerator().unlockUser(uid.getUidValue())); } if (StringUtil.isNotBlank(newUserName) && StringUtil.isNotEmpty(newUserName)) { unixConnection.execute( UnixConnector.getCommandGenerator().updateGroup(uid.getUidValue(), newUserName)); } } else if (objectClass.equals(ObjectClass.GROUP)) { if (!EvaluateCommandsResultOutput.evaluateUserOrGroupExists( unixConnection.execute(UnixConnector.getCommandGenerator().groupExists(newUserName)))) { throw new ConnectorException("Group do not exists"); } unixConnection.execute( UnixConnector.getCommandGenerator().updateGroup(uid.getUidValue(), newUserName)); } return uid; }
public void readDOMElement(Element element) { String label = element.getAttribute("name").getValue(); m_name = label; Attribute idelement = element.getAttribute("id"); if (idelement != null) { setId(idelement.getValue()); } Element datasetselements = (Element) element.getChild(IDataSets.class.getName()); readDOMDataElement(datasetselements, getDataSets()); Element exportselements = (Element) element.getChild(IExportItem.class.getName()); if (exportselements != null) {} }
/** @inheritDoc */ public Number getDistance( Attribute alpha, FrameSpan alphaSpan, Attribute beta, FrameSpan betaSpan, int frame, CanonicalFileDescriptor cfd) { Object a = alpha.getValue(alphaSpan, frame); Object b = beta.getValue(betaSpan, frame); if (a == null || b == null) { return a == b ? new Integer(0) : new Integer(1); } else if ((a instanceof Object[]) && (b instanceof Object[])) { return Arrays.equals((Object[]) a, (Object[]) b) ? new Integer(0) : new Integer(1); } else if ((a instanceof int[]) && (b instanceof int[])) { return Arrays.equals((int[]) a, (int[]) b) ? new Integer(0) : new Integer(1); } else if ((a instanceof double[]) && (b instanceof double[])) { return Arrays.equals((double[]) a, (double[]) b) ? new Integer(0) : new Integer(1); } else if ((a instanceof boolean[]) && (b instanceof boolean[])) { return Arrays.equals((boolean[]) a, (boolean[]) b) ? new Integer(0) : new Integer(1); } else { return a.equals(b) ? new Integer(0) : new Integer(1); } }
@Override public void checkAttributeValue( PerunSessionImpl perunSession, Facility facility, Attribute attribute) throws InternalErrorException, WrongAttributeValueException, WrongReferenceAttributeValueException, WrongAttributeAssignmentException { if (attribute.getValue() == null) { throw new WrongAttributeValueException(attribute, facility, "attribute is null"); } String value = (String) attribute.getValue(); if (value.length() < 3) { throw new WrongAttributeValueException( attribute, facility, "attribute has to start with \"ou=\" or \"dc=\""); } String sub = value.substring(0, 3); if (!(sub.equalsIgnoreCase("ou=") || sub.equalsIgnoreCase("dc="))) { throw new WrongAttributeValueException( attribute, facility, "attribute has to start with \"ou=\" or \"dc=\""); } }