Java Code Examples for java.util.Hashtable.isEmpty()

The following are Jave code examples for showing how to use isEmpty() of the java.util.Hashtable class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: SCDynamicStoreConfig.java   View Source Code Vote up 6 votes
@SuppressWarnings("unchecked")
private static Hashtable<String, Object> convertNativeConfig(
        Hashtable<String, Object> stanzaTable) throws IOException {
    // convert SCDynamicStore realm structure to Java realm structure
    Hashtable<String, ?> realms =
            (Hashtable<String, ?>) stanzaTable.get("realms");
    if (realms == null || realms.isEmpty()) {
        throw new IOException(
                "SCDynamicStore contains an empty Kerberos setting");
    }
    stanzaTable.remove("realms");
    Hashtable<String, Object> realmsTable = convertRealmConfigs(realms);
    stanzaTable.put("realms", realmsTable);
    WrapAllStringInVector(stanzaTable);
    if (DEBUG) System.out.println("stanzaTable : " + stanzaTable);
    return stanzaTable;
}
 
Example 2
Project: openjdk-jdk10   File: AttributeValues.java   View Source Code Vote up 6 votes
public static AttributeValues
fromSerializableHashtable(Hashtable<Object, Object> ht)
{
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e: ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer)val).intValue());
            } else {
                try {
                    EAttribute ea =
                        EAttribute.forAttribute((Attribute)key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                }
                catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
 
Example 3
Project: OpenJSharp   File: AttributeValues.java   View Source Code Vote up 6 votes
public static AttributeValues
fromSerializableHashtable(Hashtable<Object, Object> ht)
{
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e: ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer)val).intValue());
            } else {
                try {
                    EAttribute ea =
                        EAttribute.forAttribute((Attribute)key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                }
                catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
 
Example 4
Project: jdk8u-jdk   File: AttributeValues.java   View Source Code Vote up 6 votes
public static AttributeValues
fromSerializableHashtable(Hashtable<Object, Object> ht)
{
    AttributeValues result = new AttributeValues();
    if (ht != null && !ht.isEmpty()) {
        for (Map.Entry<Object, Object> e: ht.entrySet()) {
            Object key = e.getKey();
            Object val = e.getValue();
            if (key.equals(DEFINED_KEY)) {
                result.defineAll(((Integer)val).intValue());
            } else {
                try {
                    EAttribute ea =
                        EAttribute.forAttribute((Attribute)key);
                    if (ea != null) {
                        result.set(ea, val);
                    }
                }
                catch (ClassCastException ex) {
                }
            }
        }
    }
    return result;
}
 
Example 5
Project: logistimo-web-service   File: RESTUtil.java   View Source Code Vote up 5 votes
protected static Hashtable<String, Hashtable<String, String>> getMaterialStatus(
    InventoryConfig ic) {
  Hashtable<String, Hashtable<String, String>> mStHt = new Hashtable<>(1);
  Map<String, MatStatusConfig> mStMap = ic.getMatStatusConfigMapByType();
  if (mStMap != null && !mStMap.isEmpty()) {
    Set<String> transTypes = mStMap.keySet();
    if (!transTypes.isEmpty()) {
      for (String transType : transTypes) {
        MatStatusConfig mStConfig = mStMap.get(transType);
        Hashtable<String, String> mTyStHt = new Hashtable<>();
        if (mStConfig != null) {
          if(mStConfig.getDf() !=null) {
            String df = StringUtil.getUniqueValueCSV(mStConfig.getDf());
            if (StringUtils.isNotEmpty(df)) {
              mTyStHt.put(JsonTagsZ.ALL, df);
            }
          }
          if(mStConfig.getEtsm() != null) {
            String etsm = StringUtil.getUniqueValueCSV(mStConfig.getEtsm());
            if (StringUtils.isNotEmpty(etsm)) {
              mTyStHt.put(JsonTagsZ.TEMP_SENSITVE_MATERIALS, etsm);
            }
          }
          if (!mTyStHt.isEmpty()) {
            mTyStHt.put(JsonTagsZ.MANDATORY, String.valueOf(mStConfig.isStatusMandatory()));
            mStHt.put(transType, mTyStHt);
          }
        }
      }
    }
  }
  return mStHt;
}
 
Example 6
Project: Proyecto-DASI   File: TablaEstadosControl.java   View Source Code Vote up 5 votes
/**
 *  Expresa la tabla en texto
 *
 *@return    Texto con la tabla de estados
 */
public String toString()
{
	String dev = "LEYENDA:   Estado: input/accion -> estado siguiente";
	dev += "\n------------------------------------------------------";
	java.util.Enumeration nombres = clasificacionEstados.keys();

	String input = "";
	String accion = "";
	String estsig = "";
	String id = "";
	while (nombres.hasMoreElements())
	{
		id = (String) nombres.nextElement();

		Hashtable inp = (Hashtable) inputsDeEstados.get(id);
		if (!inp.isEmpty())
		{
			java.util.Enumeration inps = inp.keys();
			while (inps.hasMoreElements())
			{
				input = (String) inps.nextElement();
				Operacion op = (Operacion) inp.get(input);
				accion = op.accionSemantica;
				estsig = op.estadoSiguiente;
				dev += "\n" + id + ": " + input + " / " + accion + " -> " + estsig;
			}

		}
		else
		{
			dev += "\n" + id + " <- ES UN ESTADO FINAL";
		}

	}
	return dev += "\n------------------------------------------------------";
}
 
Example 7
Project: unitimes   File: ProjectedStudentCourseDemands.java   View Source Code Vote up 5 votes
@Override
public float getProjection(String areaAbbv, String clasfCode, String majorCode) {
	if (iAreaClasfMajor2Proj.isEmpty()) return 1.0f;
	Hashtable<String,Hashtable<String, Float>> clasf2major2proj = (areaAbbv == null ? null : iAreaClasfMajor2Proj.get(areaAbbv));
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	Hashtable<String, Float> major2proj = (clasfCode == null ? null : clasf2major2proj.get(clasfCode));
	if (major2proj == null) return 1.0f;
	Float projection = (majorCode == null ? null : major2proj.get(majorCode));
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
Example 8
Project: unitimes   File: CurriculaCourseDemands.java   View Source Code Vote up 5 votes
public Set<WeightedStudentId> getDemands(CourseOffering course) {
	if (iDemands.isEmpty()) return iFallback.getDemands(course);
	Set<WeightedStudentId> demands = iDemands.get(course.getUniqueId());
	if (!iIncludeOtherStudents) return demands;
	if (demands == null) {
		demands = new HashSet<WeightedStudentId>();
		iDemands.put(course.getUniqueId(), demands);
	}
	if (iCheckedCourses.add(course.getUniqueId())) {
		int was = demands.size();
		Hashtable<String,Set<String>> curricula = iLoadedCurricula.get(course.getUniqueId());
		Set<WeightedStudentId> other = iFallback.getDemands(course);
		if (curricula == null || curricula.isEmpty()) {
			demands.addAll(other);
		} else {
			other: for (WeightedStudentId student: other) {
				// if (student.getMajors().isEmpty()) continue; // ignore students w/o academic area
				for (AreaClasfMajor acm: student.getMajors()) {
					Set<String> majors = curricula.get(acm.getArea());
					if (majors != null && (majors.contains("") || student.match(acm.getArea(), majors))) continue other; // all majors or match
				}
				demands.add(student);
			}
		}
		if (demands.size() > was)
			sLog.info(course.getCourseName() + " has " + (demands.size() - was) + " other students (besides of the " + was + " curriculum students).");
	}
	return demands;
}
 
Example 9
Project: unitimes   File: CurriculaServlet.java   View Source Code Vote up 5 votes
public float getProjection(Hashtable<String,HashMap<String, Float>> clasf2major2proj, String majorCode, String clasfCode) {
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	HashMap<String, Float> major2proj = clasf2major2proj.get(clasfCode);
	if (major2proj == null) return 1.0f;
	Float projection = major2proj.get(majorCode);
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
Example 10
Project: unitimes   File: CurriculaServlet.java   View Source Code Vote up 5 votes
public float getSnapshotProjection(Hashtable<String, HashMap<String, Float>> clasf2major2ssproj, String majorCode,
		String clasfCode) {
	if (clasf2major2ssproj == null || clasf2major2ssproj.isEmpty())
		return 1.0f;
	HashMap<String, Float> major2ssproj = clasf2major2ssproj.get(clasfCode);
	if (major2ssproj == null)
		return 1.0f;
	Float snapshotProjection = major2ssproj.get(majorCode);
	if (snapshotProjection == null)
		snapshotProjection = major2ssproj.get("");
	return (snapshotProjection == null ? 1.0f : snapshotProjection);
}
 
Example 11
Project: unitimes   File: ReservationServlet.java   View Source Code Vote up 5 votes
private float getProjection(Hashtable<String,HashMap<String, Float>> clasf2major2proj, String majorCode, String clasfCode) {
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	HashMap<String, Float> major2proj = clasf2major2proj.get(clasfCode);
	if (major2proj == null) return 1.0f;
	Float projection = major2proj.get(majorCode);
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
Example 12
Project: unitimes   File: MakeCurriculaFromLastlikeDemands.java   View Source Code Vote up 5 votes
public float getProjection(Hashtable<String,Hashtable<String, Float>> clasf2major2proj, String majorCode, String clasfCode) {
	if (clasf2major2proj == null || clasf2major2proj.isEmpty()) return 1.0f;
	Hashtable<String, Float> major2proj = clasf2major2proj.get(clasfCode);
	if (major2proj == null) return 1.0f;
	Float projection = major2proj.get(majorCode);
	if (projection == null)
		projection = major2proj.get("");
	return (projection == null ? 1.0f : projection);
}
 
Example 13
Project: OpenJSharp   File: CoreDocumentImpl.java   View Source Code Vote up 5 votes
/**
 * Call user data handlers when a node is deleted (finalized)
 * @param n The node this operation applies to.
 * @param c The copy node or null.
 * @param operation The operation - import, clone, or delete.
 */
void callUserDataHandlers(Node n, Node c, short operation) {
    if (userData == null) {
        return;
    }
    //Hashtable t = (Hashtable) userData.get(n);
            if(n instanceof NodeImpl){
                    Hashtable t = ((NodeImpl)n).getUserDataRecord();
                    if (t == null || t.isEmpty()) {
                            return;
                    }
                    callUserDataHandlers(n, c, operation,t);
            }
}
 
Example 14
Project: OpenJSharp   File: CoreDocumentImpl.java   View Source Code Vote up 5 votes
/**
 * Call user data handlers when a node is deleted (finalized)
 * @param n The node this operation applies to.
 * @param c The copy node or null.
 * @param operation The operation - import, clone, or delete.
     * @param handlers Data associated with n.
    */
    void callUserDataHandlers(Node n, Node c, short operation,Hashtable userData) {
    if (userData == null || userData.isEmpty()) {
        return;
    }
    Enumeration keys = userData.keys();
    while (keys.hasMoreElements()) {
        String key = (String) keys.nextElement();
        UserDataRecord r = (UserDataRecord) userData.get(key);
        if (r.fHandler != null) {
            r.fHandler.handle(operation, key, r.fData, n, c);
        }
    }
}
 
Example 15
Project: logistimo-web-service   File: RESTUtil.java   View Source Code Vote up 4 votes
private static Hashtable<String, Hashtable<String, String>> getReasonsByTag(InventoryConfig ic) {
  Hashtable<String, Hashtable<String, String>> rsnsByMtag = new Hashtable<>(1);
  // For Issue
  Map<String, String> iMtagReasons = ic.getImTransReasons();
  if (iMtagReasons != null && !iMtagReasons.isEmpty()) {
    Hashtable<String, String> iMtagReasonsHt = getHashtableFromMap(iMtagReasons);
    if (iMtagReasonsHt != null && !iMtagReasonsHt.isEmpty()) {
      rsnsByMtag.put(JsonTagsZ.ISSUES, iMtagReasonsHt);
    }
  }
  // For Receipt
  Map<String, String> rMtagReasons = ic.getRmTransReasons();
  if (rMtagReasons != null && !rMtagReasons.isEmpty()) {
    Hashtable<String, String> rMTagReasonsHt = getHashtableFromMap(rMtagReasons);
    if (rMTagReasonsHt != null && !rMTagReasonsHt.isEmpty()) {
      rsnsByMtag.put(JsonTagsZ.RECEIPTS, rMTagReasonsHt);
    }
  }
  // For Physical stock count
  Map<String, String> scMtagReasons = ic.getSmTransReasons();
  if (scMtagReasons != null && !scMtagReasons.isEmpty()) {
    Hashtable<String, String> scMTagReasonsHt = getHashtableFromMap(scMtagReasons);
    if (scMTagReasonsHt != null && !scMTagReasonsHt.isEmpty()) {
      rsnsByMtag.put(JsonTagsZ.PHYSICAL_STOCK, scMTagReasonsHt);
    }
  }
  // For Wastage/Discards
  Map<String, String> wMtagReasons = ic.getDmTransReasons();
  if (wMtagReasons != null && !wMtagReasons.isEmpty()) {
    Hashtable<String, String> wMTagReasonsHt = getHashtableFromMap(wMtagReasons);
    if (wMTagReasonsHt != null && !wMTagReasonsHt.isEmpty()) {
      rsnsByMtag.put(JsonTagsZ.DISCARDS, wMTagReasonsHt);
    }
  }
  // For Transfer
  Map<String, String> tMtagReasons = ic.getTmTransReasons();
  if (tMtagReasons != null && !tMtagReasons.isEmpty()) {
    Hashtable<String, String> tMTagReasonsHt = getHashtableFromMap(tMtagReasons);
    if (tMTagReasonsHt != null && !tMTagReasonsHt.isEmpty()) {
      rsnsByMtag.put(JsonTagsZ.TRANSFER, tMTagReasonsHt);
    }
  }

  return rsnsByMtag;
}
 
Example 16
Project: logistimo-web-service   File: GetOrdersOutput.java   View Source Code Vote up 4 votes
public Vector toMessageString() throws ProtocolException {
  String msg = version + " " + statusCode;
  if (!status) {
    if (errMsg == null) {
      if (hasOrders) {
        if (orders == null || orders.isEmpty()) {
          errMsg = protoMessages.getString("error.noorders");
        }
      } else {
        if (materials == null || materials.isEmpty()) {
          errMsg = protoMessages.getString("error.nomaterials");
        }
      }
    }
    msg += " " + MessageUtil.encode(errMsg);
  } else {
    if (hasOrders) {
      msg += " " + MODE_ORDER;
      int numOrders = orders.size();
      msg += " " + numOrders;
      Enumeration en = orders.elements();
      while (en.hasMoreElements()) {
        Hashtable ord = (Hashtable) en.nextElement();
        if (ord == null || ord.isEmpty()) {
          throw new ProtocolException(protoMessages.getString("error.noorder"));
        }
        msg += " " + MessageUtil.getOrderString(ord, version);
      }
    } else {
      msg += " " + MODE_DEMAND;
      String cur = MessageUtil.DUMMY;
      if (currency != null && currency.length() > 0) {
        cur = currency;
      }
      msg += " " + cur; // currency
      ////int numMaterials = materials.size();
      ////msg += " " + numMaterials; // num. materials
      msg +=
          " " + MessageUtil
              .getMaterialsString(materials, MessageUtil.QUANTITY_AND_PRICE, true); // materials
    }
  }
  return MessageUtil.split(msg, getMessageId());
}
 
Example 17
Project: logistimo-web-service   File: MessageUtil.java   View Source Code Vote up 4 votes
public static String getOrderString(Hashtable order, String version) throws ProtocolException {
  if (order == null || order.isEmpty()) {
    throw new ProtocolException("No order specified");
  }
  String msg = (String) order.get(JsonTagsZ.TRACKING_ID) + SEP2 +
      (String) order.get(JsonTagsZ.ORDER_STATUS) + SEP2 +
      (String) order.get(JsonTagsZ.QUANTITY) + SEP2 +
      encode((String) order.get(JsonTagsZ.TIMESTAMP));
  String value = null;
  if ((value = (String) order.get(JsonTagsZ.UPDATED_TIME)) != null && !value.equals("")) {
    msg += SEP2 + encode(value);
  } else {
    msg += SEP2 + DUMMY;
  }
  if ((value = (String) order.get(JsonTagsZ.TOTAL_PRICE)) != null && !value.equals("")) {
    msg += SEP2 + value;
  } else {
    msg += SEP2 + DUMMY;
  }
  if ((value = (String) order.get(JsonTagsZ.CURRENCY)) != null && !value.equals("")) {
    msg += SEP2 + value;
  } else {
    msg += SEP2 + DUMMY;
  }
  if ((value = (String) order.get(JsonTagsZ.MESSAGE)) != null && !value.equals("")) {
    msg += SEP2 + encode(value);
  } else {
    msg += SEP2 + DUMMY;
  }
  if (Integer.parseInt(version) >= Integer
      .parseInt(MessageHeader.VERSION02)) { // MessageHeader.VERSION02.equals( version ) ) {
    // Vendor ID
    if ((value = (String) order.get(JsonTagsZ.VENDORID)) != null && !value.equals("")) {
      msg += SEP2 + value;
    } else {
      msg += SEP2 + DUMMY;
    }
  }
  if (Integer.parseInt(version) >= Integer
      .parseInt(MessageHeader.VERSION05)) { // version 05 onwards
    // Discount
    if ((value = (String) order.get(JsonTagsZ.DISCOUNT)) != null && !value.equals("")) {
      msg += SEP2 + value;
    } else {
      msg += SEP2 + DUMMY;
    }
  }
  if (Integer.parseInt(version) >= Integer
      .parseInt(MessageHeader.VERSION06)) { // version 06 onwards
    // Kiosk Id (Customer)
    if ((value = (String) order.get(JsonTagsZ.KIOSK_ID)) != null && !value.equals("")) {
      msg += SEP2 + value;
    } else {
      msg += SEP2 + DUMMY;
    }
  }
  // Add materials
  msg +=
      SEP2 + getMaterialsString((Vector) order.get(JsonTagsZ.MATERIALS), QUANTITY_AND_PRICE,
          true);
  // Split message
  return msg;
}
 
Example 18
Project: unitimes   File: JenrlInfo.java   View Source Code Vote up 4 votes
public JenrlInfo(Solver solver, JenrlConstraint jc) {
	super();
	Assignment<Lecture, Placement> assignment = solver.currentSolution().getAssignment();
	TimetableModel model = (TimetableModel)solver.currentSolution().getModel();
	Lecture first = (Lecture)jc.first();
	Placement firstPl = (Placement)assignment.getValue(first);
	Lecture second = (Lecture)jc.second();
	Placement secondPl = (Placement)assignment.getValue(second);
	if (solver!=null) {
		if (firstPl!=null)
			iFirst = new ClassAssignmentDetails(solver,first,firstPl,false);
		if (secondPl!=null)
			iSecond = new ClassAssignmentDetails(solver,second,secondPl,false);
	}
	if (firstPl==null || secondPl==null) return;
	setJenrl(jc.getJenrl());
	setIsSatisfied(jc.isInConflict(assignment));
	if (jc.isInConflict(assignment)) {
		setIsHard(first.areStudentConflictsHard(second));
		setIsFixed(first.nrTimeLocations()==1 && second.nrTimeLocations()==1);
		setIsDistance(!firstPl.getTimeLocation().hasIntersection(secondPl.getTimeLocation()));
		setIsCommited(jc.areStudentConflictsCommitted());
		if (isDistance())
			setDistance(Placement.getDistanceInMeters(model.getDistanceMetric(),firstPl,secondPl));
		StudentConflict imp = (StudentConflict)model.getCriterion(ImportantStudentConflict.class);
		setIsImportant(imp != null && imp.isApplicable(first, second) && imp.inConflict(firstPl, secondPl));
		setIsInstructor(jc.getNrInstructors() > 0);
	}
	Hashtable<String, Double> curriculum2nrStudents = new Hashtable<String, Double>();
	for (Student student: jc.first().sameStudents(jc.second())) {
		if (student.getCurriculum() == null || student.getCurriculum().isEmpty()) continue;
		for (String c: student.getCurriculum().split("\\|")) {
			Double nrStudents = curriculum2nrStudents.get(c);
			curriculum2nrStudents.put(student.getCurriculum(), jc.getJenrlWeight(student) + (nrStudents == null ? 0.0 : nrStudents));
		}
	}
	if (!curriculum2nrStudents.isEmpty()) {
		iCurriculum2nrStudents = new TreeSet<CurriculumInfo>();
		for (Map.Entry<String, Double> entry: curriculum2nrStudents.entrySet()) {
			iCurriculum2nrStudents.add(new CurriculumInfo(entry.getKey(), entry.getValue()));
		}
	}
}
 
Example 19
Project: OpenJSharp   File: FeatureDescriptor.java   View Source Code Vote up 2 votes
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}
 
Example 20
Project: jdk8u-jdk   File: FeatureDescriptor.java   View Source Code Vote up 2 votes
/**
 * Copies all values from the specified attribute table.
 * If some attribute is exist its value should be overridden.
 *
 * @param table  the attribute table with new values
 */
private void addTable(Hashtable<String, Object> table) {
    if ((table != null) && !table.isEmpty()) {
        getTable().putAll(table);
    }
}