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


Java Enumeration.nextElement方法代码示例

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


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

示例1: isAjaxRequest

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * 判断是否为ajax请求
 * 
 * @param request
 * @return
 */
public static boolean isAjaxRequest(final HttpServletRequest request) {
    if (logger.isDebugEnabled()) {
        Enumeration enums = request.getHeaderNames();
        while (enums.hasMoreElements()) {
            String key = (String) enums.nextElement();
            logger.debug(" 请求头信息: {} 的值对应为: {}", new Object[] { key, request.getHeader(key) });
        }
    }

    boolean isAjaxMatch = XML_HTTP_REQUEST.equalsIgnoreCase(request.getHeader(X_REQUESTED_WITH));

    boolean isCrossDomain = isCrossDomain(request);

    logger.debug("是否是原生ajax请求 : {} , 是否是跨域请求 : {}, 综合: {}", new Object[] { isAjaxMatch, isCrossDomain, isAjaxMatch || isCrossDomain });

    return isAjaxMatch || isCrossDomain;
}
 
开发者ID:bridgeli,项目名称:netty-socketio-demo,代码行数:24,代码来源:WebUtils.java

示例2: unpackZip

import java.util.Enumeration; //导入方法依赖的package包/类
private static void unpackZip(ZipFile zipFile, File unpackDir) throws IOException {
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        File destination = new File(unpackDir.getAbsolutePath() + "/" + entry.getName());
        if (entry.isDirectory()) {
            destination.mkdirs();
        } else {
            destination.getParentFile().mkdirs();
            FileCopyUtils.copy(zipFile.getInputStream(entry), new FileOutputStream(destination));
        }
        if (entry.getTime() != -1) {
            destination.setLastModified(entry.getTime());
        }
    }
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:17,代码来源:SampleProjects.java

示例3: createGetMethod

import java.util.Enumeration; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private HttpMethod createGetMethod(HttpServletRequest req, String uri) throws ServletException,
        NotLoggedInException {

    GetMethod get = new GetMethod(uri);
    addUserNameToHeader(get, req);
    addAcceptEncodingHeader(get, req);

    get.getParams().setContentCharset("UTF-8");
    HttpMethodParams params = new HttpMethodParams();
    Enumeration e = req.getParameterNames();
    while (e.hasMoreElements()) {
        String paramName = (String) e.nextElement();
        for (String value : req.getParameterValues(paramName)) {
            params.setParameter(paramName, value);
        }
    }
    get.setParams(params);
    return get;
}
 
开发者ID:openNaEF,项目名称:openNaEF,代码行数:21,代码来源:ForwarderServlet.java

示例4: getLocalInetAddress

import java.util.Enumeration; //导入方法依赖的package包/类
public static List<String> getLocalInetAddress() {
    List<String> inetAddressList = new ArrayList<String>();
    try {
        Enumeration<NetworkInterface> enumeration = NetworkInterface.getNetworkInterfaces();
        while (enumeration.hasMoreElements()) {
            NetworkInterface networkInterface = enumeration.nextElement();
            Enumeration<InetAddress> addrs = networkInterface.getInetAddresses();
            while (addrs.hasMoreElements()) {
                inetAddressList.add(addrs.nextElement().getHostAddress());
            }
        }
    } catch (SocketException e) {
        throw new RuntimeException("get local inet address fail", e);
    }

    return inetAddressList;
}
 
开发者ID:lyy4j,项目名称:rmq4note,代码行数:18,代码来源:MixAll.java

示例5: writeBoxedRMIIncludes

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * Write includes for boxedRMI valuetypes for IDL sequences.
 * Write only the maximum dimension found for an ArrayType.
 * @param arrHash Hashtable loaded with array types
 * @param p The output stream.
 */
