Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JDK 11 java.naming.jmod - Naming Module
JDK 11 java.naming.jmod is the JMOD file for JDK 11 Naming module.
JDK 11 Naming module compiled class files are stored in \fyicenter\jdk-11.0.1\jmods\java.naming.jmod.
JDK 11 Naming module compiled class files are also linked and stored in the \fyicenter\jdk-11.0.1\lib\modules JImage file.
JDK 11 Naming module source code files are stored in \fyicenter\jdk-11.0.1\lib\src.zip\java.naming.
You can click and view the content of each source code file in the list below.
✍: FYIcenter
⏎ com/sun/jndi/toolkit/dir/ContextEnumerator.java
/*
* Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.sun.jndi.toolkit.dir;
import javax.naming.*;
import javax.naming.directory.SearchControls;
import java.util.*;
/**
* A class for recursively enumerating the contents of a Context;
*
* @author Jon Ruiz
*/
public class ContextEnumerator implements NamingEnumeration<Binding> {
private static boolean debug = false;
private NamingEnumeration<Binding> children = null;
private Binding currentChild = null;
private boolean currentReturned = false;
private Context root;
private ContextEnumerator currentChildEnum = null;
private boolean currentChildExpanded = false;
private boolean rootProcessed = false;
private int scope = SearchControls.SUBTREE_SCOPE;
private String contextName = "";
public ContextEnumerator(Context context) throws NamingException {
this(context, SearchControls.SUBTREE_SCOPE);
}
public ContextEnumerator(Context context, int scope)
throws NamingException {
// return this object except when searching single-level
this(context, scope, "", scope != SearchControls.ONELEVEL_SCOPE);
}
protected ContextEnumerator(Context context, int scope, String contextName,
boolean returnSelf)
throws NamingException {
if(context == null) {
throw new IllegalArgumentException("null context passed");
}
root = context;
// No need to list children if we're only searching object
if (scope != SearchControls.OBJECT_SCOPE) {
children = getImmediateChildren(context);
}
this.scope = scope;
this.contextName = contextName;
// pretend root is processed, if we're not supposed to return ourself
rootProcessed = !returnSelf;
prepNextChild();
}
// Subclass should override if it wants to avoid calling obj factory
protected NamingEnumeration<Binding> getImmediateChildren(Context ctx)
throws NamingException {
return ctx.listBindings("");
}
// Subclass should override so that instance is of same type as subclass
protected ContextEnumerator newEnumerator(Context ctx, int scope,
String contextName, boolean returnSelf) throws NamingException {
return new ContextEnumerator(ctx, scope, contextName, returnSelf);
}
public boolean hasMore() throws NamingException {
return !rootProcessed ||
(scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants());
}
public boolean hasMoreElements() {
try {
return hasMore();
} catch (NamingException e) {
return false;
}
}
public Binding nextElement() {
try {
return next();
} catch (NamingException e) {
throw new NoSuchElementException(e.toString());
}
}
public Binding next() throws NamingException {
if (!rootProcessed) {
rootProcessed = true;
return new Binding("", root.getClass().getName(),
root, true);
}
if (scope != SearchControls.OBJECT_SCOPE && hasMoreDescendants()) {
return getNextDescendant();
}
throw new NoSuchElementException();
}
public void close() throws NamingException {
root = null;
}
private boolean hasMoreChildren() throws NamingException {
return children != null && children.hasMore();
}
private Binding getNextChild() throws NamingException {
Binding oldBinding = children.next();
Binding newBinding = null;
// if the name is relative, we need to add it to the name of this
// context to keep it relative w.r.t. the root context we are
// enumerating
if(oldBinding.isRelative() && !contextName.equals("")) {
NameParser parser = root.getNameParser("");
Name newName = parser.parse(contextName);
newName.add(oldBinding.getName());
if(debug) {
System.out.println("ContextEnumerator: adding " + newName);
}
newBinding = new Binding(newName.toString(),
oldBinding.getClassName(),
oldBinding.getObject(),
oldBinding.isRelative());
} else {
if(debug) {
System.out.println("ContextEnumerator: using old binding");
}
newBinding = oldBinding;
}
return newBinding;
}
private boolean hasMoreDescendants() throws NamingException {
// if the current child is expanded, see if it has more elements
if (!currentReturned) {
if(debug) {System.out.println("hasMoreDescendants returning " +
(currentChild != null) ); }
return currentChild != null;
} else if (currentChildExpanded && currentChildEnum.hasMore()) {
if(debug) {System.out.println("hasMoreDescendants returning " +
"true");}
return true;
} else {
if(debug) {System.out.println("hasMoreDescendants returning " +
"hasMoreChildren");}
return hasMoreChildren();
}
}
private Binding getNextDescendant() throws NamingException {
if (!currentReturned) {
// returning parent
if(debug) {System.out.println("getNextDescendant: simple case");}
currentReturned = true;
return currentChild;
} else if (currentChildExpanded && currentChildEnum.hasMore()) {
if(debug) {System.out.println("getNextDescendant: expanded case");}
// if the current child is expanded, use it's enumerator
return currentChildEnum.next();
} else {
// Ready to go onto next child
if(debug) {System.out.println("getNextDescendant: next case");}
prepNextChild();
return getNextDescendant();
}
}
private void prepNextChild() throws NamingException {
if(hasMoreChildren()) {
try {
currentChild = getNextChild();
currentReturned = false;
} catch (NamingException e){
if (debug) System.out.println(e);
if (debug) e.printStackTrace();
}
} else {
currentChild = null;
return;
}
if(scope == SearchControls.SUBTREE_SCOPE &&
currentChild.getObject() instanceof Context) {
currentChildEnum = newEnumerator(
(Context)(currentChild.getObject()),
scope, currentChild.getName(),
false);
currentChildExpanded = true;
if(debug) {System.out.println("prepNextChild: expanded");}
} else {
currentChildExpanded = false;
currentChildEnum = null;
if(debug) {System.out.println("prepNextChild: normal");}
}
}
}
⏎ com/sun/jndi/toolkit/dir/ContextEnumerator.java
Or download all of them as a single archive file:
File name: java.naming-11.0.1-src.zip File size: 461792 bytes Release date: 2018-11-04 Download
⇒ JDK 11 java.net.http.jmod - Net HTTP Module
2020-09-30, ≈85🔥, 0💬
Popular Posts:
Guava is a suite of core and expanded libraries that include utility classes, google's collections, ...
A stream buffer is a stream-based representation of an XML infoset in Java. Stream buffers are desig...
Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented ...
ANTLR is a powerful parser generator for multiple programming languages including Java. ANTLR contai...
JDK 1.1 source code directory contains Java source code for JDK 1.1 core classes: "C:\fyicenter\jdk-...