下面列出了java.util.Hashtable#get ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public Component getCellRendererComponent(Component list, Object model, Object value, int index, boolean isSelected) {
Hashtable v = (Hashtable) value;
setText((String)v.get("name"));
Image im = (Image)v.get("pic");
String id = (String)v.get("id");
if(im == null && id != null && v.get("fetching") == null){
v.put("fetching", Boolean.TRUE);
try {
FaceBookAccess.getInstance().getPicture(id, (List)list, index, "pic", imageSize, true);
} catch (IOException ex) {
ex.printStackTrace();
}
}else{
setIcon(im);
}
return this;
}
DigestClientId(int version, String hostname, int port,
String protocol, Control[] bindCtls, OutputStream trace,
String socketFactory, String username,
Object passwd, Hashtable<?,?> env) {
super(version, hostname, port, protocol, bindCtls, trace,
socketFactory, username, passwd);
if (env == null) {
propvals = null;
} else {
// Could be smarter and apply default values for props
// but for now, we just record and check exact matches
propvals = new String[SASL_PROPS.length];
for (int i = 0; i < SASL_PROPS.length; i++) {
propvals[i] = (String) env.get(SASL_PROPS[i]);
}
}
myHash = super.hashCode() ^ Arrays.hashCode(propvals);
}
public Context getInitialContext( final Hashtable environment ) throws NamingException {
final Hashtable hashtable = new Hashtable();
if ( environment != null ) {
hashtable.putAll( environment );
}
final String o = (String) hashtable.get( "java.naming.factory.initial" );
if ( StringUtils.isEmpty( o ) == false && DebugJndiContextFactory.class.getName().equals( o ) == false ) {
final InitialContextFactory contextFactory =
ObjectUtilities.loadAndInstantiate( o, DebugJndiContextFactory.class, InitialContextFactory.class );
return contextFactory.getInitialContext( environment );
}
hashtable.put( JndiLoader.SIMPLE_DELIMITER, "/" );
try {
final File directory = GoldenSampleGenerator.findMarker();
final File jndi = new File( directory, "jndi" );
if ( jndi != null ) {
hashtable.put( SimpleContext.SIMPLE_ROOT, jndi.getAbsolutePath() );
}
} catch ( SecurityException se ) {
// ignore ..
}
return new SimpleContext( hashtable );
}
/**
* Removes a component listener bound to a specific component
*
* @param formName the name of the form
* @param componentName the name of the component
* @param listener the listener instance
*/
public void removeComponentListener(String formName, String componentName, Object listener) {
if(localComponentListeners == null) {
return;
}
Hashtable formListeners = (Hashtable)localComponentListeners.get(formName);
if(formListeners == null) {
return;
}
Object currentListeners = formListeners.get(componentName);
if(currentListeners == null) {
return;
} else {
if(currentListeners instanceof Vector) {
((Vector)currentListeners).removeElement(listener);
if(((Vector)currentListeners).size() == 0) {
formListeners.remove(componentName);
}
} else {
formListeners.remove(componentName);
}
}
}
private Hashtable<String,Hashtable<String, Float>> getRules(org.hibernate.Session hibSession, Long acadAreaId) {
Hashtable<String,Hashtable<String, Float>> clasf2major2proj = new Hashtable<String, Hashtable<String,Float>>();
for (CurriculumProjectionRule rule: (List<CurriculumProjectionRule>)hibSession.createQuery(
"select r from CurriculumProjectionRule r where r.academicArea.uniqueId=:acadAreaId")
.setLong("acadAreaId", acadAreaId).setCacheable(true).list()) {
String majorCode = (rule.getMajor() == null ? "" : rule.getMajor().getCode());
String clasfCode = rule.getAcademicClassification().getCode();
Float projection = rule.getProjection();
Hashtable<String, Float> major2proj = clasf2major2proj.get(clasfCode);
if (major2proj == null) {
major2proj = new Hashtable<String, Float>();
clasf2major2proj.put(clasfCode, major2proj);
}
major2proj.put(majorCode, projection);
}
return clasf2major2proj;
}
@SuppressWarnings("unchecked")
private static Hashtable<String, Object> convertNativeConfig(
Hashtable<String, Object> stanzaTable) {
// convert SCDynamicStore realm structure to Java realm structure
Hashtable<String, ?> realms =
(Hashtable<String, ?>) stanzaTable.get("realms");
if (realms != null) {
stanzaTable.remove("realms");
Hashtable<String, Object> realmsTable = convertRealmConfigs(realms);
stanzaTable.put("realms", realmsTable);
}
WrapAllStringInVector(stanzaTable);
if (DEBUG) System.out.println("stanzaTable : " + stanzaTable);
return stanzaTable;
}
public Vector<String> matchesAdditionalGeneratedPath(String fullPath) {
Vector<String> rv = new Vector<String>();
Hashtable<String, String> v = (Hashtable<String, String>)BuildConfig.getField(this.toString(), "AdditionalGeneratedFile");
if (v != null) {
for (Enumeration<String> e=v.keys(); e.hasMoreElements(); ) {
String key = e.nextElement();
String val = v.get(key);
if (fullPath.endsWith(expandFormat(key))) {
rv.add(expandFormat(val));
}
}
}
return rv;
}
protected Hashtable<String, int[]> getClassifications() {
Hashtable<String, int[]> cnt = new Hashtable<String, int[]>();
for (CurriculumCourse c: iCourses) {
int[] other = cnt.get(c.getClassification().getName());
cnt.put(c.getClassification().getName(), new int[] {
Math.round(c.getPercShare() * c.getClassification().getNrStudents()) + (other == null ? 0 : other[0]),
c.getClassification().getNrStudents() + (other == null ? 0 : other[1])});
}
return cnt;
}
float getValue(boolean w3cLengthUnits) {
Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
float scale = 1;
if (units != null) {
Float scaleFloat = mapping.get(units);
if (scaleFloat != null) {
scale = scaleFloat.floatValue();
}
}
return this.value * scale;
}
/**
* Parses a query string passed from the client to the
* server and builds a <code>HashTable</code> object
* with key-value pairs.
* The query string should be in the form of a string
* packaged by the GET or POST method, that is, it
* should have key-value pairs in the form <i>key=value</i>,
* with each pair separated from the next by a & character.
*
* <p>A key can appear more than once in the query string
* with different values. However, the key appears only once in
* the hashtable, with its value being
* an array of strings containing the multiple values sent
* by the query string.
*
* <p>The keys and values in the hashtable are stored in their
* decoded form, so
* any + characters are converted to spaces, and characters
* sent in hexadecimal notation (like <i>%xx</i>) are
* converted to ASCII characters.
*
* @param s a string containing the query to be parsed
*
* @return a <code>HashTable</code> object built
* from the parsed key-value pairs
*
* @exception IllegalArgumentException if the query string is invalid
*/
public static Hashtable<String, String[]> parseQueryString(String s) {
String valArray[] = null;
if (s == null) {
throw new IllegalArgumentException();
}
Hashtable<String, String[]> ht = new Hashtable<String, String[]>();
StringBuilder sb = new StringBuilder();
StringTokenizer st = new StringTokenizer(s, "&");
while (st.hasMoreTokens()) {
String pair = st.nextToken();
int pos = pair.indexOf('=');
if (pos == -1) {
// XXX
// should give more detail about the illegal argument
throw new IllegalArgumentException();
}
String key = parseName(pair.substring(0, pos), sb);
String val = parseName(pair.substring(pos+1, pair.length()), sb);
if (ht.containsKey(key)) {
String oldVals[] = ht.get(key);
valArray = new String[oldVals.length + 1];
for (int i = 0; i < oldVals.length; i++) {
valArray[i] = oldVals[i];
}
valArray[oldVals.length] = val;
} else {
valArray = new String[1];
valArray[0] = val;
}
ht.put(key, valArray);
}
return ht;
}
/**
* Check statement
*/
Vset check(Environment env, Context ctx, Vset vset, Hashtable exp) {
checkLabel(env, ctx);
try {
vset = reach(env, vset);
expr.checkValue(env, ctx, vset, exp);
if (expr.type.isType(TC_CLASS)) {
ClassDeclaration c = env.getClassDeclaration(expr.type);
if (exp.get(c) == null) {
exp.put(c, this);
}
ClassDefinition def = c.getClassDefinition(env);
ClassDeclaration throwable =
env.getClassDeclaration(idJavaLangThrowable);
if (!def.subClassOf(env, throwable)) {
env.error(where, "throw.not.throwable", def);
}
expr = convert(env, ctx, Type.tObject, expr);
} else if (!expr.type.isType(TC_ERROR)) {
env.error(expr.where, "throw.not.throwable", expr.type);
}
} catch (ClassNotFound e) {
env.error(where, "class.not.found", e.name, opNames[op]);
}
CheckContext exitctx = ctx.getTryExitContext();
if (exitctx != null) {
exitctx.vsTryExit = exitctx.vsTryExit.join(vset);
}
return DEAD_END;
}
@SuppressWarnings("unchecked")
private static void WrapAllStringInVector(
Hashtable<String, Object> stanzaTable) {
for (String s: stanzaTable.keySet()) {
Object v = stanzaTable.get(s);
if (v instanceof Hashtable) {
WrapAllStringInVector((Hashtable<String,Object>)v);
} else if (v instanceof String) {
Vector<String> vec = new Vector<>();
vec.add((String)v);
stanzaTable.put(s, vec);
}
}
}
public static boolean isAttribute (String name, Hashtable symbolTable)
{
SymtabEntry entry = (SymtabEntry)symbolTable.get (name);
return entry == null ? false : entry instanceof AttributeEntry;
}
/**
* Set any DocumentBuilderFactory attributes of our underlying DOMParser
*
* Note: code does not handle possible conflicts between DOMParser
* attribute names and JAXP specific attribute names,
* eg. DocumentBuilderFactory.setValidating()
*/
private void setDocumentBuilderFactoryAttributes(Hashtable dbfAttrs)
throws SAXNotSupportedException, SAXNotRecognizedException
{
if (dbfAttrs == null) {
// Nothing to do
return;
}
Iterator entries = dbfAttrs.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry entry = (Map.Entry) entries.next();
String name = (String) entry.getKey();
Object val = entry.getValue();
if (val instanceof Boolean) {
// Assume feature
domParser.setFeature(name, ((Boolean)val).booleanValue());
} else {
// Assume property
if (JAXP_SCHEMA_LANGUAGE.equals(name)) {
// JAXP 1.2 support
//None of the properties will take effect till the setValidating(true) has been called
if ( W3C_XML_SCHEMA.equals(val) ) {
if( isValidating() ) {
domParser.setFeature(XMLSCHEMA_VALIDATION_FEATURE, true);
// this should allow us not to emit DTD errors, as expected by the
// spec when schema validation is enabled
domParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
}
}
} else if(JAXP_SCHEMA_SOURCE.equals(name)){
if( isValidating() ) {
String value=(String)dbfAttrs.get(JAXP_SCHEMA_LANGUAGE);
if(value !=null && W3C_XML_SCHEMA.equals(value)){
domParser.setProperty(name, val);
}else{
throw new IllegalArgumentException(
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN,
"jaxp-order-not-supported",
new Object[] {JAXP_SCHEMA_LANGUAGE, JAXP_SCHEMA_SOURCE}));
}
}
} else {
//check if the property is managed by security manager
if (fSecurityManager == null ||
!fSecurityManager.setLimit(name, XMLSecurityManager.State.APIPROPERTY, val)) {
//check if the property is managed by security property manager
if (fSecurityPropertyMgr == null ||
!fSecurityPropertyMgr.setValue(name, XMLSecurityPropertyManager.State.APIPROPERTY, val)) {
//fall back to the existing property manager
domParser.setProperty(name, val);
}
}
}
}
}
}
private static String getInitCtxUrl(Hashtable<?,?> env) {
String url = (String) env.get(Context.PROVIDER_URL);
return ((url != null) ? url : DEFAULT_URL);
}
/**
* Dump a basic Xalan environment report to outWriter.
*
* <p>This dumps a simple header and then each of the entries in
* the Hashtable to our PrintWriter; it does special processing
* for entries that are .jars found in the classpath.</p>
*
* @param h Hashtable of items to report on; presumably
* filled in by our various check*() methods
* @return true if your environment appears to have no major
* problems; false if potential environment problems found
* @see #appendEnvironmentReport(Node, Document, Hashtable)
* for an equivalent that appends to a Node instead
*/
protected boolean writeEnvironmentReport(Hashtable h)
{
if (null == h)
{
logMsg("# ERROR: writeEnvironmentReport called with null Hashtable");
return false;
}
boolean errors = false;
logMsg(
"#---- BEGIN writeEnvironmentReport($Revision: 1.10 $): Useful stuff found: ----");
// Fake the Properties-like output
for (Enumeration keys = h.keys();
keys.hasMoreElements();
/* no increment portion */
)
{
Object key = keys.nextElement();
String keyStr = (String) key;
try
{
// Special processing for classes found..
if (keyStr.startsWith(FOUNDCLASSES))
{
Vector v = (Vector) h.get(keyStr);
errors |= logFoundJars(v, keyStr);
}
// ..normal processing for all other entries
else
{
// Note: we could just check for the ERROR key by itself,
// since we now set that, but since we have to go
// through the whole hash anyway, do it this way,
// which is safer for maintenance
if (keyStr.startsWith(ERROR))
{
errors = true;
}
logMsg(keyStr + "=" + h.get(keyStr));
}
}
catch (Exception e)
{
logMsg("Reading-" + key + "= threw: " + e.toString());
}
}
logMsg(
"#----- END writeEnvironmentReport: Useful properties found: -----");
return errors;
}
public boolean registerFont(Font font) {
/* This method should not be called with "null".
* It is the caller's responsibility to ensure that.
*/
if (font == null) {
return false;
}
/* Initialise these objects only once we start to use this API */
synchronized (regFamilyKey) {
if (createdByFamilyName == null) {
createdByFamilyName = new Hashtable<String,FontFamily>();
createdByFullName = new Hashtable<String,Font2D>();
}
}
if (! FontAccess.getFontAccess().isCreatedFont(font)) {
return false;
}
/* We want to ensure that this font cannot override existing
* installed fonts. Check these conditions :
* - family name is not that of an installed font
* - full name is not that of an installed font
* - family name is not the same as the full name of an installed font
* - full name is not the same as the family name of an installed font
* The last two of these may initially look odd but the reason is
* that (unfortunately) Font constructors do not distinuguish these.
* An extreme example of such a problem would be a font which has
* family name "Dialog.Plain" and full name of "Dialog".
* The one arguably overly stringent restriction here is that if an
* application wants to supply a new member of an existing family
* It will get rejected. But since the JRE can perform synthetic
* styling in many cases its not necessary.
* We don't apply the same logic to registered fonts. If apps want
* to do this lets assume they have a reason. It won't cause problems
* except for themselves.
*/
HashSet<String> names = getInstalledNames();
Locale l = getSystemStartupLocale();
String familyName = font.getFamily(l).toLowerCase();
String fullName = font.getFontName(l).toLowerCase();
if (names.contains(familyName) || names.contains(fullName)) {
return false;
}
/* Checks passed, now register the font */
Hashtable<String,FontFamily> familyTable;
Hashtable<String,Font2D> fullNameTable;
if (!maybeMultiAppContext()) {
familyTable = createdByFamilyName;
fullNameTable = createdByFullName;
fontsAreRegistered = true;
} else {
AppContext appContext = AppContext.getAppContext();
familyTable =
(Hashtable<String,FontFamily>)appContext.get(regFamilyKey);
fullNameTable =
(Hashtable<String,Font2D>)appContext.get(regFullNameKey);
if (familyTable == null) {
familyTable = new Hashtable<String,FontFamily>();
fullNameTable = new Hashtable<String,Font2D>();
appContext.put(regFamilyKey, familyTable);
appContext.put(regFullNameKey, fullNameTable);
}
fontsAreRegisteredPerAppContext = true;
}
/* Create the FontFamily and add font to the tables */
Font2D font2D = FontUtilities.getFont2D(font);
int style = font2D.getStyle();
FontFamily family = familyTable.get(familyName);
if (family == null) {
family = new FontFamily(font.getFamily(l));
familyTable.put(familyName, family);
}
/* Remove name cache entries if not using app contexts.
* To accommodate a case where code may have registered first a plain
* family member and then used it and is now registering a bold family
* member, we need to remove all members of the family, so that the
* new style can get picked up rather than continuing to synthesise.
*/
if (fontsAreRegistered) {
removeFromCache(family.getFont(Font.PLAIN));
removeFromCache(family.getFont(Font.BOLD));
removeFromCache(family.getFont(Font.ITALIC));
removeFromCache(family.getFont(Font.BOLD|Font.ITALIC));
removeFromCache(fullNameTable.get(fullName));
}
family.setFont(font2D, style);
fullNameTable.put(fullName, font2D);
return true;
}
public String getCriterion (String criterion, Hashtable<String, String> allowedValues) throws DataRequestException {
if (allowedValues.containsKey(criterion.toLowerCase())) {
return allowedValues.get(criterion.toLowerCase());
}
else throw new DataRequestException (CRITERION_ERROR_MSG + " >" + criterion + "<. Valid values are >" + allowedValues.keySet().toString() + "<") ;
}
/**
* Returns properties and it's values supported by this object.
* object.name Name of the object; use setObjectName()
* object.owner Name of the object; use setObjectOwner()
* column.size Size of column
* column.decsize Deimal size of size
* column.type Type of column
* default.value Condition of column
* Throws DDLException if object name is not specified.
*/
public Map getColumnProperties(AbstractCommand cmd) throws DDLException {
DatabaseSpecification spec = cmd.getSpecification();
Map args = super.getColumnProperties(cmd);
String stype = spec.getType(type);
Vector charactertypes = (Vector)spec.getProperties().get("CharacterTypes"); // NOI18N
String strdelim = (String)spec.getProperties().get("StringDelimiter"); // NOI18N
Vector sizelesstypes = (Vector)spec.getProperties().get("SizelessTypes"); // NOI18N
String coldelim = (String)spec.getProperties().get("ArgumentListDelimiter"); // NOI18N
// Decimal size for sizeless type
if (sizelesstypes != null && size > 0) {
if (!sizelesstypes.contains(stype)) {
if (size > 0)
args.put("column.size", String.valueOf(size)); // NOI18N
if (decsize > 0)
args.put("column.decsize", String.valueOf(decsize)); // NOI18N
}
}
String qdefval = defval;
if (qdefval != null && charactertypes.contains(spec.getType(type)) && !qdefval.startsWith(strdelim) && !qdefval.endsWith(strdelim))
if (!qdefval.startsWith("(" + strdelim) && !qdefval.endsWith(strdelim + ")")) //hack for MSSQLServer, default value is encapsulated in () so I can't generate '()'
qdefval = strdelim + defval + strdelim;
String dbType = spec.getType(type);
String dbTypeSuffix = null;
Map suffixTypeMap = (Map)spec.getProperties().get("TypePrefixSuffixMap"); // NOI18N
if (suffixTypeMap != null) {
Map dbTypePrefixSuffix = (Map)suffixTypeMap.get(dbType);
if (dbTypePrefixSuffix != null) {
dbType = (String)dbTypePrefixSuffix.get("Prefix"); // NOI18N
dbTypeSuffix = (String)dbTypePrefixSuffix.get("Suffix"); // NOI18N
}
}
args.put("column.type", dbType);
if (dbTypeSuffix != null) {
args.put("column.type.suffix", dbTypeSuffix);
}
if (!nullable)
args.put("column.notnull", ""); // NOI18N
if (!(! nullable && qdefval != null && (qdefval.equalsIgnoreCase("null") || qdefval.equalsIgnoreCase("'null'") || qdefval.equalsIgnoreCase("\"null\"")))) // NOI18N
if (defval != null && !defval.equals(""))
args.put("default.value", qdefval); // NOI18N
if (checke != null)
args.put("check.condition", checke); // NOI18N
if (constraintColumns != null) {
String cols = "";
Enumeration col_e = constraintColumns.elements();
while (col_e.hasMoreElements()) {
Object zrus = col_e.nextElement();
Hashtable col = (Hashtable)zrus;
boolean inscomma = col_e.hasMoreElements();
String colname = (String)col.get("name");
cols = cols +
(isNewColumn() ? colname : cmd.quote(colname)) +
(inscomma ? coldelim : "" ); //NOI18N
}
args.put("constraint.columns", cols); // NOI18N
}
return args;
}
/**
* Passes along the properties from the source object after adding a
* property indicating the scale applied.
* This method invokes <code>super.setProperties</code>,
* which might result in additional properties being added.
* <p>
* Note: This method is intended to be called by the
* <code>ImageProducer</code> of the <code>Image</code> whose pixels
* are being filtered. Developers using
* this class to filter pixels from an image should avoid calling
* this method directly since that operation could interfere
* with the filtering operation.
*/
public void setProperties(Hashtable<?,?> props) {
Hashtable<Object,Object> p = (Hashtable<Object,Object>)props.clone();
String key = "rescale";
String val = destWidth + "x" + destHeight;
Object o = p.get(key);
if (o != null && o instanceof String) {
val = ((String) o) + ", " + val;
}
p.put(key, val);
super.setProperties(p);
}