protected void writeBoxedRMIIncludes(
                                     Hashtable arrHash,
                                     IndentingWriter p)
    throws IOException {
    Enumeration e1 = arrHash.elements();
    nextSequence:
    while ( e1.hasMoreElements() ) {
        ArrayType at = (ArrayType)e1.nextElement();
        int dim = at.getArrayDimension();
        Type et = at.getElementType();

        Enumeration e2 = arrHash.elements();
        while ( e2.hasMoreElements() ) {                   //eliminate duplicates
            ArrayType at2 = (ArrayType)e2.nextElement();
            if ( et == at2.getElementType() &&                //same element type &
                 dim < at2.getArrayDimension() )               //smaller dimension?
                continue nextSequence;                              //ignore this one
    }
        writeInclude( at,dim,!isThrown,p );
}
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:28,代码来源:IDLGenerator.java

示例6: scan

import java.util.Enumeration; //导入方法依赖的package包/类
public List<String> scan(String ...paths){
    List<String> fileNames = new ArrayList<>();
    if(paths == null || paths.length <= 0){
        return Collections.emptyList();
    }
    for(int i=0;i<paths.length;i++){
        try {
            String item = paths[i].replace(".","/");
            Enumeration<URL> enumeration =Thread.currentThread().getContextClassLoader().getResources(item);
            while (enumeration.hasMoreElements()){
                URL url = enumeration.nextElement();
                if(url.getProtocol().equals("file")) {
                    fileScanner(url.getPath(), fileNames);
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return fileNames;
}
 
开发者ID:caoyj1991,项目名称:Core-Java,代码行数:22,代码来源:PackageScanner.java

示例7: doStartTag

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * Prints the names and values of everything in page scope to the response,
 * along with the body (if showBody is set to <code>true</code>).
 */
public int doStartTag() throws JspTagException
{
    Enumeration names =
        pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE);

    JspWriter out = pageContext.getOut();

    try {

        out.println("The following attributes exist in page scope: <BR>");

        while (names.hasMoreElements()) {
            String name = (String) names.nextElement();
            Object attribute = pageContext.getAttribute(name);

            out.println(name + " = " + attribute + " <BR>");
        }

        if (this.showBody) {

            out.println("Body Content Follows: <BR>");
            return EVAL_BODY_INCLUDE;
        }

    } catch (IOException e) {
        throw new JspTagException(e.getMessage());
    }

    return SKIP_BODY;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:SampleTag.java

示例8: testAsEnumerationSingleton

import java.util.Enumeration; //导入方法依赖的package包/类
public void testAsEnumerationSingleton() {
  Iterator<Integer> iter = ImmutableList.of(1).iterator();
  Enumeration<Integer> enumer = Iterators.asEnumeration(iter);

  assertTrue(enumer.hasMoreElements());
  assertTrue(enumer.hasMoreElements());
  assertEquals(1, (int) enumer.nextElement());
  assertFalse(enumer.hasMoreElements());
  try {
    enumer.nextElement();
    fail();
  } catch (NoSuchElementException expected) {
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:15,代码来源:IteratorsTest.java

示例9: getSubinterfaceInetAddrs

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * @param nif network interface to get addresses for
 * @return set containing addresses for each subinterface of nif,
 *    see below for the rationale for using an ordered set
 */
private static LinkedHashSet<InetAddress> getSubinterfaceInetAddrs(
    NetworkInterface nif) {
  LinkedHashSet<InetAddress> addrs = new LinkedHashSet<InetAddress>();
  Enumeration<NetworkInterface> subNifs = nif.getSubInterfaces();
  while (subNifs.hasMoreElements()) {
    NetworkInterface subNif = subNifs.nextElement();
    addrs.addAll(Collections.list(subNif.getInetAddresses()));
  }
  return addrs;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:16,代码来源:DNS.java

示例10: decode

import java.util.Enumeration; //导入方法依赖的package包/类
String decode(Hashtable decodeMap)
{
    StringJoiner joiner = new StringJoiner(" ");
    Enumeration e = decodeMap.keys();
    while (e.hasMoreElements())
    {
        Integer i = (Integer)e.nextElement();
        if (isSet(i.intValue()))
        {
            joiner.add((String)decodeMap.get(i));
        }
    }
    return joiner.toString();
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:15,代码来源:Flags.java

示例11: getRevokedCertificate

import java.util.Enumeration; //导入方法依赖的package包/类
public X509CRLEntry getRevokedCertificate(BigInteger serialNumber)
{
    Enumeration certs = c.getRevokedCertificateEnumeration();

    X500Name previousCertificateIssuer = null; // the issuer
    while (certs.hasMoreElements())
    {
        TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();

        if (serialNumber.equals(entry.getUserCertificate().getValue()))
        {
            return new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
        }

        if (isIndirect && entry.hasExtensions())
        {
            Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);

            if (currentCaName != null)
            {
                previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
            }
        }
    }

    return null;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:28,代码来源:X509CRLObject.java

示例12: writeMaps

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * Outputs the maps as elements. Maps are not stored as elements in
 * the document, and as such this is used to output them.
 */
void writeMaps(Enumeration maps) throws IOException {
    if (maps != null) {
        while (maps.hasMoreElements()) {
            Map map = (Map) maps.nextElement();
            String name = map.getName();

            incrIndent();
            indent();
            write("<map");
            if (name != null) {
                write(" name=\"");
                write(name);
                write("\">");
            }
            else {
                write('>');
            }
            writeLineSeparator();
            incrIndent();

            // Output the areas
            AttributeSet[] areas = map.getAreas();
            if (areas != null) {
                for (int counter = 0, maxCounter = areas.length; counter < maxCounter; counter++) {
                    indent();
                    write("<area");
                    writeAttributes(areas[counter]);
                    write("></area>");
                    writeLineSeparator();
                }
            }
            decrIndent();
            indent();
            write("</map>");
            writeLineSeparator();
            decrIndent();
        }
    }
}
 
开发者ID:ser316asu,项目名称:SER316-Munich,代码行数:44,代码来源:AltHTMLWriter.java

示例13: getRealIp

import java.util.Enumeration; //导入方法依赖的package包/类
/**
 * 取得本机的IP.
 *
 * @return 如果有多个IP地址返回外网的IP,多个外网IP返回第一个IP(在多网管等特殊情况下)
 * @throws SocketException
 */
public static String getRealIp() throws SocketException {
  String localIp = null; // 本地IP,如果没有配置外网IP则返回它
  String netIp = null; // 外网IP

  Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
  InetAddress ip = null;
  boolean isFind = false; // 是否找到外网IP
  while (netInterfaces.hasMoreElements() && !isFind) {
    NetworkInterface ni = netInterfaces.nextElement();
    Enumeration<InetAddress> address = ni.getInetAddresses();
    while (address.hasMoreElements()) {
      ip = address.nextElement();
      if (!ip.isSiteLocalAddress()
          && !ip.isLoopbackAddress()
          && ip.getHostAddress().indexOf(":") == -1) { // 外网IP
        netIp = ip.getHostAddress();
        isFind = true;
        break;
      } else if (ip.isSiteLocalAddress()
          && !ip.isLoopbackAddress()
          && ip.getHostAddress().indexOf(":") == -1) { // 内网IP
        localIp = ip.getHostAddress();
      }
    }
  }
  if (netIp != null && !"".equals(netIp)) {
    return netIp;
  } else {
    return localIp;
  }
}
 
开发者ID:junzixiehui,项目名称:godeye,代码行数:38,代码来源:IpUtils.java

示例14: createMachineIdentifier

import java.util.Enumeration; //导入方法依赖的package包/类
private static int createMachineIdentifier() {
	// build a 2-byte machine piece based on NICs info
	int machinePiece;
	try {
		StringBuilder sb = new StringBuilder();
		Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces();
		while (e.hasMoreElements()) {
			NetworkInterface ni = e.nextElement();
			sb.append(ni.toString());
			byte[] mac = ni.getHardwareAddress();
			if (mac != null) {
				ByteBuffer bb = ByteBuffer.wrap(mac);
				try {
					sb.append(bb.getChar());
					sb.append(bb.getChar());
					sb.append(bb.getChar());
				} catch (BufferUnderflowException shortHardwareAddressException) { // NOPMD
					// mac with less than 6 bytes. continue
				}
			}
		}
		machinePiece = sb.toString().hashCode();
	} catch (Throwable t) {
		// exception sometimes happens with IBM JVM, use random
		machinePiece = (new SecureRandom().nextInt());
	}
	machinePiece = machinePiece & LOW_ORDER_THREE_BYTES;
	return machinePiece;
}
 
开发者ID:zhangjunfang,项目名称:util,代码行数:30,代码来源:ObjectId.java

示例15: clearJdbcDriverRegistrations

import java.util.Enumeration; //导入方法依赖的package包/类
public List<String> clearJdbcDriverRegistrations() throws SQLException {
	List<String> driverNames = new ArrayList<String>();

	/*
	 * DriverManager.getDrivers() has a nasty side-effect of registering
	 * drivers that are visible to this class loader but haven't yet been
	 * loaded. Therefore, the first call to this method a) gets the list of
	 * originally loaded drivers and b) triggers the unwanted side-effect.
	 * The second call gets the complete list of drivers ensuring that both
	 * original drivers and any loaded as a result of the side-effects are
	 * all de-registered.
	 */
	HashSet<Driver> originalDrivers = new HashSet<Driver>();
	Enumeration<Driver> drivers = DriverManager.getDrivers();
	while (drivers.hasMoreElements()) {
		originalDrivers.add(drivers.nextElement());
	}
	drivers = DriverManager.getDrivers();
	while (drivers.hasMoreElements()) {
		Driver driver = drivers.nextElement();
		// Only unload the drivers this web app loaded
		if (driver.getClass().getClassLoader() != this.getClass().getClassLoader()) {
			continue;
		}
		// Only report drivers that were originally registered. Skip any
		// that were registered as a side-effect of this code.
		if (originalDrivers.contains(driver)) {
			driverNames.add(driver.getClass().getCanonicalName());
		}
		DriverManager.deregisterDriver(driver);
	}
	return driverNames;
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:34,代码来源:JdbcLeakPrevention.java


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