Example usage for java.util Hashtable isEmpty

List of usage examples for java.util Hashtable isEmpty

Introduction

In this page you can find the example usage for java.util Hashtable isEmpty.

Prototype

public synchronized boolean isEmpty() 

Source Link

Document

Tests if this hashtable maps no keys to values.

Usage

From source file:org.wandora.application.gui.OccurrenceTableSingleType.java

@Override
public void changeType() {
    try {//  ww w.  j  a  va2 s  .co  m
        Point p = getTableModelPoint();
        if (p != null) {
            Topic selectedScope = langs[p.y];
            if (type != null && !type.isRemoved()) {
                Topic newType = wandora.showTopicFinder("Select new occurrence type");
                if (newType != null && !newType.isRemoved()) {
                    Hashtable<Topic, String> os = topic.getData(type);
                    if (os != null && !os.isEmpty()) {
                        for (Topic scope : os.keySet()) {
                            if (scope != null && !scope.isRemoved()) {
                                if (selectedScope == null) {
                                    String occurrenceText = os.get(scope);
                                    topic.setData(newType, scope, occurrenceText);
                                } else if (selectedScope.mergesWithTopic(scope)) {
                                    String occurrenceText = os.get(scope);
                                    topic.setData(newType, scope, occurrenceText);
                                }
                            }
                        }
                        if (selectedScope == null) {
                            topic.removeData(type);
                        } else {
                            topic.removeData(type, selectedScope);
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        if (wandora != null)
            wandora.handleError(e);
    }
}

From source file:solidstack.reflect.Dumper.java

public void dumpTo(Object o, DumpWriter out) {
    try {/* w w  w  .ja v  a2 s  .c  o  m*/
        if (o == null) {
            out.append("<null>");
            return;
        }
        Class<?> cls = o.getClass();
        if (cls == String.class) {
            out.append("\"").append(((String) o).replace("\\", "\\\\").replace("\n", "\\n").replace("\r", "\\r")
                    .replace("\t", "\\t").replace("\"", "\\\"")).append("\"");
            return;
        }
        if (o instanceof CharSequence) {
            out.append("(").append(o.getClass().getName()).append(")");
            dumpTo(o.toString(), out);
            return;
        }
        if (cls == char[].class) {
            out.append("(char[])");
            dumpTo(String.valueOf((char[]) o), out);
            return;
        }
        if (cls == byte[].class) {
            out.append("byte[").append(Integer.toString(((byte[]) o).length)).append("]");
            return;
        }
        if (cls == Class.class) {
            out.append(((Class<?>) o).getCanonicalName()).append(".class");
            return;
        }
        if (cls == File.class) {
            out.append("File( \"").append(((File) o).getPath()).append("\" )");
            return;
        }
        if (cls == AtomicInteger.class) {
            out.append("AtomicInteger( ").append(Integer.toString(((AtomicInteger) o).get())).append(" )");
            return;
        }
        if (cls == AtomicLong.class) {
            out.append("AtomicLong( ").append(Long.toString(((AtomicLong) o).get())).append(" )");
            return;
        }
        if (o instanceof ClassLoader) {
            out.append(o.getClass().getCanonicalName());
            return;
        }

        if (cls == java.lang.Short.class || cls == java.lang.Long.class || cls == java.lang.Integer.class
                || cls == java.lang.Float.class || cls == java.lang.Byte.class
                || cls == java.lang.Character.class || cls == java.lang.Double.class
                || cls == java.lang.Boolean.class || cls == BigInteger.class || cls == BigDecimal.class) {
            out.append("(").append(cls.getSimpleName()).append(")").append(o.toString());
            return;
        }

        String className = cls.getCanonicalName();
        if (className == null)
            className = cls.getName();
        out.append(className);

        if (this.skip.contains(className) || o instanceof java.lang.Thread) {
            out.append(" (skipped)");
            return;
        }

        Integer id = this.visited.get(o);
        if (id == null) {
            id = ++this.id;
            this.visited.put(o, id);
            if (!this.hideIds)
                out.append(" <id=" + id + ">");
        } else {
            out.append(" <refid=" + id + ">");
            return;
        }

        if (cls.isArray()) {
            if (Array.getLength(o) == 0)
                out.append(" []");
            else {
                out.newlineOrSpace().append("[").newlineOrSpace().indent().setFirst();
                int rowCount = Array.getLength(o);
                for (int i = 0; i < rowCount; i++) {
                    out.comma();
                    dumpTo(Array.get(o, i), out);
                }
                out.newlineOrSpace().unIndent().append("]");
            }
        } else if (o instanceof Collection && !this.overriddenCollection.contains(className)) {
            Collection<?> list = (Collection<?>) o;
            if (list.isEmpty())
                out.append(" []");
            else {
                out.newlineOrSpace().append("[").newlineOrSpace().indent().setFirst();
                for (Object value : list) {
                    out.comma();
                    dumpTo(value, out);
                }
                out.newlineOrSpace().unIndent().append("]");
            }
        } else if (o instanceof Properties && !this.overriddenCollection.contains(className)) // Properties is a Map, so it must come before the Map
        {
            Field def = cls.getDeclaredField("defaults");
            if (!def.isAccessible())
                def.setAccessible(true);
            Properties defaults = (Properties) def.get(o);
            Hashtable<?, ?> map = (Hashtable<?, ?>) o;
            out.newlineOrSpace().append("[").newlineOrSpace().indent().setFirst();
            for (Map.Entry<?, ?> entry : map.entrySet()) {
                out.comma();
                dumpTo(entry.getKey(), out);
                out.append(": ");
                dumpTo(entry.getValue(), out);
            }
            if (defaults != null && !defaults.isEmpty()) {
                out.comma().append("defaults: ");
                dumpTo(defaults, out);
            }
            out.newlineOrSpace().unIndent().append("]");
        } else if (o instanceof Map && !this.overriddenCollection.contains(className)) {
            Map<?, ?> map = (Map<?, ?>) o;
            if (map.isEmpty())
                out.append(" []");
            else {
                out.newlineOrSpace().append("[").newlineOrSpace().indent().setFirst();
                for (Map.Entry<?, ?> entry : map.entrySet()) {
                    out.comma();
                    dumpTo(entry.getKey(), out);
                    out.append(": ");
                    dumpTo(entry.getValue(), out);
                }
                out.newlineOrSpace().unIndent().append("]");
            }
        } else if (o instanceof Method) {
            out.newlineOrSpace().append("{").newlineOrSpace().indent().setFirst();

            Field field = cls.getDeclaredField("clazz");
            if (!field.isAccessible())
                field.setAccessible(true);
            out.comma().append("clazz").append(": ");
            dumpTo(field.get(o), out);

            field = cls.getDeclaredField("name");
            if (!field.isAccessible())
                field.setAccessible(true);
            out.comma().append("name").append(": ");
            dumpTo(field.get(o), out);

            field = cls.getDeclaredField("parameterTypes");
            if (!field.isAccessible())
                field.setAccessible(true);
            out.comma().append("parameterTypes").append(": ");
            dumpTo(field.get(o), out);

            field = cls.getDeclaredField("returnType");
            if (!field.isAccessible())
                field.setAccessible(true);
            out.comma().append("returnType").append(": ");
            dumpTo(field.get(o), out);

            out.newlineOrSpace().unIndent().append("}");
        } else {
            ArrayList<Field> fields = new ArrayList<Field>();
            while (cls != Object.class) {
                Field[] fs = cls.getDeclaredFields();
                for (Field field : fs)
                    fields.add(field);
                cls = cls.getSuperclass();
            }

            Collections.sort(fields, new Comparator<Field>() {
                public int compare(Field left, Field right) {
                    return left.getName().compareTo(right.getName());
                }
            });

            if (fields.isEmpty())
                out.append(" {}");
            else {
                out.newlineOrSpace().append("{").newlineOrSpace().indent().setFirst();
                for (Field field : fields)
                    if ((field.getModifiers() & Modifier.STATIC) == 0)
                        if (!this.hideTransients || (field.getModifiers() & Modifier.TRANSIENT) == 0) {
                            out.comma().append(field.getName()).append(": ");

                            if (!field.isAccessible())
                                field.setAccessible(true);

                            if (field.getType().isPrimitive())
                                if (field.getType() == boolean.class) // TODO More?
                                    out.append(field.get(o).toString());
                                else
                                    out.append("(").append(field.getType().getName()).append(")")
                                            .append(field.get(o).toString());
                            else
                                dumpTo(field.get(o), out);
                        }
                out.newlineOrSpace().unIndent().append("}");
            }
        }
    } catch (IOException e) {
        throw new FatalIOException(e);
    } catch (Exception e) {
        dumpTo(e.toString(), out);
    }
}

From source file:net.sourceforge.dvb.projectx.common.Common.java

/**
 *
 *///from  w  w w . j  a va 2s.c o m
public static Hashtable getUserColourTable(String model) throws IOException {
    Hashtable user_table = new Hashtable();

    URL url = Resource.getResourceURL(COLOUR_TABLES_FILENAME);

    if (url == null)
        return user_table;

    BufferedReader table = new BufferedReader(new InputStreamReader(url.openStream()));
    String line;
    boolean table_match = false;

    while ((line = table.readLine()) != null) {
        if (line.trim().length() == 0)
            continue;

        if (line.startsWith("table"))
            table_match = line.substring(line.indexOf("=") + 1).trim().equals(model);

        else if (table_match) {
            if (line.startsWith("model"))
                user_table.put("model", line.substring(line.indexOf("=") + 1).trim());

            else
                user_table.put(line.substring(0, line.indexOf("=")).trim(),
                        line.substring(line.indexOf("=") + 1).trim());
        }
    }

    table.close();

    if (!user_table.isEmpty() && !user_table.containsKey("model"))
        user_table.put("model", "16");

    return user_table;
}

From source file:org.globus.workspace.network.defaults.Util.java

/**
 * @param associationDir association directory, may not be null
 * @param previous previous entries/*ww w  .  j  av  a 2s . co  m*/
 * @return updated entries
 * @throws Exception problem
 */
static Hashtable loadDirectory(File associationDir, Hashtable previous) throws Exception {

    if (associationDir == null) {
        throw new IllegalArgumentException("null associationDir");
    }

    final String[] listing = associationDir.list();

    if (listing == null) {
        // null return from list() is different than zero results, it denotes a real problem
        throw new Exception(
                "Problem listing contents of directory '" + associationDir.getAbsolutePath() + '\'');
    }

    final Hashtable newAssocSet = new Hashtable(listing.length);

    for (int i = 0; i < listing.length; i++) {

        final String path = associationDir.getAbsolutePath() + File.separator + listing[i];

        final File associationFile = new File(path);

        if (!associationFile.isFile()) {
            logger.warn("not a file: '" + path + "'");
            continue;
        }

        final String assocName = associationFile.getName();

        Association oldassoc = null;
        if (previous != null) {
            oldassoc = (Association) previous.get(assocName);

            // skip reading if file modification time isn't newer than last
            // container boot
            if (oldassoc != null) {
                if (oldassoc.getFileTime() == associationFile.lastModified()) {

                    logger.info("file modification time for network '" + assocName
                            + "' is not newer, using old configuration");

                    newAssocSet.put(assocName, oldassoc);

                    continue;
                }
            }
        }

        final Association newassoc = getNewAssoc(assocName, associationFile, oldassoc);

        if (newassoc != null) {
            newAssocSet.put(assocName, newassoc);
        }
    }

    if (previous == null || previous.isEmpty()) {
        return newAssocSet;
    }

    // Now look at previous entries in database for entries that were
    // there and now entirely gone.
    // If in use, we don't do anything.  When retired and the entry is
    // not in DB, a warning will trip but that is it.  From then on, the
    // address will be gone.

    final Enumeration en = previous.keys();

    while (en.hasMoreElements()) {

        final String assocname = (String) en.nextElement();
        final Association oldassoc = (Association) previous.get(assocname);
        if (oldassoc == null) {
            throw new ProgrammingError("all networks " + "in the hashmap should be non-null");
        }
        if (newAssocSet.containsKey(assocname)) {
            logChangedAssoc(assocname, (Association) newAssocSet.get(assocname), oldassoc);
        } else {
            logger.info("Previously configured network '" + assocname
                    + "' is not present in the new configuration. " + goneStatus(oldassoc));
        }
    }

    return newAssocSet;
}

From source file:org.sakaiproject.archive.tool.ArchiveAction.java

/**
* doImport called when "eventSubmit_doBatch_Import" is in the request parameters
* to run an import.//w  w w .  j  av a  2s.co m
*/
public void doBatch_Import(RunData data, Context context) {
    SessionState state = ((JetspeedRunData) data).getPortletSessionState(((JetspeedRunData) data).getJs_peid());

    Hashtable fTable = new Hashtable();

    if (!securityService.isSuperUser()) {
        addAlert(state, rb.getString("archive.batch.auth"));
        return;
    }

    //String fileName = data.getParameters().getString("import-file");
    FileItem fi = data.getParameters().getFileItem("importFile");
    if (fi == null) {
        addAlert(state, rb.getString("archive.batch.missingname"));
    } else {
        // get content
        String content = fi.getString();

        String[] lines = content.split("\n");
        for (int i = 0; i < lines.length; i++) {
            String lineContent = (String) lines[i];
            String[] lineContents = lineContent.split("\t");
            if (lineContents.length == 2) {
                fTable.put(lineContents[0], lineContents[1]);
            } else {
                addAlert(state, rb.getString("archive.batch.wrongformat"));
            }
        }
    }

    if (!fTable.isEmpty()) {
        Enumeration importFileName = fTable.keys();
        int count = 1;
        while (importFileName.hasMoreElements()) {
            String path = StringUtils.trimToNull((String) importFileName.nextElement());
            String siteCreatorName = StringUtils.trimToNull((String) fTable.get(path));
            if (path != null && siteCreatorName != null) {
                String nSiteId = idManager.createUuid();

                try {
                    Object[] params = new Object[] { count, path, nSiteId, siteCreatorName };
                    addAlert(state, rb.getFormattedMessage("archive.import1", params));
                    addAlert(state, archiveService.merge(path, nSiteId, siteCreatorName));

                } catch (Exception ignore) {
                }
            }

            count++;
        }
    }
}

From source file:org.unitime.timetable.test.BatchStudentSectioningLoader.java

public void loadLastLikeStudent(org.hibernate.Session hibSession, LastLikeCourseDemand d,
        org.unitime.timetable.model.Student s, Long courseOfferingId, Hashtable studentTable,
        Hashtable courseTable, Hashtable classTable, Hashtable classAssignments) {
    sLog.debug("Loading last like demand of student " + s.getUniqueId() + " (id=" + s.getExternalUniqueId()
            + ", name=" + s.getFirstName() + " " + s.getMiddleName() + " " + s.getLastName() + ") for "
            + courseOfferingId);/*from w w  w. ja v  a  2 s  .co m*/
    Student student = (Student) studentTable.get(s.getUniqueId());
    if (student == null) {
        student = new Student(s.getUniqueId().longValue(), true);
        if (iLoadStudentInfo)
            loadStudentInfo(student, s);
        studentTable.put(s.getUniqueId(), student);
    }
    int priority = student.getRequests().size();
    Vector courses = new Vector();
    Course course = (Course) courseTable.get(courseOfferingId);
    if (course == null) {
        sLog.warn("  -- course " + courseOfferingId + " not loaded");
        return;
    }
    courses.addElement(course);
    CourseRequest request = new CourseRequest(d.getUniqueId().longValue(), priority++, false, student, courses,
            false, null);
    sLog.debug("  -- added request " + request);
    if (classAssignments != null && !classAssignments.isEmpty()) {
        HashSet assignedSections = new HashSet();
        HashSet classIds = (HashSet) classAssignments.get(s.getUniqueId());
        if (classIds != null)
            for (Iterator i = classIds.iterator(); i.hasNext();) {
                Long classId = (Long) i.next();
                Section section = (Section) request.getSection(classId.longValue());
                if (section != null)
                    assignedSections.add(section);
            }
        if (!assignedSections.isEmpty()) {
            sLog.debug("    -- committed assignment: " + assignedSections);
            for (Enrollment enrollment : request.values(getAssignment())) {
                if (enrollment.getAssignments().containsAll(assignedSections)) {
                    request.setInitialAssignment(enrollment);
                    sLog.debug("      -- found: " + enrollment);
                    break;
                }
            }
        }
    }
}

From source file:org.oscarehr.decisionSupport.model.DSGuidelineFactory.java

public DSGuideline createGuidelineFromXml(String xml) throws DecisionSupportParseException {
    if (xml == null || xml.equals(""))
        throw new DecisionSupportParseException("Xml not set");
    SAXBuilder parser = new SAXBuilder();
    Document doc;/*from  w  w w . j a va  2  s . c  o m*/
    try {
        doc = parser.build(new StringReader(xml));
    } catch (JDOMException jdome) {
        throw new DecisionSupportParseException("Failed to read the xml string for parsing", jdome);
    } catch (IOException ioe) {
        throw new DecisionSupportParseException("Failed to read the xml string for parsing", ioe);
    }
    //<guideline evidence="" significance="" title="Plavix Drug DS">
    Element guidelineRoot = doc.getRootElement();

    DSGuideline dsGuideline = this.createBlankGuideline();

    String guidelineTitle = guidelineRoot.getAttributeValue("title");
    dsGuideline.setTitle(guidelineTitle);

    //Load parameters such as classes
    //<parameter identifier="a">
    //  <class>java.util.ArrayList</class>
    //</parameter>
    ArrayList<DSParameter> parameters = new ArrayList<DSParameter>();
    @SuppressWarnings("unchecked")
    List<Element> parameterTags = guidelineRoot.getChildren("parameter");
    for (Element parameterTag : parameterTags) {
        String alias = parameterTag.getAttributeValue("identifier");
        if (alias == null) {
            throw new DecisionSupportParseException(guidelineTitle,
                    "Parameter identifier attribute is mandatory");
        }

        Element Eclass = parameterTag.getChild("class");
        String strClass = Eclass.getText();
        DSParameter dsParameter = new DSParameter();
        dsParameter.setStrAlias(alias);
        dsParameter.setStrClass(strClass);
        parameters.add(dsParameter);
    }

    dsGuideline.setParameters(parameters);

    //Load Conditions
    //<conditions>
    //  <condition type="dxcodes" any="icd9:4439,icd9:4438,icd10:E11,icd10:E12"/>
    //  <condition type="drug" not="atc:34234"/>
    ArrayList<DSCondition> conditions = new ArrayList<DSCondition>();
    @SuppressWarnings("unchecked")
    List<Element> conditionTags = guidelineRoot.getChild("conditions").getChildren("condition");
    for (Element conditionTag : conditionTags) {

        String conditionTypeStr = conditionTag.getAttributeValue("type");
        if (conditionTypeStr == null)
            throw new DecisionSupportParseException(guidelineTitle, "Condition 'type' attribute is mandatory");
        //try to resolve type
        DSDemographicAccess.Module conditionType;
        try {
            conditionType = DSDemographicAccess.Module.valueOf(conditionTypeStr);
        } catch (IllegalArgumentException iae) {
            String knownTypes = StringUtils.join(DSDemographicAccess.Module.values(), ",");
            throw new DecisionSupportParseException(guidelineTitle,
                    "Cannot recognize condition type: '" + conditionTypeStr + "'.  Known types: " + knownTypes,
                    iae);
        }

        String conditionDescStr = conditionTag.getAttributeValue("desc");

        Hashtable<String, String> paramHashtable = new Hashtable<String, String>();
        @SuppressWarnings("unchecked")
        List<Element> paramList = conditionTag.getChildren("param");
        if (paramList != null) {
            for (Element param : paramList) {
                String key = param.getAttributeValue("key");
                String value = param.getAttributeValue("value");
                paramHashtable.put(key, value);
            }
        }

        @SuppressWarnings("unchecked")
        List<Attribute> attributes = conditionTag.getAttributes();
        for (Attribute attribute : attributes) {
            if (attribute.getName().equalsIgnoreCase("type"))
                continue;
            if (attribute.getName().equalsIgnoreCase("desc"))
                continue;
            DSCondition.ListOperator operator;
            try {
                operator = DSCondition.ListOperator.valueOf(attribute.getName().toLowerCase());
            } catch (IllegalArgumentException iae) {
                throw new DecisionSupportParseException(guidelineTitle,
                        "Unknown condition attribute'" + attribute.getName() + "'", iae);
            }
            DSCondition dsCondition = new DSCondition();
            dsCondition.setConditionType(conditionType);
            dsCondition.setDesc(conditionDescStr);
            dsCondition.setListOperator(operator); //i.e. any, all, not
            if (paramHashtable != null && !paramHashtable.isEmpty()) {
                _log.debug("THIS IS THE HASH STRING " + paramHashtable.toString());
                dsCondition.setParam(paramHashtable);
            }

            dsCondition.setValues(DSValue.createDSValues(attribute.getValue())); //i.e. icd9:3020,icd9:3021,icd10:5022
            conditions.add(dsCondition);
        }
    }
    dsGuideline.setConditions(conditions);

    //CONSEQUENCES
    ArrayList<DSConsequence> dsConsequences = new ArrayList<DSConsequence>();
    @SuppressWarnings("unchecked")
    List<Element> consequenceElements = guidelineRoot.getChild("consequence").getChildren();
    for (Element consequenceElement : consequenceElements) {
        DSConsequence dsConsequence = new DSConsequence();

        String consequenceTypeStr = consequenceElement.getName();
        DSConsequence.ConsequenceType consequenceType = null;
        //try to resolve type
        try {
            consequenceType = DSConsequence.ConsequenceType.valueOf(consequenceTypeStr.toLowerCase());
        } catch (IllegalArgumentException iae) {
            String knownTypes = StringUtils.join(DSConsequence.ConsequenceType.values(), ",");
            throw new DecisionSupportParseException(guidelineTitle,
                    "Unknown consequence: " + consequenceTypeStr + ". Allowed: " + knownTypes, iae);
        }
        dsConsequence.setConsequenceType(consequenceType);

        if (consequenceType == DSConsequence.ConsequenceType.warning) {
            String strengthStr = consequenceElement.getAttributeValue("strength");
            if (strengthStr == null) {
                strengthStr = "warning";
            }
            DSConsequence.ConsequenceStrength strength = null;
            //try to resolve strength type
            try {
                strength = DSConsequence.ConsequenceStrength.valueOf(strengthStr.toLowerCase());
                dsConsequence.setConsequenceStrength(strength);
            } catch (IllegalArgumentException iae) {
                String knownStrengths = StringUtils.join(DSConsequence.ConsequenceStrength.values(), ",");
                throw new DecisionSupportParseException(guidelineTitle,
                        "Unknown strength: " + strengthStr + ". Allowed: " + knownStrengths, iae);
            }
        }
        dsConsequence.setText(consequenceElement.getText());
        dsConsequences.add(dsConsequence);
    }
    dsGuideline.setConsequences(dsConsequences);
    dsGuideline.setXml(xml);
    dsGuideline.setParsed(true);
    //populate consequence here
    return dsGuideline;
}

From source file:net.ustyugov.jtalk.service.JTalkService.java

public void leaveAllRooms(String account) {
    Hashtable<String, MultiUserChat> hash = conferences.get(account);
    if (!hash.isEmpty()) {
        Enumeration<String> groups = hash.keys();
        while (groups.hasMoreElements()) {
            String group = groups.nextElement();
            MultiUserChat muc = hash.get(group);
            writeMucMessage(account, group, muc.getNickname(), getString(R.string.YouLeave));
            try {
                if (muc.isJoined()) {
                    muc.leave();//www .j av  a  2  s  .  c o m
                }
            } catch (IllegalStateException ignored) {
            }
        }
    }
    Intent updateIntent = new Intent(Constants.PRESENCE_CHANGED);
    sendBroadcast(updateIntent);
}

From source file:org.kepler.ddp.actor.ExecutionChoice.java

/** Remove a port or parameter from the documentation. */
private void _removeInDocumentation(String name) throws Exception {

    List<KeplerDocumentationAttribute> docList = attributeList(KeplerDocumentationAttribute.class);
    for (KeplerDocumentationAttribute docAttribute : docList) {

        // see if the hash tables have been initialized
        Hashtable<?, ?> portHash = docAttribute.getPortHash();
        if (portHash.isEmpty()) {
            docAttribute.createInstanceFromExisting(docAttribute);
        }/*from   ww w . ja  v  a2s .  c  o m*/

        docAttribute.removePort(name);
        docAttribute.removeProperty(name);
    }
}

From source file:org.kepler.ddp.actor.ExecutionChoice.java

/** Rename a port and parameter in the documentation. */
private void _renameInDocumentation(String oldName, String newName) throws Exception {

    List<KeplerDocumentationAttribute> docList = attributeList(KeplerDocumentationAttribute.class);
    for (KeplerDocumentationAttribute docAttribute : docList) {

        // see if the hash tables have been initialized
        Hashtable<?, ?> portHash = docAttribute.getPortHash();
        if (portHash.isEmpty()) {
            docAttribute.createInstanceFromExisting(docAttribute);
        }/*from w  w  w  . j a v a 2 s .c o m*/

        String portDocStr = docAttribute.getPort(oldName);
        if (portDocStr != null) {
            docAttribute.removePort(oldName);
            docAttribute.addPort(newName, portDocStr);
        }

        String parameterDocStr = docAttribute.getProperty(oldName);
        if (parameterDocStr != null) {
            docAttribute.removeProperty(oldName);
            docAttribute.addProperty(newName, parameterDocStr);
        }
    }
}