当前位置: 首页>>代码示例>>Java>>正文


Java Hashtable.put方法代码示例

本文整理汇总了Java中java.util.Hashtable.put方法的典型用法代码示例。如果您正苦于以下问题:Java Hashtable.put方法的具体用法?Java Hashtable.put怎么用?Java Hashtable.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Hashtable的用法示例。


在下文中一共展示了Hashtable.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: analyzeBitmap

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * 解析二维码图片工具类
 *
 * @param bitmap
 */
public static String analyzeBitmap(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();

    // 解码的参数
    Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(2);
    // 可以解析的编码类型
    Vector<BarcodeFormat> decodeFormats = new Vector<BarcodeFormat>();
    if (decodeFormats == null || decodeFormats.isEmpty()) {
        decodeFormats = new Vector<BarcodeFormat>();

        // 这里设置可扫描的类型,我这里选择了都支持
        decodeFormats.addAll(DecodeFormatManager.ONE_D_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.QR_CODE_FORMATS);
        decodeFormats.addAll(DecodeFormatManager.DATA_MATRIX_FORMATS);
    }
    hints.put(DecodeHintType.POSSIBLE_FORMATS, decodeFormats);
    // 设置继续的字符编码格式为UTF8
    hints.put(DecodeHintType.CHARACTER_SET, "UTF8");
    // 设置解析配置参数
    multiFormatReader.setHints(hints);

    // 开始对图像资源解码
    Result rawResult = null;
    try {
        rawResult = multiFormatReader.decodeWithState(new BinaryBitmap(new HybridBinarizer(new BitmapLuminanceSource(bitmap))));
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (rawResult != null) {
        return rawResult.getText();
    } else {
        return "Failed";
    }
}
 
开发者ID:ymqq,项目名称:CommonFramework,代码行数:41,代码来源:ImageUtils.java

示例2: buildListFromComponents

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Builds a list from the components array.
 * @param components the components array
 * @return a list to be placed on the GUI
 */
JList buildListFromComponents (Component [] components) {
	JList list = new JList();
	
	if (components != null) {
		list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		list.setSize(100,200);
		
		listData = new Vector();
		menuItems = new Hashtable();
		
		// build a hash look-up table and fill list with components's text
		for (int i=0 ; i<components.length ; i++) {
			if (components[i] instanceof JMenuItem) {
				listData.addElement(((JMenuItem)components[i]).getText());
				menuItems.put(((JMenuItem)components[i]).getText(),components[i]);
			}
			else {
				listData.addElement(SEPARATOR_STRING);
				menuItems.put(SEPARATOR_STRING,components[i]);
			}
		}
		
		list.setListData(listData);
	}
		
	return list;
}
 
开发者ID:guilhebl,项目名称:routerapp,代码行数:33,代码来源:MenuManagementWindow.java

示例3: createQRCode

import java.util.Hashtable; //导入方法依赖的package包/类
public static Bitmap createQRCode(String str, int size) throws WriterException {
	Hashtable<EncodeHintType, String> hints = new Hashtable<EncodeHintType, String>();
	hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
	BitMatrix matrix = new MultiFormatWriter().encode(str, BarcodeFormat.QR_CODE, size, size);
	int width = matrix.getWidth();
	int height = matrix.getHeight();
	int[] pixels = new int[width * height];
	for(int x = 0; x < width; x ++){
		for(int y = 0; y < height; y ++){
			if(matrix.get(x, y)){
				pixels[y * width + x] = BLACK;
			}
		}
	}
	Bitmap bitmap = Bitmap.createBitmap(width, height, Config.ARGB_8888);
	bitmap.setPixels(pixels, 0, width, 0, 0, width, height);
	return bitmap;
}
 
开发者ID:yun2win,项目名称:tvConnect_android,代码行数:19,代码来源:EncodingHandler.java

示例4: distFeaturesOnServers

import java.util.Hashtable; //导入方法依赖的package包/类
public int[] distFeaturesOnServers() {
    Hashtable<SGHFeature, Integer> count = new Hashtable<SGHFeature, Integer>();
    for (SGHServer s : servers) {
        for (SGHFeature f : s.featureSet) {
            if (!count.containsKey(f)) {
                count.put(f, 1);
            }
            else {
                count.put(f, count.get(f) + 1);
            }
        }
    }
    ArrayList<Integer> counts = new ArrayList<Integer>(count.values());
    Collections.sort(counts);
    int[] result = new int[counts.size()];
    for (int i=0; i<counts.size(); i++) result[counts.size()-i-1] = counts.get(i);
    return result;
}
 
开发者ID:ffleurey,项目名称:EvoServ,代码行数:19,代码来源:SGHSystem.java

示例5: main

import java.util.Hashtable; //导入方法依赖的package包/类
public static void main(String[] args) {

        // Create a new AttributedString with one attribute.
        Hashtable attributes = new Hashtable();
        attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
        AttributedString origString = new AttributedString("Hello world.", attributes);

        // Create an iterator over part of the AttributedString.
        AttributedCharacterIterator iter = origString.getIterator(null, 4, 6);

        // Attempt to create a new AttributedString from the iterator.
        // This will throw IllegalArgumentException.
        AttributedString newString = new AttributedString(iter);

        // Without the exception this would get executed.
        System.out.println("DONE");
    }
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:TestAttributedStringCtor.java

示例6: MakeAssignmentsForClassEvents

import java.util.Hashtable; //导入方法依赖的package包/类
public MakeAssignmentsForClassEvents(Session session, org.hibernate.Session hibSession) {
    iHibSession = hibSession;
    iSession = session;
    Calendar date = Calendar.getInstance(Locale.US);
    date.setLenient(true);
    date.setTime(iSession.getSessionBeginDateTime());
    iWeekDate = new Vector(); 
    while (date.getTime().compareTo(iSession.getSessionEndDateTime())<=0) {
        iWeekDate.add(date.getTime());
        int idx = 0;
        while (idx<7) {
            date.add(Calendar.DAY_OF_YEAR, 1);
            if (iSession.getHoliday(date.get(Calendar.DAY_OF_MONTH),date.get(Calendar.MONTH))!=Session.sHolidayTypeBreak) idx++;
        }
    }
    iWeekDate.add(date.getTime());
    iDatePatterns = new Hashtable();
    for (Iterator i=DatePattern.findAll(iSession, true, null, null).iterator();i.hasNext();) {
        DatePattern dp = (DatePattern)i.next();
        iDatePatterns.put(dp.getName(), dp);
    }
    iExactTimePattern = TimePattern.findExactTime(iSession.getUniqueId());
    iLocations = new Hashtable();
    for (Iterator i=Location.findAll(iSession.getUniqueId()).iterator();i.hasNext();) {
        Location location = (Location)i.next();
        if (location.getPermanentId()!=null)
            iLocations.put(location.getPermanentId(), location);
    }
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:30,代码来源:MakeAssignmentsForClassEvents.java

示例7: getDump

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Returns information about component.
 */
@Override
public Hashtable<String, Object> getDump() {
    Hashtable<String, Object> result = super.getDump();
    result.put(TEXT_DPROP, ((Checkbox) getSource()).getLabel());
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:CheckboxOperator.java

示例8: createContext

import java.util.Hashtable; //导入方法依赖的package包/类
private InitialDirContext createContext() throws NamingException {
	Hashtable<String, String> env = new Hashtable<>();
	env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
	env.put(Context.PROVIDER_URL, ldapValue.getLdapUrl());
	env.put(Context.SECURITY_AUTHENTICATION, "simple");
	env.put(Context.SECURITY_PRINCIPAL, ldapValue.getUserName() + "@" + ldapValue.getLdapDomain());
	env.put(Context.SECURITY_CREDENTIALS, ldapValue.getPassword());
	return new InitialDirContext(env);
}
 
开发者ID:adessoAG,项目名称:JenkinsHue,代码行数:10,代码来源:LDAPManager.java

示例9: createImage

import java.util.Hashtable; //导入方法依赖的package包/类
private void createImage(String text,int QR_WIDTH,int QR_HEIGHT) {
    try {
        // 需要引入core包
        QRCodeWriter writer = new QRCodeWriter();

        // 把输入的文本转为二维码
        BitMatrix martix = writer.encode(text, BarcodeFormat.QR_CODE,
                QR_WIDTH, QR_HEIGHT);

        System.out.println("w:" + martix.getWidth() + "h:"
                + martix.getHeight());

        Hashtable<EncodeHintType, Object> hints = new Hashtable<>();
        hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
        hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
        BitMatrix bitMatrix = new QRCodeWriter().encode(text,
                BarcodeFormat.QR_CODE, QR_WIDTH, QR_HEIGHT, hints);
        int[] pixels = new int[QR_WIDTH * QR_HEIGHT];
        for (int y = 0; y < QR_HEIGHT; y++) {
            for (int x = 0; x < QR_WIDTH; x++) {
                if (bitMatrix.get(x, y)) {
                    pixels[y * QR_WIDTH + x] = 0xff000000;
                } else {
                    pixels[y * QR_WIDTH + x] = 0xffffffff;
                }

            }
        }

        Bitmap bitmap = Bitmap.createBitmap(QR_WIDTH, QR_HEIGHT,
                Bitmap.Config.ARGB_8888);

        bitmap.setPixels(pixels, 0, QR_WIDTH, 0, 0, QR_WIDTH, QR_HEIGHT);
        ivCode.setImageBitmap(bitmap);

    } catch (WriterException e) {
        e.printStackTrace();
    }
}
 
开发者ID:penghuanliang,项目名称:Rxjava2.0Demo,代码行数:40,代码来源:QrCodeActivity.java

示例10: actionPwd

import java.util.Hashtable; //导入方法依赖的package包/类
private Hashtable<String, Object> actionPwd(String sessionId, Hashtable<String, Object> input) throws JLIException {
       
	String outdir = proeHandler.pwd(sessionId);
	
	if (outdir!=null) {
		Hashtable<String, Object> out = new Hashtable<String, Object>();
		out.put(OUTPUT_DIRNAME, outdir);
		return out;
	}
	return null;
}
 
开发者ID:SimplifiedLogic,项目名称:creoson,代码行数:12,代码来源:JLJsonCreoHandler.java

示例11: actionList

import java.util.Hashtable; //导入方法依赖的package包/类
private Hashtable<String, Object> actionList(String sessionId, Hashtable<String, Object> input) throws JLIException {
       String modelname = checkStringParameter(input, PARAM_MODEL, false);
       String namePattern = checkStringParameter(input, PARAM_NAME, false);
       List<String> dimNames = null;
       Object namesObj = checkParameter(input, PARAM_NAMES, false);
       if (namesObj!=null) {
       	dimNames = getStringListValue(namesObj);
       }
       boolean encoded = checkFlagParameter(input, PARAM_ENCODED, false, false);

       List<DimData> dims = dimHandler.list(modelname, namePattern, dimNames, encoded, sessionId);
       
       if (dims!=null && dims.size()>0) {
		Hashtable<String, Object> out = new Hashtable<String, Object>();
		Vector<Map<String, Object>> outDims = new Vector<Map<String, Object>>();
		out.put(OUTPUT_DIMLIST, outDims);
		Map<String, Object> outDim = null;
		for (DimData dim : dims) {
			outDim = new Hashtable<String, Object>();
			if (dim.getName()!=null)
				outDim.put(PARAM_NAME, dim.getName());
			if (dim.getValue()!=null)
				outDim.put(PARAM_VALUE, dim.getValue());
			outDim.put(PARAM_ENCODED, Boolean.valueOf(dim.isEncoded()));
			
			outDims.add(outDim);
		}
		
		return out;
       }
       return null;
}
 
开发者ID:SimplifiedLogic,项目名称:creoson,代码行数:33,代码来源:JLJsonDimensionHandler.java

示例12: getDump

import java.util.Hashtable; //导入方法依赖的package包/类
@Override
public Hashtable<String, Object> getDump() {
    Hashtable<String, Object> result = super.getDump();
    result.put(MINIMUM_DPROP, Integer.toString(((JSplitPane) getSource()).getMinimumDividerLocation()));
    result.put(MAXIMUM_DPROP, Integer.toString(((JSplitPane) getSource()).getMaximumDividerLocation()));
    result.put(ORIENTATION_DPROP, (((JSplitPane) getSource()).getOrientation() == JSplitPane.HORIZONTAL_SPLIT)
            ? HORIZONTAL_ORIENTATION_DPROP_VALUE
            : VERTICAL_ORIENTATION_DPROP_VALUE);
    result.put(VALUE_DPROP, Integer.toString(((JSplitPane) getSource()).getDividerLocation()));
    result.put(IS_ONE_TOUCH_EXPANDABLE_DPROP, ((JSplitPane) getSource()).isOneTouchExpandable() ? "true" : "false");
    return result;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:JSplitPaneOperator.java

示例13: run

import java.util.Hashtable; //导入方法依赖的package包/类
public void run()
  {
Log.logNormal("LDap request " + m_nRequestId + ": trying to get ldap info from server " + m_csServer);
int nNbTries = 0;
while(nNbTries < 2)
{
          Hashtable<String, String> env = new Hashtable<String, String>();
          env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
          env.put(Context.PROVIDER_URL, "ldap://"+m_csServer+"/");
          env.put(Context.SECURITY_AUTHENTICATION, "simple");
          env.put(Context.SECURITY_PRINCIPAL, m_csUserId);
          env.put(Context.SECURITY_CREDENTIALS, m_csPassword);  
          if(m_ldapUtil != null)
          {
          	DirContext dirContext = m_ldapUtil.getDirContext(env);
          	if(dirContext != null)
          	{
          		m_ldapUtil.setOnceDirContext(dirContext);
          		Log.logNormal("LDap request " + m_nRequestId + ": dir context correctly set");
          		return;
          	}
          }   
          nNbTries++;
}
if(m_NbThreadCreated.dec() <= 0)
{
	m_ldapUtil.setOnceDirContext(null);
}
Log.logCritical("LDap request " + m_nRequestId + ": dir context NOT correctly set");
  }
 
开发者ID:costea7,项目名称:ChronoBike,代码行数:31,代码来源:LdapThread.java

示例14: InitialLdapContext

import java.util.Hashtable; //导入方法依赖的package包/类
/**
 * Constructs an initial context
 * using environment properties and connection request controls.
 * See <tt>javax.naming.InitialContext</tt> for a discussion of
 * environment properties.
 *
 * <p> This constructor will not modify its parameters or
 * save references to them, but may save a clone or copy.
 * Caller should not modify mutable keys and values in
 * <tt>environment</tt> after it has been passed to the constructor.
 *
 * <p> <tt>connCtls</tt> is used as the underlying context instance's
 * connection request controls.  See the class description
 * for details.
 *
 * @param environment
 *          environment used to create the initial DirContext.
 *          Null indicates an empty environment.
 * @param connCtls
 *          connection request controls for the initial context.
 *          If null, no connection request controls are used.
 *
 * @throws  NamingException if a naming exception is encountered
 *
 * @see #reconnect
 * @see LdapContext#reconnect
 */
@SuppressWarnings("unchecked")
public InitialLdapContext(Hashtable<?,?> environment,
                          Control[] connCtls)
        throws NamingException {
    super(true); // don't initialize yet

    // Clone environment since caller owns it.
    Hashtable<Object,Object> env = (environment == null)
        ? new Hashtable<>(11)
        : (Hashtable<Object,Object>)environment.clone();

    // Put connect controls into environment.  Copy them first since
    // caller owns the array.
    if (connCtls != null) {
        Control[] copy = new Control[connCtls.length];
        System.arraycopy(connCtls, 0, copy, 0, connCtls.length);
        env.put(BIND_CONTROLS_PROPERTY, copy);
    }
    // set version to LDAPv3
    env.put("java.naming.ldap.version", "3");

    // Initialize with updated environment
    init(env);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:52,代码来源:InitialLdapContext.java

示例15: JDBCTypes

import java.util.Hashtable; //导入方法依赖的package包/类
JDBCTypes() {

        hStringJDBCtypes = new Hashtable();
        hIntJDBCtypes    = new Hashtable();

        hStringJDBCtypes.put(new Integer(ARRAY), "ARRAY");
        hStringJDBCtypes.put(new Integer(BLOB), "BLOB");
        hStringJDBCtypes.put(new Integer(CLOB), "CLOB");
        hStringJDBCtypes.put(new Integer(DISTINCT), "DISTINCT");
        hStringJDBCtypes.put(new Integer(JAVA_OBJECT), "JAVA_OBJECT");
        hStringJDBCtypes.put(new Integer(REF), "REF");
        hStringJDBCtypes.put(new Integer(STRUCT), "STRUCT");

        //
        hStringJDBCtypes.put(new Integer(java.sql.Types.BIGINT), "BIGINT");
        hStringJDBCtypes.put(new Integer(java.sql.Types.BINARY), "BINARY");
        hStringJDBCtypes.put(new Integer(java.sql.Types.BIT), "BIT");
        hStringJDBCtypes.put(new Integer(java.sql.Types.CHAR), "CHAR");
        hStringJDBCtypes.put(new Integer(java.sql.Types.DATE), "DATE");
        hStringJDBCtypes.put(new Integer(java.sql.Types.DECIMAL), "DECIMAL");
        hStringJDBCtypes.put(new Integer(java.sql.Types.DOUBLE), "DOUBLE");
        hStringJDBCtypes.put(new Integer(java.sql.Types.FLOAT), "FLOAT");
        hStringJDBCtypes.put(new Integer(java.sql.Types.INTEGER), "INTEGER");
        hStringJDBCtypes.put(new Integer(java.sql.Types.LONGVARBINARY),
                             "LONGVARBINARY");
        hStringJDBCtypes.put(new Integer(java.sql.Types.LONGVARCHAR),
                             "LONGVARCHAR");
        hStringJDBCtypes.put(new Integer(java.sql.Types.NULL), "NULL");
        hStringJDBCtypes.put(new Integer(java.sql.Types.NUMERIC), "NUMERIC");
        hStringJDBCtypes.put(new Integer(java.sql.Types.OTHER), "OTHER");
        hStringJDBCtypes.put(new Integer(java.sql.Types.REAL), "REAL");
        hStringJDBCtypes.put(new Integer(java.sql.Types.SMALLINT),
                             "SMALLINT");
        hStringJDBCtypes.put(new Integer(java.sql.Types.TIME), "TIME");
        hStringJDBCtypes.put(new Integer(java.sql.Types.TIMESTAMP),
                             "TIMESTAMP");
        hStringJDBCtypes.put(new Integer(java.sql.Types.TINYINT), "TINYINT");
        hStringJDBCtypes.put(new Integer(java.sql.Types.VARBINARY),
                             "VARBINARY");
        hStringJDBCtypes.put(new Integer(java.sql.Types.VARCHAR), "VARCHAR");

        hStringJDBCtypes.put(new Integer(java.sql.Types.BOOLEAN), "BOOLEAN");
        //
        hIntJDBCtypes.put("ARRAY", new Integer(ARRAY));
        hIntJDBCtypes.put("BLOB", new Integer(BLOB));
        hIntJDBCtypes.put("CLOB", new Integer(CLOB));
        hIntJDBCtypes.put("DISTINCT", new Integer(DISTINCT));
        hIntJDBCtypes.put("JAVA_OBJECT", new Integer(JAVA_OBJECT));
        hIntJDBCtypes.put("REF", new Integer(REF));
        hIntJDBCtypes.put("STRUCT", new Integer(STRUCT));

        //
        hIntJDBCtypes.put("BIGINT", new Integer(java.sql.Types.BIGINT));
        hIntJDBCtypes.put("BINARY", new Integer(java.sql.Types.BINARY));
        hIntJDBCtypes.put("BIT", new Integer(java.sql.Types.BIT));
        hIntJDBCtypes.put("CHAR", new Integer(java.sql.Types.CHAR));
        hIntJDBCtypes.put("DATE", new Integer(java.sql.Types.DATE));
        hIntJDBCtypes.put("DECIMAL", new Integer(java.sql.Types.DECIMAL));
        hIntJDBCtypes.put("DOUBLE", new Integer(java.sql.Types.DOUBLE));
        hIntJDBCtypes.put("FLOAT", new Integer(java.sql.Types.FLOAT));
        hIntJDBCtypes.put("INTEGER", new Integer(java.sql.Types.INTEGER));
        hIntJDBCtypes.put("LONGVARBINARY",
                          new Integer(java.sql.Types.LONGVARBINARY));
        hIntJDBCtypes.put("LONGVARCHAR",
                          new Integer(java.sql.Types.LONGVARCHAR));
        hIntJDBCtypes.put("NULL", new Integer(java.sql.Types.NULL));
        hIntJDBCtypes.put("NUMERIC", new Integer(java.sql.Types.NUMERIC));
        hIntJDBCtypes.put("OTHER", new Integer(java.sql.Types.OTHER));
        hIntJDBCtypes.put("REAL", new Integer(java.sql.Types.REAL));
        hIntJDBCtypes.put("SMALLINT", new Integer(java.sql.Types.SMALLINT));
        hIntJDBCtypes.put("TIME", new Integer(java.sql.Types.TIME));
        hIntJDBCtypes.put("TIMESTAMP", new Integer(java.sql.Types.TIMESTAMP));
        hIntJDBCtypes.put("TINYINT", new Integer(java.sql.Types.TINYINT));
        hIntJDBCtypes.put("VARBINARY", new Integer(java.sql.Types.VARBINARY));
        hIntJDBCtypes.put("VARCHAR", new Integer(java.sql.Types.VARCHAR));
        hIntJDBCtypes.put("BOOLEAN", new Integer(java.sql.Types.BOOLEAN));
    }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:78,代码来源:JDBCTypes.java


注:本文中的java.util.Hashtable.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。