171123 Enumeration - RYUDONGJIN/Memo_wiki GitHub Wiki

Enumeration μΈν„°νŽ˜μ΄μŠ€

  • κ°μ²΄λ“€μ˜ 집합(Vector)μ—μ„œ 각각의 객체듀을 ν•œμˆœκ°„μ— ν•˜λ‚˜μ”© μ²˜λ¦¬ν•  수 μžˆλŠ” λ©”μ†Œλ“œλ₯Ό μ œκ³΅ν•˜λŠ” μ»¬λ ‰μ…˜.
  • μΈν„°νŽ˜μ΄μŠ€μ΄λ―€λ‘œ 직접 new μ—°μ‚°μžλ₯Ό μ΄μš©ν•˜μ—¬ 객체λ₯Ό 생성할 수 μ—†λ‹€.
  • Enumeration μΈν„°νŽ˜μ΄μŠ€μ— μ„ μ–Έλœ λ©”μ†Œλ“œλŠ” κ·Έ μΈν„°νŽ˜μ΄μŠ€λ₯Ό μ‚¬μš©ν•˜λŠ” 클래슀둜 κ΅¬ν˜„ν•΄μ„œ μ‚¬μš©ν•΄μ•Όλ§Œ ν•œλ‹€.

Enumeration μΈν„°νŽ˜μ΄μŠ€ λ©”μ†Œλ“œ

  1. boolean hasMoreElements()
    Vector둜 λΆ€ν„° μƒμ„±λœ Enumeration의 μš”μ†Œκ°€ 있으면 true, μ•„λ‹ˆλ©΄ false λ°˜ν™˜
  2. Object nextElement()
    Enumeration λ‚΄μ˜ λ‹€μŒ μš”μ†Œλ₯Ό λ°˜ν™˜ν•œλ‹€.
    Enumeration κ°μ²΄λŠ” new μ—°μ‚°μžλ‘œ 생성할 수 μ—†μœΌλ©°, Vectorλ₯Ό μ΄μš©ν•˜μ—¬ 생성할 수 μžˆλ‹€.
    Vector 클래슀의 elements() λΌλŠ” λ©”μ†Œλ“œλŠ” 객체의 λͺ¨λ“  μš”μ†Œλ“€μ„ Enumeration 객체둜 λ°˜ν™˜ν•œλ‹€.
                String mySessionName = (String)session.getAttribute("mySessionName");
		out.println(mySessionName +"<br />");
		
		Integer myNum = (Integer)session.getAttribute("myNum");
		out.println(myNum +"<br />");
		
		out.println("************************ <br />");
		
		String sName;
		String sValue;
		Enumeration enumeration = session.getAttributeNames();
		while(enumeration.hasMoreElements()){
			sName = enumeration.nextElement().toString();
			sValue = session.getAttribute(sName).toString();
			out.println("sName : " + sName + "<br />");
			out.println("sValue : " + sValue + "<br />");
		}
		
		out.println("************************ <br />");
		
		String sessionID = session.getId();
		out.println("sessionID : " + sessionID + "<br />");
		int sessionInter =  session.getMaxInactiveInterval();
		out.println("sessionInter : " + sessionInter + "<br />");
		
		out.println("************************ <br />");
		
		session.removeAttribute("mySessionName");
		Enumeration enumeration1 = session.getAttributeNames();
		while(enumeration1.hasMoreElements()){
			sName = enumeration1.nextElement().toString();
			sValue = session.getAttribute(sName).toString();
			out.println("sName : " + sName + "<br />");
			out.println("sValue : " + sValue + "<br />");
		}
		
		out.println("************************ <br />");
		
		session.invalidate();
		if(request.isRequestedSessionIdValid()) {
			out.println("session valid");
		} else {
			out.println("session invalid");
		}
⚠️ **GitHub.com Fallback** ⚠️