public static String saxElementToDebugString(String uri, String qName, Attributes attributes) { // Open start tag final StringBuilder sb = new StringBuilder("<"); sb.append(qName); final Set<String> declaredPrefixes = new HashSet<String>(); mapPrefixIfNeeded(declaredPrefixes, uri, qName, sb); // Attributes if any for (int i = 0; i < attributes.getLength(); i++) { mapPrefixIfNeeded(declaredPrefixes, attributes.getURI(i), attributes.getQName(i), sb); sb.append(' '); sb.append(attributes.getQName(i)); sb.append("=\""); sb.append(attributes.getValue(i)); sb.append('\"'); } // Close start tag sb.append('>'); // Content sb.append("[...]"); // Close element with end tag sb.append("</"); sb.append(qName); sb.append('>'); return sb.toString(); }
/** * Read the version information from a file with a given file name. The file must be a jar * manifest file and all its entries are searched for package names and their specification * version information. All information is collected in a map for later lookup of package names * and their versions. * * @param versionFileName name of the jar file containing version information */ public static String readVersionFromFile(String applicationName, String versionFileName) { try { FileInputStream fileInput = new FileInputStream(versionFileName); Manifest manifest = new Manifest(); manifest.read(fileInput); Map entries = manifest.getEntries(); // Now write out the pre-entry attributes Iterator entryIterator = entries.entrySet().iterator(); while (entryIterator.hasNext()) { Map.Entry currentEntry = (Map.Entry) entryIterator.next(); String packageName = currentEntry.getKey().toString(); packageName = normalizePackageName(packageName); Attributes attributes = (Attributes) currentEntry.getValue(); String packageSpecVersion = attributes.getValue(Attributes.Name.SPECIFICATION_VERSION); packageSpecVersion = extractVersionInfo(packageSpecVersion); return packageSpecVersion; } } catch (IOException exception) { exception.printStackTrace(); } // no version found return null; }
/** Creates the total selector's set for get all the possible rules */ private Complejo hazSelectores(Dataset train) { Complejo almacenSelectores; int nClases = train.getnclases(); almacenSelectores = new Complejo(nClases); // Aqui voy a almacenar los selectores (numVariable,operador,valor) Attribute[] atributos = null; int num_atributos, type; Vector nominalValues; atributos = Attributes.getAttributes(); num_atributos = Attributes.getNumAttributes(); Selector s; for (int i = 0; i < train.getnentradas(); i++) { type = atributos[i].getType(); switch (type) { case 0: // NOMINAL nominalValues = atributos[i].getNominalValuesList(); // System.out.print("{"); for (int j = 0; j < nominalValues.size(); j++) { // System.out.print ((String)nominalValues.elementAt(j)+" "); s = new Selector(i, 0, (String) nominalValues.elementAt(j), true); // [atr,op,valor] // incluimos tb los valores en double para facilitar algunas funciones s.setValor((double) j); almacenSelectores.addSelector(s); // s.print(); } // System.out.println("}"); break; } // System.out.println(num_atributos); } return almacenSelectores; }
public void init(String name, Attributes atts) { logger.log(LogService.LOG_DEBUG, "Here is IconHandler:init()"); // $NON-NLS-1$ super.init(name, atts); String icon_resource_val = atts.getValue(RESOURCE); if (icon_resource_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { RESOURCE, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } String icon_size_val = atts.getValue(SIZE); if (icon_size_val == null) { // Not a problem, because SIZE is an optional attribute. icon_size_val = "0"; // $NON-NLS-1$ } else if (icon_size_val.equalsIgnoreCase("")) { // $NON-NLS-1$ icon_size_val = "0"; // $NON-NLS-1$ } _icon = new Icon(icon_resource_val, Integer.parseInt(icon_size_val), _dp_bundle); }
public static int verifyMaliciousPassword(String login, String mail) { String mailAdresse = ""; Ldap adminConnection = new Ldap(); adminConnection.SetEnv( Play.configuration.getProperty("ldap.host"), Play.configuration.getProperty("ldap.admin.dn"), Play.configuration.getProperty("ldap.admin.password")); Attributes f = adminConnection.getUserInfo(adminConnection.getLdapEnv(), login); try { NamingEnumeration e = f.getAll(); while (e.hasMore()) { javax.naming.directory.Attribute a = (javax.naming.directory.Attribute) e.next(); String attributeName = a.getID(); String attributeValue = ""; Enumeration values = a.getAll(); while (values.hasMoreElements()) { attributeValue = values.nextElement().toString(); } if (attributeName.equals("mail")) { mailAdresse = attributeValue; } } } catch (javax.naming.NamingException e) { System.out.println(e.getMessage()); return 0; } finally { if (mailAdresse.equals("")) { return Invitation.USER_NOTEXIST; } else if (mailAdresse.equals(mail)) { return Invitation.ADDRESSES_MATCHE; } else { return Invitation.ADDRESSES_NOTMATCHE; } } }
/** * Returns the manifest value for the specified key. * * @param key key * @return value or {@code null} */ public static Object get(final String key) { if (MAP != null) { for (final Object o : MAP.keySet()) { if (key.equals(o.toString())) return MAP.get(o); } } return null; }
private void addCreatedBy(Manifest m) { Attributes global = m.getMainAttributes(); if (global.getValue(new Attributes.Name("Created-By")) == null) { String javaVendor = System.getProperty("java.vendor"); String jdkVersion = System.getProperty("java.version"); global.put(new Attributes.Name("Created-By"), jdkVersion + " (" + javaVendor + ")"); } }
public void mustSuitablyOverrideAttributeHandlingMethods() { @SuppressWarnings("unused") final Source<Integer, NotUsed> f = Source.single(42) .withAttributes(Attributes.name("")) .addAttributes(Attributes.asyncBoundary()) .named(""); }
/** * Generates an entry for a backup directory based on the provided DN. The DN must contain an RDN * component that specifies the path to the backup directory, and that directory must exist and be * a valid backup directory. * * @param entryDN The DN of the backup directory entry to retrieve. * @return The requested backup directory entry. * @throws DirectoryException If the specified directory does not exist or is not a valid backup * directory, or if the DN does not specify any backup directory. */ private Entry getBackupDirectoryEntry(DN entryDN) throws DirectoryException { // Make sure that the DN specifies a backup directory. AttributeType t = DirectoryServer.getAttributeType(ATTR_BACKUP_DIRECTORY_PATH, true); AttributeValue v = entryDN.getRDN().getAttributeValue(t); if (v == null) { Message message = ERR_BACKUP_DN_DOES_NOT_SPECIFY_DIRECTORY.get(String.valueOf(entryDN)); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message, backupBaseDN, null); } // Get a handle to the backup directory and the information that it // contains. BackupDirectory backupDirectory; try { backupDirectory = BackupDirectory.readBackupDirectoryDescriptor(v.getValue().toString()); } catch (ConfigException ce) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, ce); } Message message = ERR_BACKUP_INVALID_BACKUP_DIRECTORY.get(String.valueOf(entryDN), ce.getMessage()); throw new DirectoryException(ResultCode.CONSTRAINT_VIOLATION, message); } catch (Exception e) { if (debugEnabled()) { TRACER.debugCaught(DebugLogLevel.ERROR, e); } Message message = ERR_BACKUP_ERROR_GETTING_BACKUP_DIRECTORY.get(getExceptionMessage(e)); throw new DirectoryException(DirectoryServer.getServerErrorResultCode(), message); } // Construct the backup directory entry to return. LinkedHashMap<ObjectClass, String> ocMap = new LinkedHashMap<ObjectClass, String>(2); ocMap.put(DirectoryServer.getTopObjectClass(), OC_TOP); ObjectClass backupDirOC = DirectoryServer.getObjectClass(OC_BACKUP_DIRECTORY, true); ocMap.put(backupDirOC, OC_BACKUP_DIRECTORY); LinkedHashMap<AttributeType, List<Attribute>> opAttrs = new LinkedHashMap<AttributeType, List<Attribute>>(0); LinkedHashMap<AttributeType, List<Attribute>> userAttrs = new LinkedHashMap<AttributeType, List<Attribute>>(3); ArrayList<Attribute> attrList = new ArrayList<Attribute>(1); attrList.add(Attributes.create(t, v)); userAttrs.put(t, attrList); t = DirectoryServer.getAttributeType(ATTR_BACKUP_BACKEND_DN, true); attrList = new ArrayList<Attribute>(1); attrList.add( Attributes.create( t, AttributeValues.create(t, backupDirectory.getConfigEntryDN().toString()))); userAttrs.put(t, attrList); Entry e = new Entry(entryDN, ocMap, userAttrs, opAttrs); e.processVirtualAttributes(); return e; }
public Attributes getAttributes() throws IOException { if (URLJarFile.this.isSuperMan()) { Map e = URLJarFile.this.superEntries; if (e != null) { Attributes a = (Attributes) e.get(getName()); if (a != null) return (Attributes) a.clone(); } } return null; }
private boolean isAmbiguousMainClass(Manifest m) { if (ename != null) { Attributes global = m.getMainAttributes(); if ((global.get(Attributes.Name.MAIN_CLASS) != null)) { error(getMsg("error.bad.eflag")); usageError(); return true; } } return false; }
public void init( String name, Attributes atts, Hashtable<String, ObjectClassDefinitionImpl> ocds_hashtable) { logger.log(LogService.LOG_DEBUG, "Here is OcdHandler():init()"); // $NON-NLS-1$ super.init(name, atts); _parent_OCDs_hashtable = ocds_hashtable; collectExtensionAttributes(atts); String ocd_name_val = atts.getValue(NAME); if (ocd_name_val == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { NAME, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } String ocd_description_val = atts.getValue(DESCRIPTION); if (ocd_description_val == null) { // Not a problem, because DESCRIPTION is an optional attribute. } _refID = atts.getValue(ID); if (_refID == null) { _isParsedDataValid = false; logger.log( LogService.LOG_ERROR, NLS.bind( MetaTypeMsg.MISSING_ATTRIBUTE, new Object[] { ID, name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); return; } _ocd = new ObjectClassDefinitionImpl( ocd_name_val, ocd_description_val, _refID, _dp_localization, extensionAttributes); }
private static Hashtable<String, String> getManifestAttributes(Manifest manifest) { Hashtable<String, String> h = new Hashtable<String, String>(); try { Attributes attrs = manifest.getMainAttributes(); Iterator it = attrs.keySet().iterator(); while (it.hasNext()) { String key = it.next().toString(); h.put(key, attrs.getValue(key)); } } catch (Exception ignore) { } return h; }
public void startElement(String uri, String sName, String qName, Attributes attrs) { if (qName.equals("PROPSTABLE")) { // LogUtil.fine(attrs.getValue("DESC")); propsAl = new ArrayList(); } else if (qName.equals("PROPSROW")) { curPROPSROW_DESC = attrs.getValue("DESC"); curProps = new Properties(); } else { // LogUtil.fine(qName); curKEY_DESC = attrs.getValue("DESC"); curKey = qName; textFlag = true; } }
static void checkDataset() { Attribute[] outputs = Attributes.getOutputAttributes(); if (outputs.length != 1) { LogManager.printErr("Only datasets with one output are supported"); System.exit(1); } if (outputs[0].getType() != Attribute.NOMINAL) { LogManager.printErr("Output attribute should be nominal"); System.exit(1); } Parameters.numClasses = outputs[0].getNumNominalValues(); Parameters.numAttributes = Attributes.getInputAttributes().length; }
protected void collectExtensionAttributes(Attributes attributes) { for (int i = 0; i < attributes.getLength(); i++) { String key = attributes.getURI(i); if (key.length() == 0 || key.startsWith("http://www.osgi.org/xmlns/metatype/v")) // $NON-NLS-1$ continue; Map<String, String> value = extensionAttributes.get(key); if (value == null) { value = new HashMap<String, String>(); extensionAttributes.put(key, value); } value.put( getName(attributes.getLocalName(i), attributes.getQName(i)), attributes.getValue(i)); } }
/** Method interface for Automatic Branch and Bound */ public void ejecutar() { String resultado; int i, numFeatures; Date d; d = new Date(); resultado = "RESULTS generated at " + String.valueOf((Date) d) + " \n--------------------------------------------------\n"; resultado += "Algorithm Name: " + params.nameAlgorithm + "\n"; /* call of ABB algorithm */ runABB(); resultado += "\nPARTITION Filename: " + params.trainFileNameInput + "\n---------------\n\n"; resultado += "Features selected: \n"; for (i = numFeatures = 0; i < features.length; i++) if (features[i] == true) { resultado += Attributes.getInputAttribute(i).getName() + " - "; numFeatures++; } resultado += "\n\n" + String.valueOf(numFeatures) + " features of " + Attributes.getInputNumAttributes() + "\n\n"; resultado += "Error in test (using train for prediction): " + String.valueOf(data.validacionCruzada(features)) + "\n"; resultado += "Error in test (using test for prediction): " + String.valueOf(data.LVOTest(features)) + "\n"; resultado += "---------------\n"; System.out.println("Experiment completed successfully"); /* creates the new training and test datasets only with the selected features */ Files.writeFile(params.extraFileNameOutput, resultado); data.generarFicherosSalida(params.trainFileNameOutput, params.testFileNameOutput, features); }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is DesignateHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OBJECT)) { ObjectHandler objectHandler = new ObjectHandler(this); objectHandler.init(name, atts); if (objectHandler._isParsedDataValid) { _ocdref = objectHandler._ocdref; } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is AttributeDefinitionHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(OPTION)) { OptionHandler optionHandler = new OptionHandler(this); optionHandler.init(name, atts); if (optionHandler._isParsedDataValid) { // Only add valid Option _optionLabel_vector.addElement(optionHandler._label_val); _optionValue_vector.addElement(optionHandler._value_val); } } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is OcdHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(AD)) { AttributeDefinitionHandler attributeDefHandler = new AttributeDefinitionHandler(this); attributeDefHandler.init(name, atts, _ad_vector); } else if (name.equalsIgnoreCase(ICON)) { IconHandler iconHandler = new IconHandler(this); iconHandler.init(name, atts); if (iconHandler._isParsedDataValid) icons.add(iconHandler._icon); } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is MetaDataHandler:startElement():" //$NON-NLS-1$ + qName); String name = getName(localName, qName); if (name.equalsIgnoreCase(DESIGNATE)) { DesignateHandler designateHandler = new DesignateHandler(this); designateHandler.init(name, atts); if (designateHandler._isParsedDataValid) { _dp_designateHandlers.addElement(designateHandler); } } else if (name.equalsIgnoreCase(OCD)) { OcdHandler ocdHandler = new OcdHandler(this); ocdHandler.init(name, atts, _dp_OCDs); } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
void insertInputOutput( String line, int lineCount, Vector collection, String type, boolean isTrain) { String attName; System.out.println(" >> processing: " + line); // Declaring StringTokenizer StringTokenizer st = new StringTokenizer(line, ","); while (st.hasMoreTokens()) { attName = st.nextToken().trim(); if (Attributes.getAttribute(attName) == null) { // If this attribute has not been declared, generate error ErrorInfo er = new ErrorInfo( ErrorInfo.InputTestAttributeNotDefined, 0, lineCount, 0, 0, isTrain, ("The attribute " + attName + " defined in @" + type + " in test, it has not been defined in @inputs in its train dataset. It will be ignored")); InstanceSet.errorLogger.setError(er); } else { System.out.println(" > " + type + " attribute considered: " + attName + "."); collection.add(attName); } } } // end insertInputOutput
public void startElement(String uri, String localName, String qName, Attributes atts) { logger.log( LogService.LOG_DEBUG, "Here is ObjectHandler:startElement():" //$NON-NLS-1$ + qName); if (!_isParsedDataValid) return; String name = getName(localName, qName); if (name.equalsIgnoreCase(ATTRIBUTE)) { AttributeHandler attributeHandler = new AttributeHandler(this); attributeHandler.init(name, atts); // The ATTRIBUTE element is only used by RFC94, do nothing for it here. } else { logger.log( LogService.LOG_WARNING, NLS.bind( MetaTypeMsg.UNEXPECTED_ELEMENT, new Object[] { name, atts.getValue(ID), _dp_url, _dp_bundle.getBundleId(), _dp_bundle.getSymbolicName() })); } }
public void startElement(String namespaceURI, String localName, String rawName, Attributes atts) throws SAXException { String k; if (insidePerson = (rawName.equals("author") || rawName.equals("editor"))) { Value = ""; return; } if (insidePerson = (rawName.equals("booktitle") || rawName.equals("journal"))) { Value = ""; return; } if ((atts.getLength() > 0) && ((k = atts.getValue("key")) != null)) { key = k; recordTag = rawName; } }
public void startElement(String uri, String localName, String qname, Attributes atts) { super.startElement(uri, localName, qname, atts); if (localName.equals(DataExport.FIELD_EXPORT)) { String type = atts.getValue(DataExport.EXPORT_TYPE); textImport = (type != null && type.equals(DataExport.EXPORT_TYPE_TEXT)); } else if (localName.equals(DataRecord.ENCODING_RECORD)) { // begin of record record = dataAccess.getPersistence().createNewRecord(); fieldsInImport = new ArrayList<String>(); return; } else { if (atts.getValue("key") != null && atts.getValue("key").equalsIgnoreCase("true")) { overrideKeyField = localName; } } }
private Map attributeMap(String tagName, Attributes atts) throws ParserException { if (null == tagName || null == atts) return null; Map mapping = null; try { mapping = (Map) attributeMaps.get(tagName); } catch (Exception e) { throw new ParserException( "Typecast error, unknown element found in attribute list mappings! " + e.getMessage()); } if (null == mapping) return null; Map resultMapping = new HashMap(); for (int i = 0; i < atts.getLength(); i++) { String xmlName = atts.getQName(i); String value = atts.getValue(i); TagMap.AttributeMapping aMap = null; try { aMap = (TagMap.AttributeMapping) mapping.get(xmlName); } catch (Exception e) { throw new ParserException( "Typecast error, unknown element found in property mapping! " + e.getMessage()); } if (null == aMap) throw new ParserException( "No attribute mapping specified for attribute: " + xmlName + " in tag: " + tagName); String propertyName = aMap.getPropertyName(); try { resultMapping.put(propertyName, aMap.convertValue(value)); } catch (Exception e) { throw new ParserException( "Can not convert given value: \"" + value + "\" to specified type: " + aMap.getType() + " for attribute: " + xmlName + " in tag: " + tagName + "! " + e.getMessage()); } } checkForRequiredAttributes(tagName, resultMapping, mapping); addDefaultValues(resultMapping, mapping); return resultMapping; }
/** It does return the original header definiton but without @input and @output in there */ public String getOriginalHeaderWithoutInOut() { String line = ""; Attribute[] attrs = null; // Getting the relation name and the attributes if (storeAttributesAsNonStatic && attributes != null) { line = "@relation " + attributes.getRelationName() + "\n"; attrs = attributes.getAttributes(); } else { line = "@relation " + Attributes.getRelationName() + "\n"; attrs = Attributes.getAttributes(); } for (int i = 0; i < attrs.length; i++) { line += attrs[i].toString() + "\n"; } return line; } // end getOriginalHeaderWithoutInOut
/** * Creates a boolean array with all values to true * * @return returns a boolean vector with all values to true */ private boolean[] startSolution() { boolean fv[]; fv = new boolean[Attributes.getInputNumAttributes()]; for (int i = 0; i < fv.length; i++) fv[i] = true; return fv; }
public void startElement( String namespaceURI, String lName, // local name String qName, // qualified name Attributes attrs) throws SAXException { element = qName; if (element.compareToIgnoreCase("presence") == 0) { presenceTag = new PresenceTag(); String entity = attrs.getValue("entity").trim(); presenceTag.setEntity(entity); } if (element.compareToIgnoreCase("presentity") == 0) { presentityTag = new PresentityTag(); String id = attrs.getValue("id").trim(); presentityTag.setId(id); } if (element.compareToIgnoreCase("tuple") == 0) { tupleTag = new TupleTag(); String id = attrs.getValue("id").trim(); tupleTag.setId(id); } if (element.compareToIgnoreCase("status") == 0) { statusTag = new StatusTag(); } if (element.compareToIgnoreCase("basic") == 0) { basicTag = new BasicTag(); } if (element.compareToIgnoreCase("contact") == 0) { contactTag = new ContactTag(); String priority = attrs.getValue("priority").trim(); if (priority != null) { try { contactTag.setPriority(Float.parseFloat(priority)); } catch (Exception e) { e.printStackTrace(); } } } if (element.compareToIgnoreCase("note") == 0) { noteTag = new NoteTag(); } }
private static String getVersionString() { String findContainingJar = JarManager.findContainingJar(Main.class); try { StringBuffer buffer = new StringBuffer(); JarFile jar = new JarFile(findContainingJar); final Manifest manifest = jar.getManifest(); final Map<String, Attributes> attrs = manifest.getEntries(); Attributes attr = attrs.get("org/apache/pig"); String version = (String) attr.getValue("Implementation-Version"); String svnRevision = (String) attr.getValue("Svn-Revision"); String buildTime = (String) attr.getValue("Build-TimeStamp"); // we use a version string similar to svn // svn, version 1.4.4 (r25188) // compiled Sep 23 2007, 22:32:34 return "Apache Pig version " + version + " (r" + svnRevision + ") \ncompiled " + buildTime; } catch (Exception e) { throw new RuntimeException("unable to read pigs manifest file", e); } }