id int32 0 165k | repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1 value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 |
|---|---|---|---|---|---|---|---|---|---|---|---|
23,700 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.emptyElement | public void emptyElement (String uri, String localName)
throws SAXException
{
emptyElement(uri, localName, "", EMPTY_ATTS);
} | java | public void emptyElement (String uri, String localName)
throws SAXException
{
emptyElement(uri, localName, "", EMPTY_ATTS);
} | [
"public",
"void",
"emptyElement",
"(",
"String",
"uri",
",",
"String",
"localName",
")",
"throws",
"SAXException",
"{",
"emptyElement",
"(",
"uri",
",",
"localName",
",",
"\"\"",
",",
"EMPTY_ATTS",
")",
";",
"}"
] | Add an empty element without a qname or attributes.
<p>This method will supply an empty string for the qname
and an empty attribute list. It invokes
{@link #emptyElement(String, String, String, Attributes)}
directly.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see #emptyElement(String, String, String, Attributes) | [
"Add",
"an",
"empty",
"element",
"without",
"a",
"qname",
"or",
"attributes",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L303-L307 |
23,701 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.dataElement | public void dataElement (String uri, String localName,
String qName, Attributes atts,
String content)
throws SAXException
{
startElement(uri, localName, qName, atts);
characters(content);
endElement(uri, localName, qName);
} | java | public void dataElement (String uri, String localName,
String qName, Attributes atts,
String content)
throws SAXException
{
startElement(uri, localName, qName, atts);
characters(content);
endElement(uri, localName, qName);
} | [
"public",
"void",
"dataElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"qName",
",",
"Attributes",
"atts",
",",
"String",
"content",
")",
"throws",
"SAXException",
"{",
"startElement",
"(",
"uri",
",",
"localName",
",",
"qName",
",",
"atts",
")",
";",
"characters",
"(",
"content",
")",
";",
"endElement",
"(",
"uri",
",",
"localName",
",",
"qName",
")",
";",
"}"
] | Add an element with character data content.
<p>This is a convenience method to add a complete element
with character data content, including the start tag
and end tag.</p>
<p>This method invokes
{@link @see org.xml.sax.ContentHandler#startElement},
followed by
{@link #characters(String)}, followed by
{@link @see org.xml.sax.ContentHandler#endElement}.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@param qName The element's default qualified name.
@param atts The element's attributes.
@param content The character data content.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see org.xml.sax.ContentHandler#startElement
@see #characters(String)
@see org.xml.sax.ContentHandler#endElement | [
"Add",
"an",
"element",
"with",
"character",
"data",
"content",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L377-L385 |
23,702 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.dataElement | public void dataElement (String uri, String localName, String content)
throws SAXException
{
dataElement(uri, localName, "", EMPTY_ATTS, content);
} | java | public void dataElement (String uri, String localName, String content)
throws SAXException
{
dataElement(uri, localName, "", EMPTY_ATTS, content);
} | [
"public",
"void",
"dataElement",
"(",
"String",
"uri",
",",
"String",
"localName",
",",
"String",
"content",
")",
"throws",
"SAXException",
"{",
"dataElement",
"(",
"uri",
",",
"localName",
",",
"\"\"",
",",
"EMPTY_ATTS",
",",
"content",
")",
";",
"}"
] | Add an element with character data content but no qname or attributes.
<p>This is a convenience method to add a complete element
with character data content, including the start tag
and end tag. This method provides an empty string
for the qname and an empty attribute list. It invokes
{@link #dataElement(String, String, String, Attributes, String)}}
directly.</p>
@param uri The element's Namespace URI.
@param localName The element's local name.
@param content The character data content.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see org.xml.sax.ContentHandler#startElement
@see #characters(String)
@see org.xml.sax.ContentHandler#endElement | [
"Add",
"an",
"element",
"with",
"character",
"data",
"content",
"but",
"no",
"qname",
"or",
"attributes",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L407-L411 |
23,703 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.dataElement | public void dataElement (String localName, Attributes atts, String content)
throws SAXException
{
dataElement("", localName, "", atts, content);
} | java | public void dataElement (String localName, Attributes atts, String content)
throws SAXException
{
dataElement("", localName, "", atts, content);
} | [
"public",
"void",
"dataElement",
"(",
"String",
"localName",
",",
"Attributes",
"atts",
",",
"String",
"content",
")",
"throws",
"SAXException",
"{",
"dataElement",
"(",
"\"\"",
",",
"localName",
",",
"\"\"",
",",
"atts",
",",
"content",
")",
";",
"}"
] | Add an element with character data content but no Namespace URI or qname.
<p>This is a convenience method to add a complete element
with character data content, including the start tag
and end tag. The method provides an empty string for the
Namespace URI, and empty string for the qualified name. It invokes
{@link #dataElement(String, String, String, Attributes, String)}}
directly.</p>
@param localName The element's local name.
@param atts The element's attributes.
@param content The character data content.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see org.xml.sax.ContentHandler#startElement
@see #characters(String)
@see org.xml.sax.ContentHandler#endElement | [
"Add",
"an",
"element",
"with",
"character",
"data",
"content",
"but",
"no",
"Namespace",
"URI",
"or",
"qname",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L433-L437 |
23,704 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.characters | public void characters (String data)
throws SAXException
{
char ch[] = data.toCharArray();
characters(ch, 0, ch.length);
} | java | public void characters (String data)
throws SAXException
{
char ch[] = data.toCharArray();
characters(ch, 0, ch.length);
} | [
"public",
"void",
"characters",
"(",
"String",
"data",
")",
"throws",
"SAXException",
"{",
"char",
"ch",
"[",
"]",
"=",
"data",
".",
"toCharArray",
"(",
")",
";",
"characters",
"(",
"ch",
",",
"0",
",",
"ch",
".",
"length",
")",
";",
"}"
] | Add a string of character data, with XML escaping.
<p>This is a convenience method that takes an XML
String, converts it to a character array, then invokes
{@link @see org.xml.sax.ContentHandler#characters}.</p>
@param data The character data.
@exception org.xml.sax.SAXException If a filter
further down the chain raises an exception.
@see @see org.xml.sax.ContentHandler#characters | [
"Add",
"a",
"string",
"of",
"character",
"data",
"with",
"XML",
"escaping",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L479-L484 |
23,705 | banq/jdonframework | src/main/java/com/jdon/util/jdom/XMLFilterBase.java | XMLFilterBase.installLexicalHandler | private void installLexicalHandler ()
{
XMLReader parent = getParent();
if (parent == null) {
throw new NullPointerException("No parent for filter");
}
// try to register for lexical events
for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
try {
parent.setProperty(LEXICAL_HANDLER_NAMES[i], this);
break;
}
catch (SAXNotRecognizedException ex) {
// ignore
}
catch (SAXNotSupportedException ex) {
// ignore
}
}
} | java | private void installLexicalHandler ()
{
XMLReader parent = getParent();
if (parent == null) {
throw new NullPointerException("No parent for filter");
}
// try to register for lexical events
for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
try {
parent.setProperty(LEXICAL_HANDLER_NAMES[i], this);
break;
}
catch (SAXNotRecognizedException ex) {
// ignore
}
catch (SAXNotSupportedException ex) {
// ignore
}
}
} | [
"private",
"void",
"installLexicalHandler",
"(",
")",
"{",
"XMLReader",
"parent",
"=",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"==",
"null",
")",
"{",
"throw",
"new",
"NullPointerException",
"(",
"\"No parent for filter\"",
")",
";",
"}",
"// try to register for lexical events\r",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"LEXICAL_HANDLER_NAMES",
".",
"length",
";",
"i",
"++",
")",
"{",
"try",
"{",
"parent",
".",
"setProperty",
"(",
"LEXICAL_HANDLER_NAMES",
"[",
"i",
"]",
",",
"this",
")",
";",
"break",
";",
"}",
"catch",
"(",
"SAXNotRecognizedException",
"ex",
")",
"{",
"// ignore\r",
"}",
"catch",
"(",
"SAXNotSupportedException",
"ex",
")",
"{",
"// ignore\r",
"}",
"}",
"}"
] | Installs lexical handler before a parse.
<p>Before every parse, check whether the parent is
non-null, and re-register the filter for the lexical
events.</p> | [
"Installs",
"lexical",
"handler",
"before",
"a",
"parse",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/jdom/XMLFilterBase.java#L733-L752 |
23,706 | banq/jdonframework | src/main/java/com/jdon/container/factory/ContainerBuilderFactory.java | ContainerBuilderFactory.createContainerBuilder | public synchronized ContainerRegistryBuilder createContainerBuilder(AppContextWrapper context) {
containerLoaderAnnotation.startScan(context);
ContainerFactory containerFactory = new ContainerFactory();
ContainerWrapper cw = containerFactory.create(containerLoaderAnnotation.getConfigInfo());
ContainerComponents configComponents = containerLoaderXML.loadAllContainerConfig(context);
ContainerComponents aspectConfigComponents = containerLoaderXML.loadAllAspectConfig(context);
return createContainerBuilder(context, cw, configComponents, aspectConfigComponents);
} | java | public synchronized ContainerRegistryBuilder createContainerBuilder(AppContextWrapper context) {
containerLoaderAnnotation.startScan(context);
ContainerFactory containerFactory = new ContainerFactory();
ContainerWrapper cw = containerFactory.create(containerLoaderAnnotation.getConfigInfo());
ContainerComponents configComponents = containerLoaderXML.loadAllContainerConfig(context);
ContainerComponents aspectConfigComponents = containerLoaderXML.loadAllAspectConfig(context);
return createContainerBuilder(context, cw, configComponents, aspectConfigComponents);
} | [
"public",
"synchronized",
"ContainerRegistryBuilder",
"createContainerBuilder",
"(",
"AppContextWrapper",
"context",
")",
"{",
"containerLoaderAnnotation",
".",
"startScan",
"(",
"context",
")",
";",
"ContainerFactory",
"containerFactory",
"=",
"new",
"ContainerFactory",
"(",
")",
";",
"ContainerWrapper",
"cw",
"=",
"containerFactory",
".",
"create",
"(",
"containerLoaderAnnotation",
".",
"getConfigInfo",
"(",
")",
")",
";",
"ContainerComponents",
"configComponents",
"=",
"containerLoaderXML",
".",
"loadAllContainerConfig",
"(",
"context",
")",
";",
"ContainerComponents",
"aspectConfigComponents",
"=",
"containerLoaderXML",
".",
"loadAllAspectConfig",
"(",
"context",
")",
";",
"return",
"createContainerBuilder",
"(",
"context",
",",
"cw",
",",
"configComponents",
",",
"aspectConfigComponents",
")",
";",
"}"
] | the main method in this class, read all components include interceptors
from Xml configure file.
create a micro container instance. and then returen a ContainerBuilder
instance
@param context
@return | [
"the",
"main",
"method",
"in",
"this",
"class",
"read",
"all",
"components",
"include",
"interceptors",
"from",
"Xml",
"configure",
"file",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/factory/ContainerBuilderFactory.java#L53-L63 |
23,707 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java | LazyUtil.getHibernateClass | private static Class < ? > getHibernateClass() {
Class < ? > cl = null;
try {
cl = Class.forName(HIBERNATE_CLASS);
} catch (ClassNotFoundException e) {
// in this case jar which contain
// Hibernate class not found
}
return cl;
} | java | private static Class < ? > getHibernateClass() {
Class < ? > cl = null;
try {
cl = Class.forName(HIBERNATE_CLASS);
} catch (ClassNotFoundException e) {
// in this case jar which contain
// Hibernate class not found
}
return cl;
} | [
"private",
"static",
"Class",
"<",
"?",
">",
"getHibernateClass",
"(",
")",
"{",
"Class",
"<",
"?",
">",
"cl",
"=",
"null",
";",
"try",
"{",
"cl",
"=",
"Class",
".",
"forName",
"(",
"HIBERNATE_CLASS",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"// in this case jar which contain \r",
"// Hibernate class not found\r",
"}",
"return",
"cl",
";",
"}"
] | Return Hibernate class instance
@return Hibernate class instance
if it exist | [
"Return",
"Hibernate",
"class",
"instance"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java#L43-L53 |
23,708 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java | LazyUtil.getInitializeMethod | private static Method getInitializeMethod(Class< ? > cl) {
Method method = null;
try {
method = cl.getDeclaredMethod(IS_INITIALIZED, new Class[]{Object.class});
} catch (NoSuchMethodException e) {
//in this case 'isInitialized' method can't be null
}
return method;
} | java | private static Method getInitializeMethod(Class< ? > cl) {
Method method = null;
try {
method = cl.getDeclaredMethod(IS_INITIALIZED, new Class[]{Object.class});
} catch (NoSuchMethodException e) {
//in this case 'isInitialized' method can't be null
}
return method;
} | [
"private",
"static",
"Method",
"getInitializeMethod",
"(",
"Class",
"<",
"?",
">",
"cl",
")",
"{",
"Method",
"method",
"=",
"null",
";",
"try",
"{",
"method",
"=",
"cl",
".",
"getDeclaredMethod",
"(",
"IS_INITIALIZED",
",",
"new",
"Class",
"[",
"]",
"{",
"Object",
".",
"class",
"}",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"//in this case 'isInitialized' method can't be null\r",
"}",
"return",
"method",
";",
"}"
] | Return "isInitialized" Hibernate static method
@param cl - "Hibernate" class instance
@return "isInitialized" Hibernate static method | [
"Return",
"isInitialized",
"Hibernate",
"static",
"method"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java#L60-L69 |
23,709 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java | LazyUtil.checkInitialize | private static boolean checkInitialize(Method method, Object obj) {
boolean isInitialized = true;
try {
isInitialized = (Boolean) method.invoke(null, new Object[] {obj});
} catch (IllegalArgumentException e) {
// do nothing
} catch (IllegalAccessException e) {
// do nothing
} catch (InvocationTargetException e) {
// do nothing
}
return isInitialized;
} | java | private static boolean checkInitialize(Method method, Object obj) {
boolean isInitialized = true;
try {
isInitialized = (Boolean) method.invoke(null, new Object[] {obj});
} catch (IllegalArgumentException e) {
// do nothing
} catch (IllegalAccessException e) {
// do nothing
} catch (InvocationTargetException e) {
// do nothing
}
return isInitialized;
} | [
"private",
"static",
"boolean",
"checkInitialize",
"(",
"Method",
"method",
",",
"Object",
"obj",
")",
"{",
"boolean",
"isInitialized",
"=",
"true",
";",
"try",
"{",
"isInitialized",
"=",
"(",
"Boolean",
")",
"method",
".",
"invoke",
"(",
"null",
",",
"new",
"Object",
"[",
"]",
"{",
"obj",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"// do nothing\r",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"// do nothing\r",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"// do nothing\r",
"}",
"return",
"isInitialized",
";",
"}"
] | Check is current property was initialized
@param method - hibernate static method, which check
is initilized property
@param obj - object which need for lazy check
@return boolean value | [
"Check",
"is",
"current",
"property",
"was",
"initialized"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java#L78-L91 |
23,710 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java | LazyUtil.isPropertyInitialized | public static boolean isPropertyInitialized(Object object) {
Class < ? > cl = getHibernateClass();
if (cl == null) {
return true;
}
Method method = getInitializeMethod(cl);
return checkInitialize(method, object);
} | java | public static boolean isPropertyInitialized(Object object) {
Class < ? > cl = getHibernateClass();
if (cl == null) {
return true;
}
Method method = getInitializeMethod(cl);
return checkInitialize(method, object);
} | [
"public",
"static",
"boolean",
"isPropertyInitialized",
"(",
"Object",
"object",
")",
"{",
"Class",
"<",
"?",
">",
"cl",
"=",
"getHibernateClass",
"(",
")",
";",
"if",
"(",
"cl",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"Method",
"method",
"=",
"getInitializeMethod",
"(",
"cl",
")",
";",
"return",
"checkInitialize",
"(",
"method",
",",
"object",
")",
";",
"}"
] | Check is current object was initialized
@param object - object, which need check
@return boolean value | [
"Check",
"is",
"current",
"object",
"was",
"initialized"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/hessian/io/LazyUtil.java#L98-L107 |
23,711 | banq/jdonframework | src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java | DefaultContainerBuilder.registerAppRoot | public void registerAppRoot(String configureFileName) throws Exception {
try {
AppConfigureCollection existedAppConfigureFiles = (AppConfigureCollection) containerWrapper.lookup(AppConfigureCollection.NAME);
if (existedAppConfigureFiles == null) {
xmlcontainerRegistry.registerAppRoot();
existedAppConfigureFiles = (AppConfigureCollection) containerWrapper.lookup(AppConfigureCollection.NAME);
}
if (!existedAppConfigureFiles.getConfigList().contains(configureFileName)) {
Debug.logInfo("[JdonFramework]found jdonframework configuration:" + configureFileName, module);
existedAppConfigureFiles.addConfigList(configureFileName);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] found jdonframework configuration error:" + ex, module);
throw new Exception(ex);
}
} | java | public void registerAppRoot(String configureFileName) throws Exception {
try {
AppConfigureCollection existedAppConfigureFiles = (AppConfigureCollection) containerWrapper.lookup(AppConfigureCollection.NAME);
if (existedAppConfigureFiles == null) {
xmlcontainerRegistry.registerAppRoot();
existedAppConfigureFiles = (AppConfigureCollection) containerWrapper.lookup(AppConfigureCollection.NAME);
}
if (!existedAppConfigureFiles.getConfigList().contains(configureFileName)) {
Debug.logInfo("[JdonFramework]found jdonframework configuration:" + configureFileName, module);
existedAppConfigureFiles.addConfigList(configureFileName);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] found jdonframework configuration error:" + ex, module);
throw new Exception(ex);
}
} | [
"public",
"void",
"registerAppRoot",
"(",
"String",
"configureFileName",
")",
"throws",
"Exception",
"{",
"try",
"{",
"AppConfigureCollection",
"existedAppConfigureFiles",
"=",
"(",
"AppConfigureCollection",
")",
"containerWrapper",
".",
"lookup",
"(",
"AppConfigureCollection",
".",
"NAME",
")",
";",
"if",
"(",
"existedAppConfigureFiles",
"==",
"null",
")",
"{",
"xmlcontainerRegistry",
".",
"registerAppRoot",
"(",
")",
";",
"existedAppConfigureFiles",
"=",
"(",
"AppConfigureCollection",
")",
"containerWrapper",
".",
"lookup",
"(",
"AppConfigureCollection",
".",
"NAME",
")",
";",
"}",
"if",
"(",
"!",
"existedAppConfigureFiles",
".",
"getConfigList",
"(",
")",
".",
"contains",
"(",
"configureFileName",
")",
")",
"{",
"Debug",
".",
"logInfo",
"(",
"\"[JdonFramework]found jdonframework configuration:\"",
"+",
"configureFileName",
",",
"module",
")",
";",
"existedAppConfigureFiles",
".",
"addConfigList",
"(",
"configureFileName",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] found jdonframework configuration error:\"",
"+",
"ex",
",",
"module",
")",
";",
"throw",
"new",
"Exception",
"(",
"ex",
")",
";",
"}",
"}"
] | if there are xml configure then add new ones; if not, register it;
@param configList
Collection the configure collection for jdonframework.xml | [
"if",
"there",
"are",
"xml",
"configure",
"then",
"add",
"new",
"ones",
";",
"if",
"not",
"register",
"it",
";"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java#L77-L92 |
23,712 | banq/jdonframework | src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java | DefaultContainerBuilder.registerComponents | public void registerComponents() throws Exception {
Debug.logVerbose("[JdonFramework] note: registe all basic components in container.xml size=" + basicComponents.size(), module);
try {
Iterator iter = basicComponents.iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
ComponentMetaDef componentMetaDef = basicComponents.getComponentMetaDef(name);
xmlcontainerRegistry.registerComponentMetaDef(componentMetaDef);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] register basiceComponents error:" + ex, module);
throw new Exception(ex);
}
} | java | public void registerComponents() throws Exception {
Debug.logVerbose("[JdonFramework] note: registe all basic components in container.xml size=" + basicComponents.size(), module);
try {
Iterator iter = basicComponents.iterator();
while (iter.hasNext()) {
String name = (String) iter.next();
ComponentMetaDef componentMetaDef = basicComponents.getComponentMetaDef(name);
xmlcontainerRegistry.registerComponentMetaDef(componentMetaDef);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] register basiceComponents error:" + ex, module);
throw new Exception(ex);
}
} | [
"public",
"void",
"registerComponents",
"(",
")",
"throws",
"Exception",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] note: registe all basic components in container.xml size=\"",
"+",
"basicComponents",
".",
"size",
"(",
")",
",",
"module",
")",
";",
"try",
"{",
"Iterator",
"iter",
"=",
"basicComponents",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"name",
"=",
"(",
"String",
")",
"iter",
".",
"next",
"(",
")",
";",
"ComponentMetaDef",
"componentMetaDef",
"=",
"basicComponents",
".",
"getComponentMetaDef",
"(",
"name",
")",
";",
"xmlcontainerRegistry",
".",
"registerComponentMetaDef",
"(",
"componentMetaDef",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] register basiceComponents error:\"",
"+",
"ex",
",",
"module",
")",
";",
"throw",
"new",
"Exception",
"(",
"ex",
")",
";",
"}",
"}"
] | register all basic components in container.xml | [
"register",
"all",
"basic",
"components",
"in",
"container",
".",
"xml"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java#L97-L111 |
23,713 | banq/jdonframework | src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java | DefaultContainerBuilder.registerAspectComponents | public void registerAspectComponents() throws Exception {
Debug.logVerbose("[JdonFramework] note: registe aspect components ", module);
try {
InterceptorsChain existedInterceptorsChain = (InterceptorsChain) containerWrapper.lookup(ComponentKeys.INTERCEPTOR_CHAIN);
Iterator iter = aspectConfigComponents.iterator();
Debug.logVerbose("[JdonFramework] 3 aspectConfigComponents size:" + aspectConfigComponents.size(), module);
while (iter.hasNext()) {
String name = (String) iter.next();
AspectComponentsMetaDef componentMetaDef = (AspectComponentsMetaDef) aspectConfigComponents.getComponentMetaDef(name);
// registe into container
xmlcontainerRegistry.registerAspectComponentMetaDef(componentMetaDef);
// got the interceptor instance;
// add interceptor instance into InterceptorsChain object
existedInterceptorsChain.addInterceptor(componentMetaDef.getPointcut(), name);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] registerAspectComponents error:" + ex, module);
throw new Exception(ex);
}
} | java | public void registerAspectComponents() throws Exception {
Debug.logVerbose("[JdonFramework] note: registe aspect components ", module);
try {
InterceptorsChain existedInterceptorsChain = (InterceptorsChain) containerWrapper.lookup(ComponentKeys.INTERCEPTOR_CHAIN);
Iterator iter = aspectConfigComponents.iterator();
Debug.logVerbose("[JdonFramework] 3 aspectConfigComponents size:" + aspectConfigComponents.size(), module);
while (iter.hasNext()) {
String name = (String) iter.next();
AspectComponentsMetaDef componentMetaDef = (AspectComponentsMetaDef) aspectConfigComponents.getComponentMetaDef(name);
// registe into container
xmlcontainerRegistry.registerAspectComponentMetaDef(componentMetaDef);
// got the interceptor instance;
// add interceptor instance into InterceptorsChain object
existedInterceptorsChain.addInterceptor(componentMetaDef.getPointcut(), name);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] registerAspectComponents error:" + ex, module);
throw new Exception(ex);
}
} | [
"public",
"void",
"registerAspectComponents",
"(",
")",
"throws",
"Exception",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] note: registe aspect components \"",
",",
"module",
")",
";",
"try",
"{",
"InterceptorsChain",
"existedInterceptorsChain",
"=",
"(",
"InterceptorsChain",
")",
"containerWrapper",
".",
"lookup",
"(",
"ComponentKeys",
".",
"INTERCEPTOR_CHAIN",
")",
";",
"Iterator",
"iter",
"=",
"aspectConfigComponents",
".",
"iterator",
"(",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] 3 aspectConfigComponents size:\"",
"+",
"aspectConfigComponents",
".",
"size",
"(",
")",
",",
"module",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"name",
"=",
"(",
"String",
")",
"iter",
".",
"next",
"(",
")",
";",
"AspectComponentsMetaDef",
"componentMetaDef",
"=",
"(",
"AspectComponentsMetaDef",
")",
"aspectConfigComponents",
".",
"getComponentMetaDef",
"(",
"name",
")",
";",
"// registe into container\r",
"xmlcontainerRegistry",
".",
"registerAspectComponentMetaDef",
"(",
"componentMetaDef",
")",
";",
"// got the interceptor instance;\r",
"// add interceptor instance into InterceptorsChain object\r",
"existedInterceptorsChain",
".",
"addInterceptor",
"(",
"componentMetaDef",
".",
"getPointcut",
"(",
")",
",",
"name",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] registerAspectComponents error:\"",
"+",
"ex",
",",
"module",
")",
";",
"throw",
"new",
"Exception",
"(",
"ex",
")",
";",
"}",
"}"
] | register all apsect components in aspect.xml | [
"register",
"all",
"apsect",
"components",
"in",
"aspect",
".",
"xml"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/builder/DefaultContainerBuilder.java#L116-L137 |
23,714 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.createFile | public static void createFile(String output, String content) throws Exception {
OutputStreamWriter fw = null;
PrintWriter out = null;
try {
if (ENCODING == null)
ENCODING = PropsUtil.ENCODING;
fw = new OutputStreamWriter(new FileOutputStream(output), ENCODING);
out = new PrintWriter(fw);
out.print(content);
} catch (Exception ex) {
throw new Exception(ex);
} finally {
if (out != null)
out.close();
if (fw != null)
fw.close();
}
} | java | public static void createFile(String output, String content) throws Exception {
OutputStreamWriter fw = null;
PrintWriter out = null;
try {
if (ENCODING == null)
ENCODING = PropsUtil.ENCODING;
fw = new OutputStreamWriter(new FileOutputStream(output), ENCODING);
out = new PrintWriter(fw);
out.print(content);
} catch (Exception ex) {
throw new Exception(ex);
} finally {
if (out != null)
out.close();
if (fw != null)
fw.close();
}
} | [
"public",
"static",
"void",
"createFile",
"(",
"String",
"output",
",",
"String",
"content",
")",
"throws",
"Exception",
"{",
"OutputStreamWriter",
"fw",
"=",
"null",
";",
"PrintWriter",
"out",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"ENCODING",
"==",
"null",
")",
"ENCODING",
"=",
"PropsUtil",
".",
"ENCODING",
";",
"fw",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"output",
")",
",",
"ENCODING",
")",
";",
"out",
"=",
"new",
"PrintWriter",
"(",
"fw",
")",
";",
"out",
".",
"print",
"(",
"content",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"out",
"!=",
"null",
")",
"out",
".",
"close",
"(",
")",
";",
"if",
"(",
"fw",
"!=",
"null",
")",
"fw",
".",
"close",
"(",
")",
";",
"}",
"}"
] | write the content to a file;
@param output
@param content
@throws Exception | [
"write",
"the",
"content",
"to",
"a",
"file",
";"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L38-L57 |
23,715 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.readFile | public static String readFile(String input) throws Exception {
char[] buffer = new char[4096];
int len = 0;
StringBuilder content = new StringBuilder(4096);
if (ENCODING == null)
ENCODING = PropsUtil.ENCODING;
InputStreamReader fr = null;
BufferedReader br = null;
try {
fr = new InputStreamReader(new FileInputStream(input), ENCODING);
br = new BufferedReader(fr);
while ((len = br.read(buffer)) > -1) {
content.append(buffer, 0, len);
}
} catch (Exception e) {
throw new Exception(e);
} finally {
if (br != null)
br.close();
if (fr != null)
fr.close();
}
return content.toString();
} | java | public static String readFile(String input) throws Exception {
char[] buffer = new char[4096];
int len = 0;
StringBuilder content = new StringBuilder(4096);
if (ENCODING == null)
ENCODING = PropsUtil.ENCODING;
InputStreamReader fr = null;
BufferedReader br = null;
try {
fr = new InputStreamReader(new FileInputStream(input), ENCODING);
br = new BufferedReader(fr);
while ((len = br.read(buffer)) > -1) {
content.append(buffer, 0, len);
}
} catch (Exception e) {
throw new Exception(e);
} finally {
if (br != null)
br.close();
if (fr != null)
fr.close();
}
return content.toString();
} | [
"public",
"static",
"String",
"readFile",
"(",
"String",
"input",
")",
"throws",
"Exception",
"{",
"char",
"[",
"]",
"buffer",
"=",
"new",
"char",
"[",
"4096",
"]",
";",
"int",
"len",
"=",
"0",
";",
"StringBuilder",
"content",
"=",
"new",
"StringBuilder",
"(",
"4096",
")",
";",
"if",
"(",
"ENCODING",
"==",
"null",
")",
"ENCODING",
"=",
"PropsUtil",
".",
"ENCODING",
";",
"InputStreamReader",
"fr",
"=",
"null",
";",
"BufferedReader",
"br",
"=",
"null",
";",
"try",
"{",
"fr",
"=",
"new",
"InputStreamReader",
"(",
"new",
"FileInputStream",
"(",
"input",
")",
",",
"ENCODING",
")",
";",
"br",
"=",
"new",
"BufferedReader",
"(",
"fr",
")",
";",
"while",
"(",
"(",
"len",
"=",
"br",
".",
"read",
"(",
"buffer",
")",
")",
">",
"-",
"1",
")",
"{",
"content",
".",
"append",
"(",
"buffer",
",",
"0",
",",
"len",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"e",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"br",
"!=",
"null",
")",
"br",
".",
"close",
"(",
")",
";",
"if",
"(",
"fr",
"!=",
"null",
")",
"fr",
".",
"close",
"(",
")",
";",
"}",
"return",
"content",
".",
"toString",
"(",
")",
";",
"}"
] | read the content from a file;
@param output
@param content
@throws Exception | [
"read",
"the",
"content",
"from",
"a",
"file",
";"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L66-L90 |
23,716 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.move | public static void move(String input, String output) throws Exception {
File inputFile = new File(input);
File outputFile = new File(output);
try {
inputFile.renameTo(outputFile);
} catch (Exception ex) {
throw new Exception("Can not mv" + input + " to " + output + ex.getMessage());
}
} | java | public static void move(String input, String output) throws Exception {
File inputFile = new File(input);
File outputFile = new File(output);
try {
inputFile.renameTo(outputFile);
} catch (Exception ex) {
throw new Exception("Can not mv" + input + " to " + output + ex.getMessage());
}
} | [
"public",
"static",
"void",
"move",
"(",
"String",
"input",
",",
"String",
"output",
")",
"throws",
"Exception",
"{",
"File",
"inputFile",
"=",
"new",
"File",
"(",
"input",
")",
";",
"File",
"outputFile",
"=",
"new",
"File",
"(",
"output",
")",
";",
"try",
"{",
"inputFile",
".",
"renameTo",
"(",
"outputFile",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Can not mv\"",
"+",
"input",
"+",
"\" to \"",
"+",
"output",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | This class moves an input file to output file
@param String
input file to move from
@param String
output file | [
"This",
"class",
"moves",
"an",
"input",
"file",
"to",
"output",
"file"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L101-L109 |
23,717 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.copy | public static boolean copy(String input, String output) throws Exception {
int BUFSIZE = 65536;
FileInputStream fis = new FileInputStream(input);
FileOutputStream fos = new FileOutputStream(output);
try {
int s;
byte[] buf = new byte[BUFSIZE];
while ((s = fis.read(buf)) > -1) {
fos.write(buf, 0, s);
}
} catch (Exception ex) {
throw new Exception("makehome" + ex.getMessage());
} finally {
fis.close();
fos.close();
}
return true;
} | java | public static boolean copy(String input, String output) throws Exception {
int BUFSIZE = 65536;
FileInputStream fis = new FileInputStream(input);
FileOutputStream fos = new FileOutputStream(output);
try {
int s;
byte[] buf = new byte[BUFSIZE];
while ((s = fis.read(buf)) > -1) {
fos.write(buf, 0, s);
}
} catch (Exception ex) {
throw new Exception("makehome" + ex.getMessage());
} finally {
fis.close();
fos.close();
}
return true;
} | [
"public",
"static",
"boolean",
"copy",
"(",
"String",
"input",
",",
"String",
"output",
")",
"throws",
"Exception",
"{",
"int",
"BUFSIZE",
"=",
"65536",
";",
"FileInputStream",
"fis",
"=",
"new",
"FileInputStream",
"(",
"input",
")",
";",
"FileOutputStream",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"output",
")",
";",
"try",
"{",
"int",
"s",
";",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"BUFSIZE",
"]",
";",
"while",
"(",
"(",
"s",
"=",
"fis",
".",
"read",
"(",
"buf",
")",
")",
">",
"-",
"1",
")",
"{",
"fos",
".",
"write",
"(",
"buf",
",",
"0",
",",
"s",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"makehome\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"fis",
".",
"close",
"(",
")",
";",
"fos",
".",
"close",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | This class copies an input file to output file
@param String
input file to copy from
@param String
output file | [
"This",
"class",
"copies",
"an",
"input",
"file",
"to",
"output",
"file"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L119-L138 |
23,718 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.CopyDir | public static void CopyDir(String sourcedir, String destdir) throws Exception {
File dest = new File(destdir);
File source = new File(sourcedir);
String[] files = source.list();
try {
makehome(destdir);
} catch (Exception ex) {
throw new Exception("CopyDir:" + ex.getMessage());
}
for (int i = 0; i < files.length; i++) {
String sourcefile = source + File.separator + files[i];
String destfile = dest + File.separator + files[i];
File temp = new File(sourcefile);
if (temp.isFile()) {
try {
copy(sourcefile, destfile);
} catch (Exception ex) {
throw new Exception("CopyDir:" + ex.getMessage());
}
}
}
} | java | public static void CopyDir(String sourcedir, String destdir) throws Exception {
File dest = new File(destdir);
File source = new File(sourcedir);
String[] files = source.list();
try {
makehome(destdir);
} catch (Exception ex) {
throw new Exception("CopyDir:" + ex.getMessage());
}
for (int i = 0; i < files.length; i++) {
String sourcefile = source + File.separator + files[i];
String destfile = dest + File.separator + files[i];
File temp = new File(sourcefile);
if (temp.isFile()) {
try {
copy(sourcefile, destfile);
} catch (Exception ex) {
throw new Exception("CopyDir:" + ex.getMessage());
}
}
}
} | [
"public",
"static",
"void",
"CopyDir",
"(",
"String",
"sourcedir",
",",
"String",
"destdir",
")",
"throws",
"Exception",
"{",
"File",
"dest",
"=",
"new",
"File",
"(",
"destdir",
")",
";",
"File",
"source",
"=",
"new",
"File",
"(",
"sourcedir",
")",
";",
"String",
"[",
"]",
"files",
"=",
"source",
".",
"list",
"(",
")",
";",
"try",
"{",
"makehome",
"(",
"destdir",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"CopyDir:\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"files",
".",
"length",
";",
"i",
"++",
")",
"{",
"String",
"sourcefile",
"=",
"source",
"+",
"File",
".",
"separator",
"+",
"files",
"[",
"i",
"]",
";",
"String",
"destfile",
"=",
"dest",
"+",
"File",
".",
"separator",
"+",
"files",
"[",
"i",
"]",
";",
"File",
"temp",
"=",
"new",
"File",
"(",
"sourcefile",
")",
";",
"if",
"(",
"temp",
".",
"isFile",
"(",
")",
")",
"{",
"try",
"{",
"copy",
"(",
"sourcefile",
",",
"destfile",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"CopyDir:\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}"
] | This class copies an input files of a directory to another directory not
include subdir
@param String
sourcedir the directory to copy from such as:/home/bqlr/images
@param String
destdir the target directory | [
"This",
"class",
"copies",
"an",
"input",
"files",
"of",
"a",
"directory",
"to",
"another",
"directory",
"not",
"include",
"subdir"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L166-L189 |
23,719 | banq/jdonframework | src/main/java/com/jdon/util/FileUtil.java | FileUtil.recursiveRemoveDir | public static void recursiveRemoveDir(File directory) throws Exception {
if (!directory.exists())
throw new IOException(directory.toString() + " do not exist!");
String[] filelist = directory.list();
File tmpFile = null;
for (int i = 0; i < filelist.length; i++) {
tmpFile = new File(directory.getAbsolutePath(), filelist[i]);
if (tmpFile.isDirectory()) {
recursiveRemoveDir(tmpFile);
} else if (tmpFile.isFile()) {
try {
tmpFile.delete();
} catch (Exception ex) {
throw new Exception(tmpFile.toString() + " can not be deleted " + ex.getMessage());
}
}
}
try {
directory.delete();
} catch (Exception ex) {
throw new Exception(directory.toString() + " can not be deleted " + ex.getMessage());
} finally {
filelist = null;
}
} | java | public static void recursiveRemoveDir(File directory) throws Exception {
if (!directory.exists())
throw new IOException(directory.toString() + " do not exist!");
String[] filelist = directory.list();
File tmpFile = null;
for (int i = 0; i < filelist.length; i++) {
tmpFile = new File(directory.getAbsolutePath(), filelist[i]);
if (tmpFile.isDirectory()) {
recursiveRemoveDir(tmpFile);
} else if (tmpFile.isFile()) {
try {
tmpFile.delete();
} catch (Exception ex) {
throw new Exception(tmpFile.toString() + " can not be deleted " + ex.getMessage());
}
}
}
try {
directory.delete();
} catch (Exception ex) {
throw new Exception(directory.toString() + " can not be deleted " + ex.getMessage());
} finally {
filelist = null;
}
} | [
"public",
"static",
"void",
"recursiveRemoveDir",
"(",
"File",
"directory",
")",
"throws",
"Exception",
"{",
"if",
"(",
"!",
"directory",
".",
"exists",
"(",
")",
")",
"throw",
"new",
"IOException",
"(",
"directory",
".",
"toString",
"(",
")",
"+",
"\" do not exist!\"",
")",
";",
"String",
"[",
"]",
"filelist",
"=",
"directory",
".",
"list",
"(",
")",
";",
"File",
"tmpFile",
"=",
"null",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"filelist",
".",
"length",
";",
"i",
"++",
")",
"{",
"tmpFile",
"=",
"new",
"File",
"(",
"directory",
".",
"getAbsolutePath",
"(",
")",
",",
"filelist",
"[",
"i",
"]",
")",
";",
"if",
"(",
"tmpFile",
".",
"isDirectory",
"(",
")",
")",
"{",
"recursiveRemoveDir",
"(",
"tmpFile",
")",
";",
"}",
"else",
"if",
"(",
"tmpFile",
".",
"isFile",
"(",
")",
")",
"{",
"try",
"{",
"tmpFile",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"tmpFile",
".",
"toString",
"(",
")",
"+",
"\" can not be deleted \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"try",
"{",
"directory",
".",
"delete",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"directory",
".",
"toString",
"(",
")",
"+",
"\" can not be deleted \"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"finally",
"{",
"filelist",
"=",
"null",
";",
"}",
"}"
] | This class del a directory recursively,that means delete all files and
directorys.
@param File
directory the directory that will be deleted. | [
"This",
"class",
"del",
"a",
"directory",
"recursively",
"that",
"means",
"delete",
"all",
"files",
"and",
"directorys",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileUtil.java#L198-L223 |
23,720 | banq/jdonframework | src/main/java/com/jdon/container/access/UserTargetMetaDefFactory.java | UserTargetMetaDefFactory.createTargetMetaRequest | public void createTargetMetaRequest(TargetMetaDef targetMetaDef, ContextHolder holder) {
ContainerWrapper containerWrapper = servletContainerFinder.findContainer(holder.getAppContextHolder());
// get HttpSessionVisitorFactoryImp
VisitorFactory visitorFactory = (VisitorFactory) containerWrapper.lookup(ComponentKeys.VISITOR_FACTORY);
// ComponentVisitor is HttpSessionComponentVisitor
ComponentVisitor cm = visitorFactory.createtVisitor(holder.getSessionHolder(), targetMetaDef);
TargetMetaRequest targetMetaRequest = new TargetMetaRequest(targetMetaDef, cm);
targetMetaRequestsHolder.setTargetMetaRequest(targetMetaRequest);
} | java | public void createTargetMetaRequest(TargetMetaDef targetMetaDef, ContextHolder holder) {
ContainerWrapper containerWrapper = servletContainerFinder.findContainer(holder.getAppContextHolder());
// get HttpSessionVisitorFactoryImp
VisitorFactory visitorFactory = (VisitorFactory) containerWrapper.lookup(ComponentKeys.VISITOR_FACTORY);
// ComponentVisitor is HttpSessionComponentVisitor
ComponentVisitor cm = visitorFactory.createtVisitor(holder.getSessionHolder(), targetMetaDef);
TargetMetaRequest targetMetaRequest = new TargetMetaRequest(targetMetaDef, cm);
targetMetaRequestsHolder.setTargetMetaRequest(targetMetaRequest);
} | [
"public",
"void",
"createTargetMetaRequest",
"(",
"TargetMetaDef",
"targetMetaDef",
",",
"ContextHolder",
"holder",
")",
"{",
"ContainerWrapper",
"containerWrapper",
"=",
"servletContainerFinder",
".",
"findContainer",
"(",
"holder",
".",
"getAppContextHolder",
"(",
")",
")",
";",
"// get HttpSessionVisitorFactoryImp\r",
"VisitorFactory",
"visitorFactory",
"=",
"(",
"VisitorFactory",
")",
"containerWrapper",
".",
"lookup",
"(",
"ComponentKeys",
".",
"VISITOR_FACTORY",
")",
";",
"// ComponentVisitor is HttpSessionComponentVisitor\r",
"ComponentVisitor",
"cm",
"=",
"visitorFactory",
".",
"createtVisitor",
"(",
"holder",
".",
"getSessionHolder",
"(",
")",
",",
"targetMetaDef",
")",
";",
"TargetMetaRequest",
"targetMetaRequest",
"=",
"new",
"TargetMetaRequest",
"(",
"targetMetaDef",
",",
"cm",
")",
";",
"targetMetaRequestsHolder",
".",
"setTargetMetaRequest",
"(",
"targetMetaRequest",
")",
";",
"}"
] | create a targetMetaRequest instance.
@param containerWrapper
@param targetMetaDef
@param request
@return | [
"create",
"a",
"targetMetaRequest",
"instance",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/access/UserTargetMetaDefFactory.java#L60-L68 |
23,721 | banq/jdonframework | src/main/java/com/jdon/domain/message/DomainMessage.java | DomainMessage.getEventResult | public Object getEventResult() {
Object result = eventResultCache.get();
if (result != null) {
return result;
}
if (eventResultHandler != null) {
result = eventResultHandler.get();
if (result != null){
if (!eventResultCache.compareAndSet(null, result)){
result = eventResultCache.get();
}
}
}
return result;
} | java | public Object getEventResult() {
Object result = eventResultCache.get();
if (result != null) {
return result;
}
if (eventResultHandler != null) {
result = eventResultHandler.get();
if (result != null){
if (!eventResultCache.compareAndSet(null, result)){
result = eventResultCache.get();
}
}
}
return result;
} | [
"public",
"Object",
"getEventResult",
"(",
")",
"{",
"Object",
"result",
"=",
"eventResultCache",
".",
"get",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"return",
"result",
";",
"}",
"if",
"(",
"eventResultHandler",
"!=",
"null",
")",
"{",
"result",
"=",
"eventResultHandler",
".",
"get",
"(",
")",
";",
"if",
"(",
"result",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"eventResultCache",
".",
"compareAndSet",
"(",
"null",
",",
"result",
")",
")",
"{",
"result",
"=",
"eventResultCache",
".",
"get",
"(",
")",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}"
] | get a Event Result until time out value
@return Event Result | [
"get",
"a",
"Event",
"Result",
"until",
"time",
"out",
"value"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/domain/message/DomainMessage.java#L73-L88 |
23,722 | banq/jdonframework | src/main/java/com/jdon/container/visitor/ComponentOriginalVisitor.java | ComponentOriginalVisitor.visit | public Object visit() {
Object o = null;
try {
ContainerWrapper containerWrapper = containerCallback.getContainerWrapper();
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
Debug.logVerbose("[JdonFramework] ComponentOriginalVisitor active:" + targetMetaRequest.getVisitableName(), module);
//targetMetaRequest.setVisitableName change the value
Visitable vo = (Visitable) containerWrapper.lookup(targetMetaRequest.getVisitableName());
o = vo.accept();
} catch (Exception ex) {
Debug.logError("[JdonFramework] ComponentOriginalVisitor active error: " + ex);
}
return o;
} | java | public Object visit() {
Object o = null;
try {
ContainerWrapper containerWrapper = containerCallback.getContainerWrapper();
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
Debug.logVerbose("[JdonFramework] ComponentOriginalVisitor active:" + targetMetaRequest.getVisitableName(), module);
//targetMetaRequest.setVisitableName change the value
Visitable vo = (Visitable) containerWrapper.lookup(targetMetaRequest.getVisitableName());
o = vo.accept();
} catch (Exception ex) {
Debug.logError("[JdonFramework] ComponentOriginalVisitor active error: " + ex);
}
return o;
} | [
"public",
"Object",
"visit",
"(",
")",
"{",
"Object",
"o",
"=",
"null",
";",
"try",
"{",
"ContainerWrapper",
"containerWrapper",
"=",
"containerCallback",
".",
"getContainerWrapper",
"(",
")",
";",
"TargetMetaRequest",
"targetMetaRequest",
"=",
"targetMetaRequestsHolder",
".",
"getTargetMetaRequest",
"(",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] ComponentOriginalVisitor active:\"",
"+",
"targetMetaRequest",
".",
"getVisitableName",
"(",
")",
",",
"module",
")",
";",
"//targetMetaRequest.setVisitableName change the value\r",
"Visitable",
"vo",
"=",
"(",
"Visitable",
")",
"containerWrapper",
".",
"lookup",
"(",
"targetMetaRequest",
".",
"getVisitableName",
"(",
")",
")",
";",
"o",
"=",
"vo",
".",
"accept",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] ComponentOriginalVisitor active error: \"",
"+",
"ex",
")",
";",
"}",
"return",
"o",
";",
"}"
] | find the visitable component from container, and execute it's accept
method, the return result is the tager service object. | [
"find",
"the",
"visitable",
"component",
"from",
"container",
"and",
"execute",
"it",
"s",
"accept",
"method",
"the",
"return",
"result",
"is",
"the",
"tager",
"service",
"object",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/visitor/ComponentOriginalVisitor.java#L55-L68 |
23,723 | banq/jdonframework | JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/handler/HandlerMethodMetaArgsFactory.java | HandlerMethodMetaArgsFactory.createinitMethod | public MethodMetaArgs createinitMethod(HandlerMetaDef handlerMetaDef, EventModel em) {
String p_methodName = handlerMetaDef.getInitMethod();
if (p_methodName == null)
return null;
return createCRUDMethodMetaArgs(p_methodName, em);
} | java | public MethodMetaArgs createinitMethod(HandlerMetaDef handlerMetaDef, EventModel em) {
String p_methodName = handlerMetaDef.getInitMethod();
if (p_methodName == null)
return null;
return createCRUDMethodMetaArgs(p_methodName, em);
} | [
"public",
"MethodMetaArgs",
"createinitMethod",
"(",
"HandlerMetaDef",
"handlerMetaDef",
",",
"EventModel",
"em",
")",
"{",
"String",
"p_methodName",
"=",
"handlerMetaDef",
".",
"getInitMethod",
"(",
")",
";",
"if",
"(",
"p_methodName",
"==",
"null",
")",
"return",
"null",
";",
"return",
"createCRUDMethodMetaArgs",
"(",
"p_methodName",
",",
"em",
")",
";",
"}"
] | create init method
@param handlerMetaDef
@return MethodMetaArgs instance | [
"create",
"init",
"method"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/handler/HandlerMethodMetaArgsFactory.java#L46-L51 |
23,724 | banq/jdonframework | JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/handler/HandlerMethodMetaArgsFactory.java | HandlerMethodMetaArgsFactory.createGetMethod | public MethodMetaArgs createGetMethod(HandlerMetaDef handlerMetaDef, Object keyValue) {
String p_methodName = handlerMetaDef.getFindMethod();
if (p_methodName == null) {
Debug.logError("[JdonFramework] not configure the findMethod parameter: <getMethod name=XXXXX /> ", module);
}
if (keyValue == null) {
Debug.logError("[JdonFramework] not found model's key value:" + handlerMetaDef.getModelMapping().getKeyName()
+ "=? in request parameters", module);
}
return createCRUDMethodMetaArgs(p_methodName, keyValue);
} | java | public MethodMetaArgs createGetMethod(HandlerMetaDef handlerMetaDef, Object keyValue) {
String p_methodName = handlerMetaDef.getFindMethod();
if (p_methodName == null) {
Debug.logError("[JdonFramework] not configure the findMethod parameter: <getMethod name=XXXXX /> ", module);
}
if (keyValue == null) {
Debug.logError("[JdonFramework] not found model's key value:" + handlerMetaDef.getModelMapping().getKeyName()
+ "=? in request parameters", module);
}
return createCRUDMethodMetaArgs(p_methodName, keyValue);
} | [
"public",
"MethodMetaArgs",
"createGetMethod",
"(",
"HandlerMetaDef",
"handlerMetaDef",
",",
"Object",
"keyValue",
")",
"{",
"String",
"p_methodName",
"=",
"handlerMetaDef",
".",
"getFindMethod",
"(",
")",
";",
"if",
"(",
"p_methodName",
"==",
"null",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] not configure the findMethod parameter: <getMethod name=XXXXX /> \"",
",",
"module",
")",
";",
"}",
"if",
"(",
"keyValue",
"==",
"null",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] not found model's key value:\"",
"+",
"handlerMetaDef",
".",
"getModelMapping",
"(",
")",
".",
"getKeyName",
"(",
")",
"+",
"\"=? in request parameters\"",
",",
"module",
")",
";",
"}",
"return",
"createCRUDMethodMetaArgs",
"(",
"p_methodName",
",",
"keyValue",
")",
";",
"}"
] | create find method the service's find method parameter type must be
String type
@param handlerMetaDef
@param keyValue
@return MethodMetaArgs instance | [
"create",
"find",
"method",
"the",
"service",
"s",
"find",
"method",
"parameter",
"type",
"must",
"be",
"String",
"type"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-struts1x/src/main/java/com/jdon/model/handler/HandlerMethodMetaArgsFactory.java#L61-L72 |
23,725 | banq/jdonframework | src/main/java/com/jdon/aop/interceptor/SessionContextInterceptor.java | SessionContextInterceptor.setSessionContext | private void setSessionContext(Object targetObject, TargetMetaRequest targetMetaRequest) {
if (isSessionContextAcceptables.contains(targetMetaRequest.getTargetMetaDef().getName())) {
SessionContextAcceptable myResult = (SessionContextAcceptable) targetObject;
SessionContext sessionContext = targetMetaRequest.getSessionContext();
myResult.setSessionContext(sessionContext);
} else if (isSessionContextAcceptablesAnnotations.containsKey(targetMetaRequest.getTargetMetaDef().getName())) {
Method method = isSessionContextAcceptablesAnnotations.get(targetMetaRequest.getTargetMetaDef().getName());
try {
Object[] sessionContexts = new SessionContext[1];
sessionContexts[0] = targetMetaRequest.getSessionContext();
method.invoke(targetObject, sessionContexts);
} catch (Exception e) {
Debug.logError("[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : " + e, module);
}
}
} | java | private void setSessionContext(Object targetObject, TargetMetaRequest targetMetaRequest) {
if (isSessionContextAcceptables.contains(targetMetaRequest.getTargetMetaDef().getName())) {
SessionContextAcceptable myResult = (SessionContextAcceptable) targetObject;
SessionContext sessionContext = targetMetaRequest.getSessionContext();
myResult.setSessionContext(sessionContext);
} else if (isSessionContextAcceptablesAnnotations.containsKey(targetMetaRequest.getTargetMetaDef().getName())) {
Method method = isSessionContextAcceptablesAnnotations.get(targetMetaRequest.getTargetMetaDef().getName());
try {
Object[] sessionContexts = new SessionContext[1];
sessionContexts[0] = targetMetaRequest.getSessionContext();
method.invoke(targetObject, sessionContexts);
} catch (Exception e) {
Debug.logError("[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : " + e, module);
}
}
} | [
"private",
"void",
"setSessionContext",
"(",
"Object",
"targetObject",
",",
"TargetMetaRequest",
"targetMetaRequest",
")",
"{",
"if",
"(",
"isSessionContextAcceptables",
".",
"contains",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"SessionContextAcceptable",
"myResult",
"=",
"(",
"SessionContextAcceptable",
")",
"targetObject",
";",
"SessionContext",
"sessionContext",
"=",
"targetMetaRequest",
".",
"getSessionContext",
"(",
")",
";",
"myResult",
".",
"setSessionContext",
"(",
"sessionContext",
")",
";",
"}",
"else",
"if",
"(",
"isSessionContextAcceptablesAnnotations",
".",
"containsKey",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
")",
"{",
"Method",
"method",
"=",
"isSessionContextAcceptablesAnnotations",
".",
"get",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"try",
"{",
"Object",
"[",
"]",
"sessionContexts",
"=",
"new",
"SessionContext",
"[",
"1",
"]",
";",
"sessionContexts",
"[",
"0",
"]",
"=",
"targetMetaRequest",
".",
"getSessionContext",
"(",
")",
";",
"method",
".",
"invoke",
"(",
"targetObject",
",",
"sessionContexts",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework]the target must has method setSessionContext(SessionContext sessionContext) : \"",
"+",
"e",
",",
"module",
")",
";",
"}",
"}",
"}"
] | WebServiceAccessorImp create sessionContext and save infomation into it | [
"WebServiceAccessorImp",
"create",
"sessionContext",
"and",
"save",
"infomation",
"into",
"it"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/interceptor/SessionContextInterceptor.java#L137-L153 |
23,726 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java | HttpClient.invoke | public Object invoke(TargetMetaDef targetMetaDef, Method m, Object[] args) throws Throwable {
Object result = null;
getThreadLock();
int currentRequestNb = requestNb++;
Debug.logVerbose("[JdonFramework]Start remote call " + currentRequestNb + " " + m.getName(), module);
// 准备参数
HttpRequest request = new HttpRequest(targetMetaDef, m.getName(), m.getParameterTypes(), args);
StringBuilder sb = new StringBuilder(httpServerParam.getServletPath().toString());
if (sessionId != null) {
sb.append(";jsessionid=");
sb.append(sessionId);
}
httpServerParam.setServletPath(sb.toString());
result = invokeHttp(request, args);
Debug.logVerbose("[JdonFramework]Ending remote call " + currentRequestNb, module);
releaseThreadLock();
return result;
} | java | public Object invoke(TargetMetaDef targetMetaDef, Method m, Object[] args) throws Throwable {
Object result = null;
getThreadLock();
int currentRequestNb = requestNb++;
Debug.logVerbose("[JdonFramework]Start remote call " + currentRequestNb + " " + m.getName(), module);
// 准备参数
HttpRequest request = new HttpRequest(targetMetaDef, m.getName(), m.getParameterTypes(), args);
StringBuilder sb = new StringBuilder(httpServerParam.getServletPath().toString());
if (sessionId != null) {
sb.append(";jsessionid=");
sb.append(sessionId);
}
httpServerParam.setServletPath(sb.toString());
result = invokeHttp(request, args);
Debug.logVerbose("[JdonFramework]Ending remote call " + currentRequestNb, module);
releaseThreadLock();
return result;
} | [
"public",
"Object",
"invoke",
"(",
"TargetMetaDef",
"targetMetaDef",
",",
"Method",
"m",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"Object",
"result",
"=",
"null",
";",
"getThreadLock",
"(",
")",
";",
"int",
"currentRequestNb",
"=",
"requestNb",
"++",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]Start remote call \"",
"+",
"currentRequestNb",
"+",
"\" \"",
"+",
"m",
".",
"getName",
"(",
")",
",",
"module",
")",
";",
"// 准备参数\r",
"HttpRequest",
"request",
"=",
"new",
"HttpRequest",
"(",
"targetMetaDef",
",",
"m",
".",
"getName",
"(",
")",
",",
"m",
".",
"getParameterTypes",
"(",
")",
",",
"args",
")",
";",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
"httpServerParam",
".",
"getServletPath",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"sessionId",
"!=",
"null",
")",
"{",
"sb",
".",
"append",
"(",
"\";jsessionid=\"",
")",
";",
"sb",
".",
"append",
"(",
"sessionId",
")",
";",
"}",
"httpServerParam",
".",
"setServletPath",
"(",
"sb",
".",
"toString",
"(",
")",
")",
";",
"result",
"=",
"invokeHttp",
"(",
"request",
",",
"args",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]Ending remote call \"",
"+",
"currentRequestNb",
",",
"module",
")",
";",
"releaseThreadLock",
"(",
")",
";",
"return",
"result",
";",
"}"
] | Invokes EJB service | [
"Invokes",
"EJB",
"service"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java#L78-L102 |
23,727 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java | HttpClient.invokeHttp | public Object invokeHttp(HttpRequest request, Object[] args) throws Throwable {
HttpResponse httpResponse;
try {
HttpConnectionHelper httpConnectionHelper = new HttpConnectionHelper();
HttpURLConnection httpURLConnection;
if (httpServerParam.isDebug()) {// 调试方式无需安全验证
// 连接服务器
Debug.logVerbose("[JdonFramework]connect service..", module);
httpURLConnection = httpConnectionHelper.connectService(httpServerParam, null);
// 发出request
Debug.logVerbose("[JdonFramework]send request: class=" + request.getTargetMetaDef().getClassName(), module);
Debug.logVerbose("[JdonFramework]method=" + request.getMethodName(), module);
httpConnectionHelper.sendObjectRequest(httpURLConnection, request);
} else {
httpURLConnection = httpConnectionHelper.connectService(httpServerParam, getUserPassword(args));
// 发出request
httpConnectionHelper.sendObjectRequest(httpURLConnection, request);
// 接受response
if (httpURLConnection.getResponseCode() == 401) {
throw new AuthException(" http Server authentication failed!");
}
}
// 接受response
httpResponse = (HttpResponse) httpConnectionHelper.getObjectResponse(httpURLConnection);
// 获得jsessionid
sessionId = httpURLConnection.getHeaderField("jsessionid");
// 断开连接
httpURLConnection.disconnect();
if (httpResponse.isExceptionThrown())
throw httpResponse.getThrowable();
return httpResponse.getResult();
} catch (ClassNotFoundException e) {
Debug.logError(e, module);
throw new RemoteException(" Class Not Found ", e);
} catch (AuthException ae) {
throw new AuthException(ae.getMessage());
} catch (Exception e) {
String message = "invokeHttp error:";
Debug.logError(message + e, module);
throw new RemoteException(message, e);
}
} | java | public Object invokeHttp(HttpRequest request, Object[] args) throws Throwable {
HttpResponse httpResponse;
try {
HttpConnectionHelper httpConnectionHelper = new HttpConnectionHelper();
HttpURLConnection httpURLConnection;
if (httpServerParam.isDebug()) {// 调试方式无需安全验证
// 连接服务器
Debug.logVerbose("[JdonFramework]connect service..", module);
httpURLConnection = httpConnectionHelper.connectService(httpServerParam, null);
// 发出request
Debug.logVerbose("[JdonFramework]send request: class=" + request.getTargetMetaDef().getClassName(), module);
Debug.logVerbose("[JdonFramework]method=" + request.getMethodName(), module);
httpConnectionHelper.sendObjectRequest(httpURLConnection, request);
} else {
httpURLConnection = httpConnectionHelper.connectService(httpServerParam, getUserPassword(args));
// 发出request
httpConnectionHelper.sendObjectRequest(httpURLConnection, request);
// 接受response
if (httpURLConnection.getResponseCode() == 401) {
throw new AuthException(" http Server authentication failed!");
}
}
// 接受response
httpResponse = (HttpResponse) httpConnectionHelper.getObjectResponse(httpURLConnection);
// 获得jsessionid
sessionId = httpURLConnection.getHeaderField("jsessionid");
// 断开连接
httpURLConnection.disconnect();
if (httpResponse.isExceptionThrown())
throw httpResponse.getThrowable();
return httpResponse.getResult();
} catch (ClassNotFoundException e) {
Debug.logError(e, module);
throw new RemoteException(" Class Not Found ", e);
} catch (AuthException ae) {
throw new AuthException(ae.getMessage());
} catch (Exception e) {
String message = "invokeHttp error:";
Debug.logError(message + e, module);
throw new RemoteException(message, e);
}
} | [
"public",
"Object",
"invokeHttp",
"(",
"HttpRequest",
"request",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"HttpResponse",
"httpResponse",
";",
"try",
"{",
"HttpConnectionHelper",
"httpConnectionHelper",
"=",
"new",
"HttpConnectionHelper",
"(",
")",
";",
"HttpURLConnection",
"httpURLConnection",
";",
"if",
"(",
"httpServerParam",
".",
"isDebug",
"(",
")",
")",
"{",
"// 调试方式无需安全验证\r",
"// 连接服务器\r",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]connect service..\"",
",",
"module",
")",
";",
"httpURLConnection",
"=",
"httpConnectionHelper",
".",
"connectService",
"(",
"httpServerParam",
",",
"null",
")",
";",
"// 发出request\r",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]send request: class=\"",
"+",
"request",
".",
"getTargetMetaDef",
"(",
")",
".",
"getClassName",
"(",
")",
",",
"module",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]method=\"",
"+",
"request",
".",
"getMethodName",
"(",
")",
",",
"module",
")",
";",
"httpConnectionHelper",
".",
"sendObjectRequest",
"(",
"httpURLConnection",
",",
"request",
")",
";",
"}",
"else",
"{",
"httpURLConnection",
"=",
"httpConnectionHelper",
".",
"connectService",
"(",
"httpServerParam",
",",
"getUserPassword",
"(",
"args",
")",
")",
";",
"// 发出request\r",
"httpConnectionHelper",
".",
"sendObjectRequest",
"(",
"httpURLConnection",
",",
"request",
")",
";",
"// 接受response\r",
"if",
"(",
"httpURLConnection",
".",
"getResponseCode",
"(",
")",
"==",
"401",
")",
"{",
"throw",
"new",
"AuthException",
"(",
"\" http Server authentication failed!\"",
")",
";",
"}",
"}",
"// 接受response\r",
"httpResponse",
"=",
"(",
"HttpResponse",
")",
"httpConnectionHelper",
".",
"getObjectResponse",
"(",
"httpURLConnection",
")",
";",
"// 获得jsessionid\r",
"sessionId",
"=",
"httpURLConnection",
".",
"getHeaderField",
"(",
"\"jsessionid\"",
")",
";",
"// 断开连接\r",
"httpURLConnection",
".",
"disconnect",
"(",
")",
";",
"if",
"(",
"httpResponse",
".",
"isExceptionThrown",
"(",
")",
")",
"throw",
"httpResponse",
".",
"getThrowable",
"(",
")",
";",
"return",
"httpResponse",
".",
"getResult",
"(",
")",
";",
"}",
"catch",
"(",
"ClassNotFoundException",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"e",
",",
"module",
")",
";",
"throw",
"new",
"RemoteException",
"(",
"\" Class Not Found \"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"AuthException",
"ae",
")",
"{",
"throw",
"new",
"AuthException",
"(",
"ae",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"String",
"message",
"=",
"\"invokeHttp error:\"",
";",
"Debug",
".",
"logError",
"(",
"message",
"+",
"e",
",",
"module",
")",
";",
"throw",
"new",
"RemoteException",
"(",
"message",
",",
"e",
")",
";",
"}",
"}"
] | Performs the http call. | [
"Performs",
"the",
"http",
"call",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java#L107-L154 |
23,728 | banq/jdonframework | JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java | HttpClient.getThreadLock | private synchronized void getThreadLock() {
while (sessionId == null && curUsedThread > 1) {
try {
Debug.logVerbose("No session. Only one thread is authorized. Waiting ...", module);
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
while (curUsedThread >= maxThreadCount) {
try {
Debug.logVerbose("[JdonFramework]Max concurent http call reached. Waiting ...", module);
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
curUsedThread++;
} | java | private synchronized void getThreadLock() {
while (sessionId == null && curUsedThread > 1) {
try {
Debug.logVerbose("No session. Only one thread is authorized. Waiting ...", module);
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
while (curUsedThread >= maxThreadCount) {
try {
Debug.logVerbose("[JdonFramework]Max concurent http call reached. Waiting ...", module);
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
curUsedThread++;
} | [
"private",
"synchronized",
"void",
"getThreadLock",
"(",
")",
"{",
"while",
"(",
"sessionId",
"==",
"null",
"&&",
"curUsedThread",
">",
"1",
")",
"{",
"try",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"No session. Only one thread is authorized. Waiting ...\"",
",",
"module",
")",
";",
"wait",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"while",
"(",
"curUsedThread",
">=",
"maxThreadCount",
")",
"{",
"try",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]Max concurent http call reached. Waiting ...\"",
",",
"module",
")",
";",
"wait",
"(",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"curUsedThread",
"++",
";",
"}"
] | This method is used to limit the concurrent http call to the max fixed by
maxThreadCount and to wait the end of the first call that will return the
session id. | [
"This",
"method",
"is",
"used",
"to",
"limit",
"the",
"concurrent",
"http",
"call",
"to",
"the",
"max",
"fixed",
"by",
"maxThreadCount",
"and",
"to",
"wait",
"the",
"end",
"of",
"the",
"first",
"call",
"that",
"will",
"return",
"the",
"session",
"id",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-remote/src/main/java/com/jdon/bussinessproxy/remote/http/HttpClient.java#L231-L250 |
23,729 | banq/jdonframework | src/main/java/com/jdon/aop/reflection/MethodConstructor.java | MethodConstructor.createMethod | public Method createMethod(TargetServiceFactory targetServiceFactory) {
Method method = null;
Debug.logVerbose("[JdonFramework] enter create the Method " , module);
try {
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
if (targetMetaRequest.getTargetMetaDef().isEJB()) {
Object obj= methodInvokerUtil.createTargetObject(targetServiceFactory);
method = createObjectMethod(obj, targetMetaRequest.getMethodMetaArgs());
}else{
method = createPojoMethod();
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error: " + ex, module);
}
return method;
} | java | public Method createMethod(TargetServiceFactory targetServiceFactory) {
Method method = null;
Debug.logVerbose("[JdonFramework] enter create the Method " , module);
try {
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
if (targetMetaRequest.getTargetMetaDef().isEJB()) {
Object obj= methodInvokerUtil.createTargetObject(targetServiceFactory);
method = createObjectMethod(obj, targetMetaRequest.getMethodMetaArgs());
}else{
method = createPojoMethod();
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error: " + ex, module);
}
return method;
} | [
"public",
"Method",
"createMethod",
"(",
"TargetServiceFactory",
"targetServiceFactory",
")",
"{",
"Method",
"method",
"=",
"null",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] enter create the Method \"",
",",
"module",
")",
";",
"try",
"{",
"TargetMetaRequest",
"targetMetaRequest",
"=",
"targetMetaRequestsHolder",
".",
"getTargetMetaRequest",
"(",
")",
";",
"if",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"isEJB",
"(",
")",
")",
"{",
"Object",
"obj",
"=",
"methodInvokerUtil",
".",
"createTargetObject",
"(",
"targetServiceFactory",
")",
";",
"method",
"=",
"createObjectMethod",
"(",
"obj",
",",
"targetMetaRequest",
".",
"getMethodMetaArgs",
"(",
")",
")",
";",
"}",
"else",
"{",
"method",
"=",
"createPojoMethod",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] createMethod error: \"",
"+",
"ex",
",",
"module",
")",
";",
"}",
"return",
"method",
";",
"}"
] | ejb's method creating must at first get service's EJB Object;
pojo's method creating can only need service's class.
@param targetServiceFactory
@param targetMetaRequest
@param methodMetaArgs
@return | [
"ejb",
"s",
"method",
"creating",
"must",
"at",
"first",
"get",
"service",
"s",
"EJB",
"Object",
";",
"pojo",
"s",
"method",
"creating",
"can",
"only",
"need",
"service",
"s",
"class",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/reflection/MethodConstructor.java#L60-L77 |
23,730 | banq/jdonframework | src/main/java/com/jdon/aop/reflection/MethodConstructor.java | MethodConstructor.createPojoMethod | public Method createPojoMethod() {
Method method = null;
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
TargetMetaDef targetMetaDef = targetMetaRequest.getTargetMetaDef();
MethodMetaArgs methodMetaArgs = targetMetaRequest.getMethodMetaArgs();
Debug.logVerbose("[JdonFramework] createPOJO Method :" + methodMetaArgs.getMethodName() + " for target service: " + targetMetaDef.getName(), module);
try {
Class thisCLass = containerCallback.getContainerWrapper().getComponentClass(targetMetaDef.getName());
if (thisCLass == null) return null;
method = thisCLass.getMethod(methodMetaArgs.getMethodName(),
methodMetaArgs.getParamTypes());
} catch (NoSuchMethodException ne) {
Debug.logError("[JdonFramework] method name:"
+ methodMetaArgs.getMethodName() + " or method parameters type don't match with your service's method", module);
Object types[] = methodMetaArgs.getParamTypes();
for(int i = 0; i<types.length; i ++){
Debug.logError("[JdonFramework]service's method parameter type must be:" + types[i] + "; ", module);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] createPojoMethod error: " + ex, module);
}
return method;
} | java | public Method createPojoMethod() {
Method method = null;
TargetMetaRequest targetMetaRequest = targetMetaRequestsHolder.getTargetMetaRequest();
TargetMetaDef targetMetaDef = targetMetaRequest.getTargetMetaDef();
MethodMetaArgs methodMetaArgs = targetMetaRequest.getMethodMetaArgs();
Debug.logVerbose("[JdonFramework] createPOJO Method :" + methodMetaArgs.getMethodName() + " for target service: " + targetMetaDef.getName(), module);
try {
Class thisCLass = containerCallback.getContainerWrapper().getComponentClass(targetMetaDef.getName());
if (thisCLass == null) return null;
method = thisCLass.getMethod(methodMetaArgs.getMethodName(),
methodMetaArgs.getParamTypes());
} catch (NoSuchMethodException ne) {
Debug.logError("[JdonFramework] method name:"
+ methodMetaArgs.getMethodName() + " or method parameters type don't match with your service's method", module);
Object types[] = methodMetaArgs.getParamTypes();
for(int i = 0; i<types.length; i ++){
Debug.logError("[JdonFramework]service's method parameter type must be:" + types[i] + "; ", module);
}
} catch (Exception ex) {
Debug.logError("[JdonFramework] createPojoMethod error: " + ex, module);
}
return method;
} | [
"public",
"Method",
"createPojoMethod",
"(",
")",
"{",
"Method",
"method",
"=",
"null",
";",
"TargetMetaRequest",
"targetMetaRequest",
"=",
"targetMetaRequestsHolder",
".",
"getTargetMetaRequest",
"(",
")",
";",
"TargetMetaDef",
"targetMetaDef",
"=",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
";",
"MethodMetaArgs",
"methodMetaArgs",
"=",
"targetMetaRequest",
".",
"getMethodMetaArgs",
"(",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] createPOJO Method :\"",
"+",
"methodMetaArgs",
".",
"getMethodName",
"(",
")",
"+",
"\" for target service: \"",
"+",
"targetMetaDef",
".",
"getName",
"(",
")",
",",
"module",
")",
";",
"try",
"{",
"Class",
"thisCLass",
"=",
"containerCallback",
".",
"getContainerWrapper",
"(",
")",
".",
"getComponentClass",
"(",
"targetMetaDef",
".",
"getName",
"(",
")",
")",
";",
"if",
"(",
"thisCLass",
"==",
"null",
")",
"return",
"null",
";",
"method",
"=",
"thisCLass",
".",
"getMethod",
"(",
"methodMetaArgs",
".",
"getMethodName",
"(",
")",
",",
"methodMetaArgs",
".",
"getParamTypes",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"ne",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] method name:\"",
"+",
"methodMetaArgs",
".",
"getMethodName",
"(",
")",
"+",
"\" or method parameters type don't match with your service's method\"",
",",
"module",
")",
";",
"Object",
"types",
"[",
"]",
"=",
"methodMetaArgs",
".",
"getParamTypes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"types",
".",
"length",
";",
"i",
"++",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework]service's method parameter type must be:\"",
"+",
"types",
"[",
"i",
"]",
"+",
"\"; \"",
",",
"module",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] createPojoMethod error: \"",
"+",
"ex",
",",
"module",
")",
";",
"}",
"return",
"method",
";",
"}"
] | create a method object by its meta definition
@param targetMetaDef
@param cw
@param methodMetaArgs | [
"create",
"a",
"method",
"object",
"by",
"its",
"meta",
"definition"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/reflection/MethodConstructor.java#L86-L110 |
23,731 | banq/jdonframework | src/main/java/com/jdon/aop/reflection/MethodConstructor.java | MethodConstructor.createObjectMethod | public Method createObjectMethod(Object ownerClass, MethodMetaArgs methodMetaArgs) {
Method m = null;
try {
m = ownerClass.getClass().getMethod(methodMetaArgs.getMethodName(),
methodMetaArgs.getParamTypes());
} catch (NoSuchMethodException nsme) {
String errS = " NoSuchMethod:" + methodMetaArgs.getMethodName() + " in MethodMetaArgs of className:"
+ ownerClass.getClass().getName();
Debug.logError(errS, module);
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error:" + ex, module);
}
return m;
} | java | public Method createObjectMethod(Object ownerClass, MethodMetaArgs methodMetaArgs) {
Method m = null;
try {
m = ownerClass.getClass().getMethod(methodMetaArgs.getMethodName(),
methodMetaArgs.getParamTypes());
} catch (NoSuchMethodException nsme) {
String errS = " NoSuchMethod:" + methodMetaArgs.getMethodName() + " in MethodMetaArgs of className:"
+ ownerClass.getClass().getName();
Debug.logError(errS, module);
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error:" + ex, module);
}
return m;
} | [
"public",
"Method",
"createObjectMethod",
"(",
"Object",
"ownerClass",
",",
"MethodMetaArgs",
"methodMetaArgs",
")",
"{",
"Method",
"m",
"=",
"null",
";",
"try",
"{",
"m",
"=",
"ownerClass",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodMetaArgs",
".",
"getMethodName",
"(",
")",
",",
"methodMetaArgs",
".",
"getParamTypes",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"nsme",
")",
"{",
"String",
"errS",
"=",
"\" NoSuchMethod:\"",
"+",
"methodMetaArgs",
".",
"getMethodName",
"(",
")",
"+",
"\" in MethodMetaArgs of className:\"",
"+",
"ownerClass",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
";",
"Debug",
".",
"logError",
"(",
"errS",
",",
"module",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] createMethod error:\"",
"+",
"ex",
",",
"module",
")",
";",
"}",
"return",
"m",
";",
"}"
] | create a method object by target Object
@param ownerClass
@param methodMetaArgs
@return | [
"create",
"a",
"method",
"object",
"by",
"target",
"Object"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/reflection/MethodConstructor.java#L118-L131 |
23,732 | banq/jdonframework | src/main/java/com/jdon/aop/reflection/MethodConstructor.java | MethodConstructor.createObjectMethod | public Method createObjectMethod(Object ownerClass, String methodName,
Class[] paramTypes) {
Method m = null;
try {
m = ownerClass.getClass().getMethod(methodName, paramTypes);
} catch (NoSuchMethodException nsme) {
String errS = " NoSuchMethod:" + methodName + " in className:"
+ ownerClass.getClass().getName() + " or method's args type error";
Debug.logError(errS, module);
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error:" + ex, module);
}
return m;
} | java | public Method createObjectMethod(Object ownerClass, String methodName,
Class[] paramTypes) {
Method m = null;
try {
m = ownerClass.getClass().getMethod(methodName, paramTypes);
} catch (NoSuchMethodException nsme) {
String errS = " NoSuchMethod:" + methodName + " in className:"
+ ownerClass.getClass().getName() + " or method's args type error";
Debug.logError(errS, module);
} catch (Exception ex) {
Debug.logError("[JdonFramework] createMethod error:" + ex, module);
}
return m;
} | [
"public",
"Method",
"createObjectMethod",
"(",
"Object",
"ownerClass",
",",
"String",
"methodName",
",",
"Class",
"[",
"]",
"paramTypes",
")",
"{",
"Method",
"m",
"=",
"null",
";",
"try",
"{",
"m",
"=",
"ownerClass",
".",
"getClass",
"(",
")",
".",
"getMethod",
"(",
"methodName",
",",
"paramTypes",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"nsme",
")",
"{",
"String",
"errS",
"=",
"\" NoSuchMethod:\"",
"+",
"methodName",
"+",
"\" in className:\"",
"+",
"ownerClass",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\" or method's args type error\"",
";",
"Debug",
".",
"logError",
"(",
"errS",
",",
"module",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] createMethod error:\"",
"+",
"ex",
",",
"module",
")",
";",
"}",
"return",
"m",
";",
"}"
] | create a method object
@param ownerClass
@param methodName
@param paramTypes
@return | [
"create",
"a",
"method",
"object"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/reflection/MethodConstructor.java#L140-L153 |
23,733 | banq/jdonframework | src/main/java/com/jdon/util/FileLocator.java | FileLocator.getConfPathXmlStream | public InputStream getConfPathXmlStream(String filePathName){
int i = filePathName.lastIndexOf(".xml");
String name = filePathName.substring(0, i);
name = name.replace('.', '/');
name += ".xml";
return getConfStream(name);
} | java | public InputStream getConfPathXmlStream(String filePathName){
int i = filePathName.lastIndexOf(".xml");
String name = filePathName.substring(0, i);
name = name.replace('.', '/');
name += ".xml";
return getConfStream(name);
} | [
"public",
"InputStream",
"getConfPathXmlStream",
"(",
"String",
"filePathName",
")",
"{",
"int",
"i",
"=",
"filePathName",
".",
"lastIndexOf",
"(",
"\".xml\"",
")",
";",
"String",
"name",
"=",
"filePathName",
".",
"substring",
"(",
"0",
",",
"i",
")",
";",
"name",
"=",
"name",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"name",
"+=",
"\".xml\"",
";",
"return",
"getConfStream",
"(",
"name",
")",
";",
"}"
] | same as getConfPathXmlFile
@param filePathName
@return the InputStream intance | [
"same",
"as",
"getConfPathXmlFile"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/FileLocator.java#L48-L54 |
23,734 | banq/jdonframework | src/main/java/com/jdon/util/MultiHashMap.java | MultiHashMap.put | public Object put(Object key,Object subKey,Object value){
HashMap a = (HashMap)super.get(key);
if(a==null){
a = new HashMap();
super.put(key,a);
}
return a.put(subKey,value);
} | java | public Object put(Object key,Object subKey,Object value){
HashMap a = (HashMap)super.get(key);
if(a==null){
a = new HashMap();
super.put(key,a);
}
return a.put(subKey,value);
} | [
"public",
"Object",
"put",
"(",
"Object",
"key",
",",
"Object",
"subKey",
",",
"Object",
"value",
")",
"{",
"HashMap",
"a",
"=",
"(",
"HashMap",
")",
"super",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"a",
"==",
"null",
")",
"{",
"a",
"=",
"new",
"HashMap",
"(",
")",
";",
"super",
".",
"put",
"(",
"key",
",",
"a",
")",
";",
"}",
"return",
"a",
".",
"put",
"(",
"subKey",
",",
"value",
")",
";",
"}"
] | Associates the specified value with the specified key and subKey in this map.
If the map previously contained a mapping for this key and subKey , the old value is replaced.
@param key Is a Primary key.
@param subKey with which the specified value is to be associated.
@param value to be associated with the specified key and subKey
@return previous value associated with specified key and subKey, or null if there was no mapping for key and subKey.
A null return can also indicate that the HashMap previously associated null with the specified key and subKey. | [
"Associates",
"the",
"specified",
"value",
"with",
"the",
"specified",
"key",
"and",
"subKey",
"in",
"this",
"map",
".",
"If",
"the",
"map",
"previously",
"contained",
"a",
"mapping",
"for",
"this",
"key",
"and",
"subKey",
"the",
"old",
"value",
"is",
"replaced",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/MultiHashMap.java#L33-L40 |
23,735 | banq/jdonframework | src/main/java/com/jdon/util/MultiHashMap.java | MultiHashMap.get | public Object get(Object key,Object subKey){
HashMap a = (HashMap)super.get(key);
if(a!=null){
Object b=a.get(subKey);
return b;
}
return null;
} | java | public Object get(Object key,Object subKey){
HashMap a = (HashMap)super.get(key);
if(a!=null){
Object b=a.get(subKey);
return b;
}
return null;
} | [
"public",
"Object",
"get",
"(",
"Object",
"key",
",",
"Object",
"subKey",
")",
"{",
"HashMap",
"a",
"=",
"(",
"HashMap",
")",
"super",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"a",
"!=",
"null",
")",
"{",
"Object",
"b",
"=",
"a",
".",
"get",
"(",
"subKey",
")",
";",
"return",
"b",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the value to which this map maps the specified key and subKey. Returns null if the map contains no mapping
for this key and subKey. A return value of null does not necessarily indicate that the map contains no mapping
for the key and subKey; it's also possible that the map explicitly maps the key to null.
The containsKey operation may be used to distinguish these two cases.
@param key whose associated value is to be returned.
@param subKey whose associated value is to be returned
@return the value to which this map maps the specified key. | [
"Returns",
"the",
"value",
"to",
"which",
"this",
"map",
"maps",
"the",
"specified",
"key",
"and",
"subKey",
".",
"Returns",
"null",
"if",
"the",
"map",
"contains",
"no",
"mapping",
"for",
"this",
"key",
"and",
"subKey",
".",
"A",
"return",
"value",
"of",
"null",
"does",
"not",
"necessarily",
"indicate",
"that",
"the",
"map",
"contains",
"no",
"mapping",
"for",
"the",
"key",
"and",
"subKey",
";",
"it",
"s",
"also",
"possible",
"that",
"the",
"map",
"explicitly",
"maps",
"the",
"key",
"to",
"null",
".",
"The",
"containsKey",
"operation",
"may",
"be",
"used",
"to",
"distinguish",
"these",
"two",
"cases",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/MultiHashMap.java#L51-L58 |
23,736 | banq/jdonframework | src/main/java/com/jdon/container/startup/ContainerSetupScript.java | ContainerSetupScript.initialized | public void initialized(AppContextWrapper context) {
ContainerRegistryBuilder cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb != null)
return;
try {
synchronized (context) {
cb = containerBuilderContext.createContainerBuilder(context);
context.setAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME, cb);
Debug.logVerbose("[JdonFramework] Initialize the container OK ..");
}
} catch (Exception e) {
Debug.logError("[JdonFramework] initialized error: " + e, module);
}
} | java | public void initialized(AppContextWrapper context) {
ContainerRegistryBuilder cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb != null)
return;
try {
synchronized (context) {
cb = containerBuilderContext.createContainerBuilder(context);
context.setAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME, cb);
Debug.logVerbose("[JdonFramework] Initialize the container OK ..");
}
} catch (Exception e) {
Debug.logError("[JdonFramework] initialized error: " + e, module);
}
} | [
"public",
"void",
"initialized",
"(",
"AppContextWrapper",
"context",
")",
"{",
"ContainerRegistryBuilder",
"cb",
"=",
"(",
"ContainerRegistryBuilder",
")",
"context",
".",
"getAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"if",
"(",
"cb",
"!=",
"null",
")",
"return",
";",
"try",
"{",
"synchronized",
"(",
"context",
")",
"{",
"cb",
"=",
"containerBuilderContext",
".",
"createContainerBuilder",
"(",
"context",
")",
";",
"context",
".",
"setAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
",",
"cb",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] Initialize the container OK ..\"",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] initialized error: \"",
"+",
"e",
",",
"module",
")",
";",
"}",
"}"
] | Initialize application container
@param context
ServletContext | [
"Initialize",
"application",
"container"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/startup/ContainerSetupScript.java#L45-L58 |
23,737 | banq/jdonframework | src/main/java/com/jdon/container/startup/ContainerSetupScript.java | ContainerSetupScript.prepare | public synchronized void prepare(String configureFileName, AppContextWrapper context) {
ContainerRegistryBuilder cb;
try {
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb == null) {
initialized(context);
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
}
ContainerDirector cd = new ContainerDirector(cb);
cd.prepareAppRoot(configureFileName);
} catch (Exception ex) {
Debug.logError(ex, module);
}
} | java | public synchronized void prepare(String configureFileName, AppContextWrapper context) {
ContainerRegistryBuilder cb;
try {
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb == null) {
initialized(context);
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
}
ContainerDirector cd = new ContainerDirector(cb);
cd.prepareAppRoot(configureFileName);
} catch (Exception ex) {
Debug.logError(ex, module);
}
} | [
"public",
"synchronized",
"void",
"prepare",
"(",
"String",
"configureFileName",
",",
"AppContextWrapper",
"context",
")",
"{",
"ContainerRegistryBuilder",
"cb",
";",
"try",
"{",
"cb",
"=",
"(",
"ContainerRegistryBuilder",
")",
"context",
".",
"getAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"if",
"(",
"cb",
"==",
"null",
")",
"{",
"initialized",
"(",
"context",
")",
";",
"cb",
"=",
"(",
"ContainerRegistryBuilder",
")",
"context",
".",
"getAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"}",
"ContainerDirector",
"cd",
"=",
"new",
"ContainerDirector",
"(",
"cb",
")",
";",
"cd",
".",
"prepareAppRoot",
"(",
"configureFileName",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"ex",
",",
"module",
")",
";",
"}",
"}"
] | prepare to the applicaition xml Configure for container;
@param configList
Collection
@param context
ServletContext | [
"prepare",
"to",
"the",
"applicaition",
"xml",
"Configure",
"for",
"container",
";"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/startup/ContainerSetupScript.java#L68-L81 |
23,738 | banq/jdonframework | src/main/java/com/jdon/container/startup/ContainerSetupScript.java | ContainerSetupScript.startup | public synchronized void startup(AppContextWrapper context) {
ContainerRegistryBuilder cb;
try {
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb == null) {
Debug.logError("[JdonFramework] at first call prepare method");
return;
}
if (cb.isKernelStartup())
return;
ContainerDirector cd = new ContainerDirector(cb);
cd.startup();
} catch (Exception ex) {
Debug.logError(ex, module);
}
} | java | public synchronized void startup(AppContextWrapper context) {
ContainerRegistryBuilder cb;
try {
cb = (ContainerRegistryBuilder) context.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb == null) {
Debug.logError("[JdonFramework] at first call prepare method");
return;
}
if (cb.isKernelStartup())
return;
ContainerDirector cd = new ContainerDirector(cb);
cd.startup();
} catch (Exception ex) {
Debug.logError(ex, module);
}
} | [
"public",
"synchronized",
"void",
"startup",
"(",
"AppContextWrapper",
"context",
")",
"{",
"ContainerRegistryBuilder",
"cb",
";",
"try",
"{",
"cb",
"=",
"(",
"ContainerRegistryBuilder",
")",
"context",
".",
"getAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"if",
"(",
"cb",
"==",
"null",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] at first call prepare method\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"cb",
".",
"isKernelStartup",
"(",
")",
")",
"return",
";",
"ContainerDirector",
"cd",
"=",
"new",
"ContainerDirector",
"(",
"cb",
")",
";",
"cd",
".",
"startup",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"ex",
",",
"module",
")",
";",
"}",
"}"
] | startup Application container
@param configList
Collection
@param context
ServletContext | [
"startup",
"Application",
"container"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/startup/ContainerSetupScript.java#L92-L107 |
23,739 | banq/jdonframework | src/main/java/com/jdon/container/startup/ContainerSetupScript.java | ContainerSetupScript.destroyed | public synchronized void destroyed(AppContextWrapper context) {
try {
ContainerRegistryBuilder cb = (ContainerRegistryBuilder) context
.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb != null) {
ContainerDirector cd = new ContainerDirector(cb);
cd.shutdown();
context.removeAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
containerBuilderContext = null;
// context.removeAttribute(ContainerBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
Debug.logVerbose("[JdonFramework] stop the container ..", module);
}
} catch (Exception e) {
Debug.logError("[JdonFramework] destroyed error: " + e, module);
}
} | java | public synchronized void destroyed(AppContextWrapper context) {
try {
ContainerRegistryBuilder cb = (ContainerRegistryBuilder) context
.getAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
if (cb != null) {
ContainerDirector cd = new ContainerDirector(cb);
cd.shutdown();
context.removeAttribute(ContainerRegistryBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
containerBuilderContext = null;
// context.removeAttribute(ContainerBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);
Debug.logVerbose("[JdonFramework] stop the container ..", module);
}
} catch (Exception e) {
Debug.logError("[JdonFramework] destroyed error: " + e, module);
}
} | [
"public",
"synchronized",
"void",
"destroyed",
"(",
"AppContextWrapper",
"context",
")",
"{",
"try",
"{",
"ContainerRegistryBuilder",
"cb",
"=",
"(",
"ContainerRegistryBuilder",
")",
"context",
".",
"getAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"if",
"(",
"cb",
"!=",
"null",
")",
"{",
"ContainerDirector",
"cd",
"=",
"new",
"ContainerDirector",
"(",
"cb",
")",
";",
"cd",
".",
"shutdown",
"(",
")",
";",
"context",
".",
"removeAttribute",
"(",
"ContainerRegistryBuilder",
".",
"APPLICATION_CONTEXT_ATTRIBUTE_NAME",
")",
";",
"containerBuilderContext",
"=",
"null",
";",
"// context.removeAttribute(ContainerBuilder.APPLICATION_CONTEXT_ATTRIBUTE_NAME);\r",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] stop the container ..\"",
",",
"module",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\"[JdonFramework] destroyed error: \"",
"+",
"e",
",",
"module",
")",
";",
"}",
"}"
] | desroy Application container
@param context
ServletContext | [
"desroy",
"Application",
"container"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/container/startup/ContainerSetupScript.java#L115-L131 |
23,740 | banq/jdonframework | src/main/java/com/jdon/util/ObjectStreamUtil.java | ObjectStreamUtil.objectToBytes | public static byte[] objectToBytes(Object object) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(baos);
os.writeObject(object);
return baos.toByteArray();
} | java | public static byte[] objectToBytes(Object object) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(baos);
os.writeObject(object);
return baos.toByteArray();
} | [
"public",
"static",
"byte",
"[",
"]",
"objectToBytes",
"(",
"Object",
"object",
")",
"throws",
"IOException",
"{",
"ByteArrayOutputStream",
"baos",
"=",
"new",
"ByteArrayOutputStream",
"(",
")",
";",
"ObjectOutputStream",
"os",
"=",
"new",
"ObjectOutputStream",
"(",
"baos",
")",
";",
"os",
".",
"writeObject",
"(",
"object",
")",
";",
"return",
"baos",
".",
"toByteArray",
"(",
")",
";",
"}"
] | Converts a serializable object to a byte array. | [
"Converts",
"a",
"serializable",
"object",
"to",
"a",
"byte",
"array",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/ObjectStreamUtil.java#L10-L15 |
23,741 | banq/jdonframework | src/main/java/com/jdon/util/ObjectStreamUtil.java | ObjectStreamUtil.bytesToObject | public static Object bytesToObject(byte[] bytes) throws IOException,
ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream is = new ObjectInputStream(bais);
return is.readObject();
} | java | public static Object bytesToObject(byte[] bytes) throws IOException,
ClassNotFoundException {
ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
ObjectInputStream is = new ObjectInputStream(bais);
return is.readObject();
} | [
"public",
"static",
"Object",
"bytesToObject",
"(",
"byte",
"[",
"]",
"bytes",
")",
"throws",
"IOException",
",",
"ClassNotFoundException",
"{",
"ByteArrayInputStream",
"bais",
"=",
"new",
"ByteArrayInputStream",
"(",
"bytes",
")",
";",
"ObjectInputStream",
"is",
"=",
"new",
"ObjectInputStream",
"(",
"bais",
")",
";",
"return",
"is",
".",
"readObject",
"(",
")",
";",
"}"
] | Converts a byte array to a serializable object. | [
"Converts",
"a",
"byte",
"array",
"to",
"a",
"serializable",
"object",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/util/ObjectStreamUtil.java#L20-L25 |
23,742 | banq/jdonframework | JdonAccessory/jdon-struts1x/src/main/java/com/jdon/controller/config/XmlPojoServiceParser.java | XmlPojoServiceParser.parsePOJOServiceConfig | private void parsePOJOServiceConfig(Element pojoService, Map<String, TargetMetaDef> mps)
throws Exception {
String name = pojoService.getAttributeValue("name");
String className = pojoService.getAttributeValue("class");
Debug.logVerbose("[JdonFramework] pojoService/component name=" + name
+ " class=" + className, module);
if ((className == null) || (className.equals("")))
throw new Exception("className is null ");
List mappings = pojoService.getChildren("constructor");
String[] constructors = null;
if ((mappings != null) && (mappings.size() != 0)) {
Debug.logVerbose("[JdonFramework] constructor parameters number:"
+ mappings.size() + " for pojoservice " + name, module);
constructors = new String[mappings.size()];
int j = 0;
Iterator i = mappings.iterator();
while (i.hasNext()) {
Element constructor = (Element) i.next();
String value = constructor.getAttributeValue("value");
Debug.logVerbose("[JdonFramework] pojoService constructor="
+ value, module);
constructors[j] = value;
j++;
}
}
POJOTargetMetaDef pojoMetaDef = null;
if (constructors != null)
pojoMetaDef = new POJOTargetMetaDef(name, className, constructors);
else
pojoMetaDef = new POJOTargetMetaDef(name, className);
mps.put(name, pojoMetaDef);
} | java | private void parsePOJOServiceConfig(Element pojoService, Map<String, TargetMetaDef> mps)
throws Exception {
String name = pojoService.getAttributeValue("name");
String className = pojoService.getAttributeValue("class");
Debug.logVerbose("[JdonFramework] pojoService/component name=" + name
+ " class=" + className, module);
if ((className == null) || (className.equals("")))
throw new Exception("className is null ");
List mappings = pojoService.getChildren("constructor");
String[] constructors = null;
if ((mappings != null) && (mappings.size() != 0)) {
Debug.logVerbose("[JdonFramework] constructor parameters number:"
+ mappings.size() + " for pojoservice " + name, module);
constructors = new String[mappings.size()];
int j = 0;
Iterator i = mappings.iterator();
while (i.hasNext()) {
Element constructor = (Element) i.next();
String value = constructor.getAttributeValue("value");
Debug.logVerbose("[JdonFramework] pojoService constructor="
+ value, module);
constructors[j] = value;
j++;
}
}
POJOTargetMetaDef pojoMetaDef = null;
if (constructors != null)
pojoMetaDef = new POJOTargetMetaDef(name, className, constructors);
else
pojoMetaDef = new POJOTargetMetaDef(name, className);
mps.put(name, pojoMetaDef);
} | [
"private",
"void",
"parsePOJOServiceConfig",
"(",
"Element",
"pojoService",
",",
"Map",
"<",
"String",
",",
"TargetMetaDef",
">",
"mps",
")",
"throws",
"Exception",
"{",
"String",
"name",
"=",
"pojoService",
".",
"getAttributeValue",
"(",
"\"name\"",
")",
";",
"String",
"className",
"=",
"pojoService",
".",
"getAttributeValue",
"(",
"\"class\"",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] pojoService/component name=\"",
"+",
"name",
"+",
"\" class=\"",
"+",
"className",
",",
"module",
")",
";",
"if",
"(",
"(",
"className",
"==",
"null",
")",
"||",
"(",
"className",
".",
"equals",
"(",
"\"\"",
")",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"className is null \"",
")",
";",
"List",
"mappings",
"=",
"pojoService",
".",
"getChildren",
"(",
"\"constructor\"",
")",
";",
"String",
"[",
"]",
"constructors",
"=",
"null",
";",
"if",
"(",
"(",
"mappings",
"!=",
"null",
")",
"&&",
"(",
"mappings",
".",
"size",
"(",
")",
"!=",
"0",
")",
")",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] constructor parameters number:\"",
"+",
"mappings",
".",
"size",
"(",
")",
"+",
"\" for pojoservice \"",
"+",
"name",
",",
"module",
")",
";",
"constructors",
"=",
"new",
"String",
"[",
"mappings",
".",
"size",
"(",
")",
"]",
";",
"int",
"j",
"=",
"0",
";",
"Iterator",
"i",
"=",
"mappings",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"i",
".",
"hasNext",
"(",
")",
")",
"{",
"Element",
"constructor",
"=",
"(",
"Element",
")",
"i",
".",
"next",
"(",
")",
";",
"String",
"value",
"=",
"constructor",
".",
"getAttributeValue",
"(",
"\"value\"",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] pojoService constructor=\"",
"+",
"value",
",",
"module",
")",
";",
"constructors",
"[",
"j",
"]",
"=",
"value",
";",
"j",
"++",
";",
"}",
"}",
"POJOTargetMetaDef",
"pojoMetaDef",
"=",
"null",
";",
"if",
"(",
"constructors",
"!=",
"null",
")",
"pojoMetaDef",
"=",
"new",
"POJOTargetMetaDef",
"(",
"name",
",",
"className",
",",
"constructors",
")",
";",
"else",
"pojoMetaDef",
"=",
"new",
"POJOTargetMetaDef",
"(",
"name",
",",
"className",
")",
";",
"mps",
".",
"put",
"(",
"name",
",",
"pojoMetaDef",
")",
";",
"}"
] | parse POJOService Config
@param pojoService Element
@param mps Map
@throws Exception | [
"parse",
"POJOService",
"Config"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-struts1x/src/main/java/com/jdon/controller/config/XmlPojoServiceParser.java#L62-L97 |
23,743 | banq/jdonframework | JdonAccessory/jdon-struts1x/src/main/java/com/jdon/servicelocator/web/ServiceLocator.java | ServiceLocator.getLocalHome | public EJBLocalHome getLocalHome(String jndiHomeName) throws
ServiceLocatorException {
Debug.logVerbose("[JdonFramework] -- > getLocalHome.... ", module);
EJBLocalHome home = null;
try {
if (cache.containsKey(jndiHomeName)) {
home = (EJBLocalHome) cache.get(jndiHomeName);
} else {
Debug.logVerbose("[JdonFramework] lookUp LocalHome.... ", module);
home = (EJBLocalHome) ic.lookup(jndiHomeName);
cache.put(jndiHomeName, home);
}
} catch (NamingException ne) {
throw new ServiceLocatorException(ne);
} catch (Exception e) {
throw new ServiceLocatorException(e);
}
return home;
} | java | public EJBLocalHome getLocalHome(String jndiHomeName) throws
ServiceLocatorException {
Debug.logVerbose("[JdonFramework] -- > getLocalHome.... ", module);
EJBLocalHome home = null;
try {
if (cache.containsKey(jndiHomeName)) {
home = (EJBLocalHome) cache.get(jndiHomeName);
} else {
Debug.logVerbose("[JdonFramework] lookUp LocalHome.... ", module);
home = (EJBLocalHome) ic.lookup(jndiHomeName);
cache.put(jndiHomeName, home);
}
} catch (NamingException ne) {
throw new ServiceLocatorException(ne);
} catch (Exception e) {
throw new ServiceLocatorException(e);
}
return home;
} | [
"public",
"EJBLocalHome",
"getLocalHome",
"(",
"String",
"jndiHomeName",
")",
"throws",
"ServiceLocatorException",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] -- > getLocalHome.... \"",
",",
"module",
")",
";",
"EJBLocalHome",
"home",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"cache",
".",
"containsKey",
"(",
"jndiHomeName",
")",
")",
"{",
"home",
"=",
"(",
"EJBLocalHome",
")",
"cache",
".",
"get",
"(",
"jndiHomeName",
")",
";",
"}",
"else",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] lookUp LocalHome.... \"",
",",
"module",
")",
";",
"home",
"=",
"(",
"EJBLocalHome",
")",
"ic",
".",
"lookup",
"(",
"jndiHomeName",
")",
";",
"cache",
".",
"put",
"(",
"jndiHomeName",
",",
"home",
")",
";",
"}",
"}",
"catch",
"(",
"NamingException",
"ne",
")",
"{",
"throw",
"new",
"ServiceLocatorException",
"(",
"ne",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"ServiceLocatorException",
"(",
"e",
")",
";",
"}",
"return",
"home",
";",
"}"
] | will get the ejb Local home factory. If this ejb home factory has already been
clients need to cast to the type of EJBHome they desire
@return the EJB Home corresponding to the homeName | [
"will",
"get",
"the",
"ejb",
"Local",
"home",
"factory",
".",
"If",
"this",
"ejb",
"home",
"factory",
"has",
"already",
"been",
"clients",
"need",
"to",
"cast",
"to",
"the",
"type",
"of",
"EJBHome",
"they",
"desire"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-struts1x/src/main/java/com/jdon/servicelocator/web/ServiceLocator.java#L67-L85 |
23,744 | banq/jdonframework | JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java | BlockStrategy.locate | public Block locate(String sqlquery, Collection queryParams, Object locateId) {
int blockSize = getBlockLength();
Block block = null;
int index = -1;
int prevBlockStart = Integer.MIN_VALUE;
int nextBlockStart = Integer.MIN_VALUE;
int start = 0;
Debug.logVerbose("[JdonFramework]try to locate a block locateId= " + locateId + " blockSize=" + blockSize, module);
try {
while (index == -1) {
block = getBlock(sqlquery, queryParams, start, blockSize);
if (block == null)
break;
List list = block.getList();
index = list.indexOf(locateId);
if ((index >= 0) && (index < list.size())) {
Debug.logVerbose("[JdonFramework]found the locateId, index= " + index, module);
if ((index == 0) && (block.getStart() >= blockSize))// if is
// the
// first
// in
// this
// block
prevBlockStart = start - blockSize;
else if (index == blockSize - 1) // // if is the last in
// this block
nextBlockStart = start + blockSize;
break;
} else {
if (block.getCount() >= blockSize)// there are more block.
start = start + blockSize;
else
// there are no more block;
break;
}
}
if (index == -1) {
Debug.logVerbose("[JdonFramework] not locate the block that have the locateId= " + locateId, module);
return null; // not found return null
}
if (prevBlockStart != Integer.MIN_VALUE) {
Block prevBlock = getBlock(sqlquery, queryParams, prevBlockStart, blockSize);
prevBlock.getList().addAll(block.getList());
prevBlock.setStart(prevBlock.getStart() + prevBlock.getCount());
prevBlock.setCount(prevBlock.getCount() + block.getCount());
return prevBlock;
} else if (nextBlockStart != Integer.MIN_VALUE) { // if
// nextBlockStart
// has new
// value, so we
// need next
// block, fetch
// it.
Block nextBlock = getBlock(sqlquery, queryParams, nextBlockStart, blockSize);
if (nextBlock != null) {
block.getList().addAll(nextBlock.getList());
block.setCount(block.getCount() + nextBlock.getCount());
}
return block;
} else
return block;
} catch (Exception e) {
Debug.logError(" locate Block error" + e, module);
}
return block;
} | java | public Block locate(String sqlquery, Collection queryParams, Object locateId) {
int blockSize = getBlockLength();
Block block = null;
int index = -1;
int prevBlockStart = Integer.MIN_VALUE;
int nextBlockStart = Integer.MIN_VALUE;
int start = 0;
Debug.logVerbose("[JdonFramework]try to locate a block locateId= " + locateId + " blockSize=" + blockSize, module);
try {
while (index == -1) {
block = getBlock(sqlquery, queryParams, start, blockSize);
if (block == null)
break;
List list = block.getList();
index = list.indexOf(locateId);
if ((index >= 0) && (index < list.size())) {
Debug.logVerbose("[JdonFramework]found the locateId, index= " + index, module);
if ((index == 0) && (block.getStart() >= blockSize))// if is
// the
// first
// in
// this
// block
prevBlockStart = start - blockSize;
else if (index == blockSize - 1) // // if is the last in
// this block
nextBlockStart = start + blockSize;
break;
} else {
if (block.getCount() >= blockSize)// there are more block.
start = start + blockSize;
else
// there are no more block;
break;
}
}
if (index == -1) {
Debug.logVerbose("[JdonFramework] not locate the block that have the locateId= " + locateId, module);
return null; // not found return null
}
if (prevBlockStart != Integer.MIN_VALUE) {
Block prevBlock = getBlock(sqlquery, queryParams, prevBlockStart, blockSize);
prevBlock.getList().addAll(block.getList());
prevBlock.setStart(prevBlock.getStart() + prevBlock.getCount());
prevBlock.setCount(prevBlock.getCount() + block.getCount());
return prevBlock;
} else if (nextBlockStart != Integer.MIN_VALUE) { // if
// nextBlockStart
// has new
// value, so we
// need next
// block, fetch
// it.
Block nextBlock = getBlock(sqlquery, queryParams, nextBlockStart, blockSize);
if (nextBlock != null) {
block.getList().addAll(nextBlock.getList());
block.setCount(block.getCount() + nextBlock.getCount());
}
return block;
} else
return block;
} catch (Exception e) {
Debug.logError(" locate Block error" + e, module);
}
return block;
} | [
"public",
"Block",
"locate",
"(",
"String",
"sqlquery",
",",
"Collection",
"queryParams",
",",
"Object",
"locateId",
")",
"{",
"int",
"blockSize",
"=",
"getBlockLength",
"(",
")",
";",
"Block",
"block",
"=",
"null",
";",
"int",
"index",
"=",
"-",
"1",
";",
"int",
"prevBlockStart",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"int",
"nextBlockStart",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"int",
"start",
"=",
"0",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]try to locate a block locateId= \"",
"+",
"locateId",
"+",
"\" blockSize=\"",
"+",
"blockSize",
",",
"module",
")",
";",
"try",
"{",
"while",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"block",
"=",
"getBlock",
"(",
"sqlquery",
",",
"queryParams",
",",
"start",
",",
"blockSize",
")",
";",
"if",
"(",
"block",
"==",
"null",
")",
"break",
";",
"List",
"list",
"=",
"block",
".",
"getList",
"(",
")",
";",
"index",
"=",
"list",
".",
"indexOf",
"(",
"locateId",
")",
";",
"if",
"(",
"(",
"index",
">=",
"0",
")",
"&&",
"(",
"index",
"<",
"list",
".",
"size",
"(",
")",
")",
")",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework]found the locateId, index= \"",
"+",
"index",
",",
"module",
")",
";",
"if",
"(",
"(",
"index",
"==",
"0",
")",
"&&",
"(",
"block",
".",
"getStart",
"(",
")",
">=",
"blockSize",
")",
")",
"// if is\r",
"// the\r",
"// first\r",
"// in\r",
"// this\r",
"// block\r",
"prevBlockStart",
"=",
"start",
"-",
"blockSize",
";",
"else",
"if",
"(",
"index",
"==",
"blockSize",
"-",
"1",
")",
"// // if is the last in\r",
"// this block\r",
"nextBlockStart",
"=",
"start",
"+",
"blockSize",
";",
"break",
";",
"}",
"else",
"{",
"if",
"(",
"block",
".",
"getCount",
"(",
")",
">=",
"blockSize",
")",
"// there are more block.\r",
"start",
"=",
"start",
"+",
"blockSize",
";",
"else",
"// there are no more block;\r",
"break",
";",
"}",
"}",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] not locate the block that have the locateId= \"",
"+",
"locateId",
",",
"module",
")",
";",
"return",
"null",
";",
"// not found return null\r",
"}",
"if",
"(",
"prevBlockStart",
"!=",
"Integer",
".",
"MIN_VALUE",
")",
"{",
"Block",
"prevBlock",
"=",
"getBlock",
"(",
"sqlquery",
",",
"queryParams",
",",
"prevBlockStart",
",",
"blockSize",
")",
";",
"prevBlock",
".",
"getList",
"(",
")",
".",
"addAll",
"(",
"block",
".",
"getList",
"(",
")",
")",
";",
"prevBlock",
".",
"setStart",
"(",
"prevBlock",
".",
"getStart",
"(",
")",
"+",
"prevBlock",
".",
"getCount",
"(",
")",
")",
";",
"prevBlock",
".",
"setCount",
"(",
"prevBlock",
".",
"getCount",
"(",
")",
"+",
"block",
".",
"getCount",
"(",
")",
")",
";",
"return",
"prevBlock",
";",
"}",
"else",
"if",
"(",
"nextBlockStart",
"!=",
"Integer",
".",
"MIN_VALUE",
")",
"{",
"// if\r",
"// nextBlockStart\r",
"// has new\r",
"// value, so we\r",
"// need next\r",
"// block, fetch\r",
"// it.\r",
"Block",
"nextBlock",
"=",
"getBlock",
"(",
"sqlquery",
",",
"queryParams",
",",
"nextBlockStart",
",",
"blockSize",
")",
";",
"if",
"(",
"nextBlock",
"!=",
"null",
")",
"{",
"block",
".",
"getList",
"(",
")",
".",
"addAll",
"(",
"nextBlock",
".",
"getList",
"(",
")",
")",
";",
"block",
".",
"setCount",
"(",
"block",
".",
"getCount",
"(",
")",
"+",
"nextBlock",
".",
"getCount",
"(",
")",
")",
";",
"}",
"return",
"block",
";",
"}",
"else",
"return",
"block",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\" locate Block error\"",
"+",
"e",
",",
"module",
")",
";",
"}",
"return",
"block",
";",
"}"
] | looking for the primary be equals to locateId in the result for the sql
sentence.
@param sqlquery
@param queryParams
@param locateId
@return if not locate, return null; | [
"looking",
"for",
"the",
"primary",
"be",
"equals",
"to",
"locateId",
"in",
"the",
"result",
"for",
"the",
"sql",
"sentence",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java#L63-L133 |
23,745 | banq/jdonframework | JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java | BlockStrategy.getBlock | private Block getBlock(QueryConditonDatakey qcdk) {
Block clientBlock = new Block(qcdk.getStart(), qcdk.getCount());
if (clientBlock.getCount() > this.blockLength)
clientBlock.setCount(this.blockLength);
// create dataBlock get DataBase or cache;
List list = getBlockKeys(qcdk);
Block dataBlock = new Block(qcdk.getBlockStart(), list.size());
int currentStart = clientBlock.getStart() - dataBlock.getStart();
Block currentBlock = new Block(currentStart, clientBlock.getCount());
currentBlock.setList(list);
try {
// because clientBlock's length maybe not be equals to the
// dataBlock's length
// we need the last length:
// 1.the last block length is great than the clientBlock's
// length,the current block's length is the clientBlock's length
// 2.the last block length is less than the clientBlock's
// length,under this condition, there are two choice.
int lastCount = dataBlock.getCount() + dataBlock.getStart() - clientBlock.getStart();
Debug.logVerbose("[JdonFramework] lastCount=" + lastCount, module);
// 2 happened
if (lastCount < clientBlock.getCount()) {
// if 2 , two case:
// 1. if the dataBlock's length is this.blockLength(200),should
// have more dataBlocks.
if (dataBlock.getCount() == this.blockLength) {
// new datablock, we must support new start and new count
// the new start = old datablock's length + old datablock's
// start.
int newStartIndex = dataBlock.getStart() + dataBlock.getCount();
int newCount = clientBlock.getCount() - lastCount;
qcdk.setStart(newStartIndex);
qcdk.setCount(newCount);
Debug.logVerbose("[JdonFramework] newStartIndex=" + newStartIndex + " newCount=" + newCount, module);
Block nextBlock = getBlock(qcdk);
Debug.logVerbose("[JdonFramework] nextBlock.getCount()=" + nextBlock.getCount(), module);
currentBlock.setCount(currentBlock.getCount() + nextBlock.getCount());
} else {
// 2. if not, all datas just be here, clientBlock's count
// value maybe not correct.
currentBlock.setCount(lastCount);
}
}
} catch (Exception e) {
Debug.logError(" getBlock error" + e, module);
}
return currentBlock;
} | java | private Block getBlock(QueryConditonDatakey qcdk) {
Block clientBlock = new Block(qcdk.getStart(), qcdk.getCount());
if (clientBlock.getCount() > this.blockLength)
clientBlock.setCount(this.blockLength);
// create dataBlock get DataBase or cache;
List list = getBlockKeys(qcdk);
Block dataBlock = new Block(qcdk.getBlockStart(), list.size());
int currentStart = clientBlock.getStart() - dataBlock.getStart();
Block currentBlock = new Block(currentStart, clientBlock.getCount());
currentBlock.setList(list);
try {
// because clientBlock's length maybe not be equals to the
// dataBlock's length
// we need the last length:
// 1.the last block length is great than the clientBlock's
// length,the current block's length is the clientBlock's length
// 2.the last block length is less than the clientBlock's
// length,under this condition, there are two choice.
int lastCount = dataBlock.getCount() + dataBlock.getStart() - clientBlock.getStart();
Debug.logVerbose("[JdonFramework] lastCount=" + lastCount, module);
// 2 happened
if (lastCount < clientBlock.getCount()) {
// if 2 , two case:
// 1. if the dataBlock's length is this.blockLength(200),should
// have more dataBlocks.
if (dataBlock.getCount() == this.blockLength) {
// new datablock, we must support new start and new count
// the new start = old datablock's length + old datablock's
// start.
int newStartIndex = dataBlock.getStart() + dataBlock.getCount();
int newCount = clientBlock.getCount() - lastCount;
qcdk.setStart(newStartIndex);
qcdk.setCount(newCount);
Debug.logVerbose("[JdonFramework] newStartIndex=" + newStartIndex + " newCount=" + newCount, module);
Block nextBlock = getBlock(qcdk);
Debug.logVerbose("[JdonFramework] nextBlock.getCount()=" + nextBlock.getCount(), module);
currentBlock.setCount(currentBlock.getCount() + nextBlock.getCount());
} else {
// 2. if not, all datas just be here, clientBlock's count
// value maybe not correct.
currentBlock.setCount(lastCount);
}
}
} catch (Exception e) {
Debug.logError(" getBlock error" + e, module);
}
return currentBlock;
} | [
"private",
"Block",
"getBlock",
"(",
"QueryConditonDatakey",
"qcdk",
")",
"{",
"Block",
"clientBlock",
"=",
"new",
"Block",
"(",
"qcdk",
".",
"getStart",
"(",
")",
",",
"qcdk",
".",
"getCount",
"(",
")",
")",
";",
"if",
"(",
"clientBlock",
".",
"getCount",
"(",
")",
">",
"this",
".",
"blockLength",
")",
"clientBlock",
".",
"setCount",
"(",
"this",
".",
"blockLength",
")",
";",
"// create dataBlock get DataBase or cache;\r",
"List",
"list",
"=",
"getBlockKeys",
"(",
"qcdk",
")",
";",
"Block",
"dataBlock",
"=",
"new",
"Block",
"(",
"qcdk",
".",
"getBlockStart",
"(",
")",
",",
"list",
".",
"size",
"(",
")",
")",
";",
"int",
"currentStart",
"=",
"clientBlock",
".",
"getStart",
"(",
")",
"-",
"dataBlock",
".",
"getStart",
"(",
")",
";",
"Block",
"currentBlock",
"=",
"new",
"Block",
"(",
"currentStart",
",",
"clientBlock",
".",
"getCount",
"(",
")",
")",
";",
"currentBlock",
".",
"setList",
"(",
"list",
")",
";",
"try",
"{",
"// because clientBlock's length maybe not be equals to the\r",
"// dataBlock's length\r",
"// we need the last length:\r",
"// 1.the last block length is great than the clientBlock's\r",
"// length,the current block's length is the clientBlock's length\r",
"// 2.the last block length is less than the clientBlock's\r",
"// length,under this condition, there are two choice.\r",
"int",
"lastCount",
"=",
"dataBlock",
".",
"getCount",
"(",
")",
"+",
"dataBlock",
".",
"getStart",
"(",
")",
"-",
"clientBlock",
".",
"getStart",
"(",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] lastCount=\"",
"+",
"lastCount",
",",
"module",
")",
";",
"// 2 happened\r",
"if",
"(",
"lastCount",
"<",
"clientBlock",
".",
"getCount",
"(",
")",
")",
"{",
"// if 2 , two case:\r",
"// 1. if the dataBlock's length is this.blockLength(200),should\r",
"// have more dataBlocks.\r",
"if",
"(",
"dataBlock",
".",
"getCount",
"(",
")",
"==",
"this",
".",
"blockLength",
")",
"{",
"// new datablock, we must support new start and new count\r",
"// the new start = old datablock's length + old datablock's\r",
"// start.\r",
"int",
"newStartIndex",
"=",
"dataBlock",
".",
"getStart",
"(",
")",
"+",
"dataBlock",
".",
"getCount",
"(",
")",
";",
"int",
"newCount",
"=",
"clientBlock",
".",
"getCount",
"(",
")",
"-",
"lastCount",
";",
"qcdk",
".",
"setStart",
"(",
"newStartIndex",
")",
";",
"qcdk",
".",
"setCount",
"(",
"newCount",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] newStartIndex=\"",
"+",
"newStartIndex",
"+",
"\" newCount=\"",
"+",
"newCount",
",",
"module",
")",
";",
"Block",
"nextBlock",
"=",
"getBlock",
"(",
"qcdk",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] nextBlock.getCount()=\"",
"+",
"nextBlock",
".",
"getCount",
"(",
")",
",",
"module",
")",
";",
"currentBlock",
".",
"setCount",
"(",
"currentBlock",
".",
"getCount",
"(",
")",
"+",
"nextBlock",
".",
"getCount",
"(",
")",
")",
";",
"}",
"else",
"{",
"// 2. if not, all datas just be here, clientBlock's count\r",
"// value maybe not correct.\r",
"currentBlock",
".",
"setCount",
"(",
"lastCount",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"Debug",
".",
"logError",
"(",
"\" getBlock error\"",
"+",
"e",
",",
"module",
")",
";",
"}",
"return",
"currentBlock",
";",
"}"
] | get the current block being avaliable to the query condition
@param qcdk
@return | [
"get",
"the",
"current",
"block",
"being",
"avaliable",
"to",
"the",
"query",
"condition"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java#L167-L217 |
23,746 | banq/jdonframework | JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java | BlockStrategy.getBlockKeys | private List getBlockKeys(QueryConditonDatakey qcdk) {
List keys = blockCacheManager.getBlockKeysFromCache(qcdk);
if ((keys == null)) {
keys = blockQueryJDBC.fetchDatas(qcdk);
if (keys != null && keys.size() != 0)
blockCacheManager.saveBlockKeys(qcdk, keys);
}
Debug.logVerbose("[JdonFramework] getBlockKeys, size=" + keys.size(), module);
return keys;
} | java | private List getBlockKeys(QueryConditonDatakey qcdk) {
List keys = blockCacheManager.getBlockKeysFromCache(qcdk);
if ((keys == null)) {
keys = blockQueryJDBC.fetchDatas(qcdk);
if (keys != null && keys.size() != 0)
blockCacheManager.saveBlockKeys(qcdk, keys);
}
Debug.logVerbose("[JdonFramework] getBlockKeys, size=" + keys.size(), module);
return keys;
} | [
"private",
"List",
"getBlockKeys",
"(",
"QueryConditonDatakey",
"qcdk",
")",
"{",
"List",
"keys",
"=",
"blockCacheManager",
".",
"getBlockKeysFromCache",
"(",
"qcdk",
")",
";",
"if",
"(",
"(",
"keys",
"==",
"null",
")",
")",
"{",
"keys",
"=",
"blockQueryJDBC",
".",
"fetchDatas",
"(",
"qcdk",
")",
";",
"if",
"(",
"keys",
"!=",
"null",
"&&",
"keys",
".",
"size",
"(",
")",
"!=",
"0",
")",
"blockCacheManager",
".",
"saveBlockKeys",
"(",
"qcdk",
",",
"keys",
")",
";",
"}",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] getBlockKeys, size=\"",
"+",
"keys",
".",
"size",
"(",
")",
",",
"module",
")",
";",
"return",
"keys",
";",
"}"
] | get a Block that begin at the start
@param qcdk
QueryConditonDatakey
@return return the collection fit for start value and count value. | [
"get",
"a",
"Block",
"that",
"begin",
"at",
"the",
"start"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/block/BlockStrategy.java#L226-L235 |
23,747 | banq/jdonframework | src/main/java/com/jdon/controller/context/web/RequestWrapperFactory.java | RequestWrapperFactory.create | public static RequestWrapper create(HttpServletRequest request) {
HttpSession session = request.getSession();
AppContextWrapper acw = new ServletContextWrapper(session.getServletContext());
SessionWrapper sw = new HttpSessionWrapper(session);
ContextHolder contextHolder = new ContextHolder(acw, sw);
return new HttpServletRequestWrapper(request, contextHolder);
} | java | public static RequestWrapper create(HttpServletRequest request) {
HttpSession session = request.getSession();
AppContextWrapper acw = new ServletContextWrapper(session.getServletContext());
SessionWrapper sw = new HttpSessionWrapper(session);
ContextHolder contextHolder = new ContextHolder(acw, sw);
return new HttpServletRequestWrapper(request, contextHolder);
} | [
"public",
"static",
"RequestWrapper",
"create",
"(",
"HttpServletRequest",
"request",
")",
"{",
"HttpSession",
"session",
"=",
"request",
".",
"getSession",
"(",
")",
";",
"AppContextWrapper",
"acw",
"=",
"new",
"ServletContextWrapper",
"(",
"session",
".",
"getServletContext",
"(",
")",
")",
";",
"SessionWrapper",
"sw",
"=",
"new",
"HttpSessionWrapper",
"(",
"session",
")",
";",
"ContextHolder",
"contextHolder",
"=",
"new",
"ContextHolder",
"(",
"acw",
",",
"sw",
")",
";",
"return",
"new",
"HttpServletRequestWrapper",
"(",
"request",
",",
"contextHolder",
")",
";",
"}"
] | create a HttpServletRequestWrapper with session supports. this method
will create HttpSession.
@param request
@return | [
"create",
"a",
"HttpServletRequestWrapper",
"with",
"session",
"supports",
".",
"this",
"method",
"will",
"create",
"HttpSession",
"."
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/controller/context/web/RequestWrapperFactory.java#L35-L43 |
23,748 | banq/jdonframework | JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/JdbcUtil.java | JdbcUtil.setQueryParams | public void setQueryParams(Collection queryParams, PreparedStatement ps) throws Exception {
if ((queryParams == null) || (queryParams.size() == 0))
return;
int i = 1;
Object key = null;
Iterator iter = queryParams.iterator();
while (iter.hasNext()) {
key = iter.next();
if (key != null) {
convertType(i, key, ps);
Debug.logVerbose("[JdonFramework] parameter " + i + " = " + key.toString(), module);
} else {
Debug.logWarning("[JdonFramework] parameter " + i + " is null", module);
ps.setString(i, "");
}
i++;
}
} | java | public void setQueryParams(Collection queryParams, PreparedStatement ps) throws Exception {
if ((queryParams == null) || (queryParams.size() == 0))
return;
int i = 1;
Object key = null;
Iterator iter = queryParams.iterator();
while (iter.hasNext()) {
key = iter.next();
if (key != null) {
convertType(i, key, ps);
Debug.logVerbose("[JdonFramework] parameter " + i + " = " + key.toString(), module);
} else {
Debug.logWarning("[JdonFramework] parameter " + i + " is null", module);
ps.setString(i, "");
}
i++;
}
} | [
"public",
"void",
"setQueryParams",
"(",
"Collection",
"queryParams",
",",
"PreparedStatement",
"ps",
")",
"throws",
"Exception",
"{",
"if",
"(",
"(",
"queryParams",
"==",
"null",
")",
"||",
"(",
"queryParams",
".",
"size",
"(",
")",
"==",
"0",
")",
")",
"return",
";",
"int",
"i",
"=",
"1",
";",
"Object",
"key",
"=",
"null",
";",
"Iterator",
"iter",
"=",
"queryParams",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"iter",
".",
"hasNext",
"(",
")",
")",
"{",
"key",
"=",
"iter",
".",
"next",
"(",
")",
";",
"if",
"(",
"key",
"!=",
"null",
")",
"{",
"convertType",
"(",
"i",
",",
"key",
",",
"ps",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] parameter \"",
"+",
"i",
"+",
"\" = \"",
"+",
"key",
".",
"toString",
"(",
")",
",",
"module",
")",
";",
"}",
"else",
"{",
"Debug",
".",
"logWarning",
"(",
"\"[JdonFramework] parameter \"",
"+",
"i",
"+",
"\" is null\"",
",",
"module",
")",
";",
"ps",
".",
"setString",
"(",
"i",
",",
"\"\"",
")",
";",
"}",
"i",
"++",
";",
"}",
"}"
] | queryParam type only support String Integer Float or Long Double Bye
Short if you need operate other types, you must use JDBC directly! | [
"queryParam",
"type",
"only",
"support",
"String",
"Integer",
"Float",
"or",
"Long",
"Double",
"Bye",
"Short",
"if",
"you",
"need",
"operate",
"other",
"types",
"you",
"must",
"use",
"JDBC",
"directly!"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/JdbcUtil.java#L43-L62 |
23,749 | banq/jdonframework | JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/JdbcUtil.java | JdbcUtil.extract | public List extract(ResultSet rs) throws Exception {
ResultSetMetaData meta = rs.getMetaData();
int count = meta.getColumnCount();
List ret = new ArrayList();
while (rs.next()) {
Map map = new LinkedHashMap(count);
for (int i = 1; i <= count; i++) {
map.put(meta.getColumnName(i), rs.getObject(i));
}
ret.add(map);
}
return ret;
} | java | public List extract(ResultSet rs) throws Exception {
ResultSetMetaData meta = rs.getMetaData();
int count = meta.getColumnCount();
List ret = new ArrayList();
while (rs.next()) {
Map map = new LinkedHashMap(count);
for (int i = 1; i <= count; i++) {
map.put(meta.getColumnName(i), rs.getObject(i));
}
ret.add(map);
}
return ret;
} | [
"public",
"List",
"extract",
"(",
"ResultSet",
"rs",
")",
"throws",
"Exception",
"{",
"ResultSetMetaData",
"meta",
"=",
"rs",
".",
"getMetaData",
"(",
")",
";",
"int",
"count",
"=",
"meta",
".",
"getColumnCount",
"(",
")",
";",
"List",
"ret",
"=",
"new",
"ArrayList",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"Map",
"map",
"=",
"new",
"LinkedHashMap",
"(",
"count",
")",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"count",
";",
"i",
"++",
")",
"{",
"map",
".",
"put",
"(",
"meta",
".",
"getColumnName",
"(",
"i",
")",
",",
"rs",
".",
"getObject",
"(",
"i",
")",
")",
";",
"}",
"ret",
".",
"add",
"(",
"map",
")",
";",
"}",
"return",
"ret",
";",
"}"
] | return a List in the List, every object is a map, by database column
name, we can get the its result from map
@param rs
ResultSet
@return List
@throws Exception | [
"return",
"a",
"List",
"in",
"the",
"List",
"every",
"object",
"is",
"a",
"map",
"by",
"database",
"column",
"name",
"we",
"can",
"get",
"the",
"its",
"result",
"from",
"map"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/JdonAccessory/jdon-hibernate3x/src/main/java/com/jdon/model/query/JdbcUtil.java#L104-L116 |
23,750 | banq/jdonframework | src/main/java/com/jdon/aop/AopClient.java | AopClient.invoke | public Object invoke(TargetMetaRequest targetMetaRequest, Method method, Object[] args) throws Throwable {
targetMetaRequestsHolder.setTargetMetaRequest(targetMetaRequest);
Debug.logVerbose(
"[JdonFramework] enter AOP invoker2 for:" + targetMetaRequest.getTargetMetaDef().getClassName() + " method:" + method.getName(),
module);
Object result = null;
MethodInvocation methodInvocation = null;
try {
List<MethodInterceptor> chain = advisorChainFactory.create(targetMetaRequest.getTargetMetaDef());
methodInvocation = new ProxyMethodInvocation(chain, targetMetaRequestsHolder, targetServiceFactory, method, args);
Debug.logVerbose("[JdonFramework] MethodInvocation will proceed ... ", module);
result = methodInvocation.proceed();
} catch (Exception ex) {
Debug.logError(ex, module);
throw new Exception(ex);
} catch (Throwable ex) {
throw new Throwable(ex);
} finally {
targetMetaRequestsHolder.clear();
}
return result;
} | java | public Object invoke(TargetMetaRequest targetMetaRequest, Method method, Object[] args) throws Throwable {
targetMetaRequestsHolder.setTargetMetaRequest(targetMetaRequest);
Debug.logVerbose(
"[JdonFramework] enter AOP invoker2 for:" + targetMetaRequest.getTargetMetaDef().getClassName() + " method:" + method.getName(),
module);
Object result = null;
MethodInvocation methodInvocation = null;
try {
List<MethodInterceptor> chain = advisorChainFactory.create(targetMetaRequest.getTargetMetaDef());
methodInvocation = new ProxyMethodInvocation(chain, targetMetaRequestsHolder, targetServiceFactory, method, args);
Debug.logVerbose("[JdonFramework] MethodInvocation will proceed ... ", module);
result = methodInvocation.proceed();
} catch (Exception ex) {
Debug.logError(ex, module);
throw new Exception(ex);
} catch (Throwable ex) {
throw new Throwable(ex);
} finally {
targetMetaRequestsHolder.clear();
}
return result;
} | [
"public",
"Object",
"invoke",
"(",
"TargetMetaRequest",
"targetMetaRequest",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"targetMetaRequestsHolder",
".",
"setTargetMetaRequest",
"(",
"targetMetaRequest",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] enter AOP invoker2 for:\"",
"+",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
".",
"getClassName",
"(",
")",
"+",
"\" method:\"",
"+",
"method",
".",
"getName",
"(",
")",
",",
"module",
")",
";",
"Object",
"result",
"=",
"null",
";",
"MethodInvocation",
"methodInvocation",
"=",
"null",
";",
"try",
"{",
"List",
"<",
"MethodInterceptor",
">",
"chain",
"=",
"advisorChainFactory",
".",
"create",
"(",
"targetMetaRequest",
".",
"getTargetMetaDef",
"(",
")",
")",
";",
"methodInvocation",
"=",
"new",
"ProxyMethodInvocation",
"(",
"chain",
",",
"targetMetaRequestsHolder",
",",
"targetServiceFactory",
",",
"method",
",",
"args",
")",
";",
"Debug",
".",
"logVerbose",
"(",
"\"[JdonFramework] MethodInvocation will proceed ... \"",
",",
"module",
")",
";",
"result",
"=",
"methodInvocation",
".",
"proceed",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"Debug",
".",
"logError",
"(",
"ex",
",",
"module",
")",
";",
"throw",
"new",
"Exception",
"(",
"ex",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"throw",
"new",
"Throwable",
"(",
"ex",
")",
";",
"}",
"finally",
"{",
"targetMetaRequestsHolder",
".",
"clear",
"(",
")",
";",
"}",
"return",
"result",
";",
"}"
] | dynamic proxy active this method when client call userService.xxxmethod
@param targetMetaRequest
@param method
@param args
@return
@throws Throwable | [
"dynamic",
"proxy",
"active",
"this",
"method",
"when",
"client",
"call",
"userService",
".",
"xxxmethod"
] | 72b451caac04f775e57f52aaed3d8775044ead53 | https://github.com/banq/jdonframework/blob/72b451caac04f775e57f52aaed3d8775044ead53/src/main/java/com/jdon/aop/AopClient.java#L101-L124 |
23,751 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/refactor/rename/Rename.java | Rename.label | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.label(oldLabel, newLabel, [nodes]) | rename a label from 'oldLabel' to 'newLabel' for all nodes. If 'nodes' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> label(@Name("oldLabel") String oldLabel, @Name("newLabel") String newLabel, @Name(value = "nodes", defaultValue = "") List<Node> nodes) {
String cypherIterate = nodes != null && !nodes.isEmpty() ? "UNWIND {nodes} AS n WITH n WHERE n:`"+oldLabel+"` RETURN n" : "MATCH (n:`"+oldLabel+"`) RETURN n";
String cypherAction = "SET n:`"+newLabel+"` REMOVE n:`"+oldLabel+"`";
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("nodes", nodes));
return getResultOfBatchAndTotalWithInfo( newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, oldLabel, null, null);
} | java | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.label(oldLabel, newLabel, [nodes]) | rename a label from 'oldLabel' to 'newLabel' for all nodes. If 'nodes' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> label(@Name("oldLabel") String oldLabel, @Name("newLabel") String newLabel, @Name(value = "nodes", defaultValue = "") List<Node> nodes) {
String cypherIterate = nodes != null && !nodes.isEmpty() ? "UNWIND {nodes} AS n WITH n WHERE n:`"+oldLabel+"` RETURN n" : "MATCH (n:`"+oldLabel+"`) RETURN n";
String cypherAction = "SET n:`"+newLabel+"` REMOVE n:`"+oldLabel+"`";
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("nodes", nodes));
return getResultOfBatchAndTotalWithInfo( newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, oldLabel, null, null);
} | [
"@",
"Procedure",
"(",
"mode",
"=",
"Mode",
".",
"WRITE",
")",
"@",
"Description",
"(",
"\"apoc.refactor.rename.label(oldLabel, newLabel, [nodes]) | rename a label from 'oldLabel' to 'newLabel' for all nodes. If 'nodes' is provided renaming is applied to this set only\"",
")",
"public",
"Stream",
"<",
"BatchAndTotalResultWithInfo",
">",
"label",
"(",
"@",
"Name",
"(",
"\"oldLabel\"",
")",
"String",
"oldLabel",
",",
"@",
"Name",
"(",
"\"newLabel\"",
")",
"String",
"newLabel",
",",
"@",
"Name",
"(",
"value",
"=",
"\"nodes\"",
",",
"defaultValue",
"=",
"\"\"",
")",
"List",
"<",
"Node",
">",
"nodes",
")",
"{",
"String",
"cypherIterate",
"=",
"nodes",
"!=",
"null",
"&&",
"!",
"nodes",
".",
"isEmpty",
"(",
")",
"?",
"\"UNWIND {nodes} AS n WITH n WHERE n:`\"",
"+",
"oldLabel",
"+",
"\"` RETURN n\"",
":",
"\"MATCH (n:`\"",
"+",
"oldLabel",
"+",
"\"`) RETURN n\"",
";",
"String",
"cypherAction",
"=",
"\"SET n:`\"",
"+",
"newLabel",
"+",
"\"` REMOVE n:`\"",
"+",
"oldLabel",
"+",
"\"`\"",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
"=",
"MapUtil",
".",
"map",
"(",
"\"batchSize\"",
",",
"100000",
",",
"\"parallel\"",
",",
"true",
",",
"\"iterateList\"",
",",
"true",
",",
"\"params\"",
",",
"MapUtil",
".",
"map",
"(",
"\"nodes\"",
",",
"nodes",
")",
")",
";",
"return",
"getResultOfBatchAndTotalWithInfo",
"(",
"newPeriodic",
"(",
")",
".",
"iterate",
"(",
"cypherIterate",
",",
"cypherAction",
",",
"parameters",
")",
",",
"db",
",",
"oldLabel",
",",
"null",
",",
"null",
")",
";",
"}"
] | Rename the Label of a node by creating a new one and deleting the old. | [
"Rename",
"the",
"Label",
"of",
"a",
"node",
"by",
"creating",
"a",
"new",
"one",
"and",
"deleting",
"the",
"old",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/refactor/rename/Rename.java#L35-L42 |
23,752 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/refactor/rename/Rename.java | Rename.type | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.type(oldType, newType, [rels]) | rename all relationships with type 'oldType' to 'newType'. If 'rels' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> type(@Name("oldType") String oldType, @Name("newType") String newType, @Name(value = "rels", defaultValue = "") List<Relationship> rels) {
String cypherIterate = rels != null && ! rels.isEmpty() ? "UNWIND {rels} AS oldRel WITH oldRel WHERE type(oldRel)=\""+oldType+"\" RETURN oldRel,startNode(oldRel) as a,endNode(oldRel) as b" : "MATCH (a)-[oldRel:`"+oldType+"`]->(b) RETURN oldRel,a,b";
String cypherAction = "CREATE(a)-[newRel:`"+newType+"`]->(b)"+ "SET newRel+=oldRel DELETE oldRel";
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("rels", rels));
return getResultOfBatchAndTotalWithInfo(newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, null, oldType, null);
} | java | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.type(oldType, newType, [rels]) | rename all relationships with type 'oldType' to 'newType'. If 'rels' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> type(@Name("oldType") String oldType, @Name("newType") String newType, @Name(value = "rels", defaultValue = "") List<Relationship> rels) {
String cypherIterate = rels != null && ! rels.isEmpty() ? "UNWIND {rels} AS oldRel WITH oldRel WHERE type(oldRel)=\""+oldType+"\" RETURN oldRel,startNode(oldRel) as a,endNode(oldRel) as b" : "MATCH (a)-[oldRel:`"+oldType+"`]->(b) RETURN oldRel,a,b";
String cypherAction = "CREATE(a)-[newRel:`"+newType+"`]->(b)"+ "SET newRel+=oldRel DELETE oldRel";
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("rels", rels));
return getResultOfBatchAndTotalWithInfo(newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, null, oldType, null);
} | [
"@",
"Procedure",
"(",
"mode",
"=",
"Mode",
".",
"WRITE",
")",
"@",
"Description",
"(",
"\"apoc.refactor.rename.type(oldType, newType, [rels]) | rename all relationships with type 'oldType' to 'newType'. If 'rels' is provided renaming is applied to this set only\"",
")",
"public",
"Stream",
"<",
"BatchAndTotalResultWithInfo",
">",
"type",
"(",
"@",
"Name",
"(",
"\"oldType\"",
")",
"String",
"oldType",
",",
"@",
"Name",
"(",
"\"newType\"",
")",
"String",
"newType",
",",
"@",
"Name",
"(",
"value",
"=",
"\"rels\"",
",",
"defaultValue",
"=",
"\"\"",
")",
"List",
"<",
"Relationship",
">",
"rels",
")",
"{",
"String",
"cypherIterate",
"=",
"rels",
"!=",
"null",
"&&",
"!",
"rels",
".",
"isEmpty",
"(",
")",
"?",
"\"UNWIND {rels} AS oldRel WITH oldRel WHERE type(oldRel)=\\\"\"",
"+",
"oldType",
"+",
"\"\\\" RETURN oldRel,startNode(oldRel) as a,endNode(oldRel) as b\"",
":",
"\"MATCH (a)-[oldRel:`\"",
"+",
"oldType",
"+",
"\"`]->(b) RETURN oldRel,a,b\"",
";",
"String",
"cypherAction",
"=",
"\"CREATE(a)-[newRel:`\"",
"+",
"newType",
"+",
"\"`]->(b)\"",
"+",
"\"SET newRel+=oldRel DELETE oldRel\"",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
"=",
"MapUtil",
".",
"map",
"(",
"\"batchSize\"",
",",
"100000",
",",
"\"parallel\"",
",",
"true",
",",
"\"iterateList\"",
",",
"true",
",",
"\"params\"",
",",
"MapUtil",
".",
"map",
"(",
"\"rels\"",
",",
"rels",
")",
")",
";",
"return",
"getResultOfBatchAndTotalWithInfo",
"(",
"newPeriodic",
"(",
")",
".",
"iterate",
"(",
"cypherIterate",
",",
"cypherAction",
",",
"parameters",
")",
",",
"db",
",",
"null",
",",
"oldType",
",",
"null",
")",
";",
"}"
] | Rename the Relationship Type by creating a new one and deleting the old. | [
"Rename",
"the",
"Relationship",
"Type",
"by",
"creating",
"a",
"new",
"one",
"and",
"deleting",
"the",
"old",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/refactor/rename/Rename.java#L47-L54 |
23,753 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/refactor/rename/Rename.java | Rename.nodeProperty | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.nodeProperty(oldName, newName, [nodes]) | rename all node's property from 'oldName' to 'newName'. If 'nodes' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> nodeProperty(@Name("oldName") String oldName, @Name("newName") String newName, @Name(value="nodes", defaultValue = "") List<Object> nodes) {
String cypherIterate = nodes != null && ! nodes.isEmpty() ? "UNWIND {nodes} AS n WITH n WHERE exists (n."+oldName+") return n" : "match (n) where exists (n."+oldName+") return n";
String cypherAction = "set n."+newName+"= n."+oldName+" remove n."+oldName;
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("nodes", nodes));
return getResultOfBatchAndTotalWithInfo(newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, null, null, oldName);
} | java | @Procedure(mode = Mode.WRITE)
@Description("apoc.refactor.rename.nodeProperty(oldName, newName, [nodes]) | rename all node's property from 'oldName' to 'newName'. If 'nodes' is provided renaming is applied to this set only")
public Stream<BatchAndTotalResultWithInfo> nodeProperty(@Name("oldName") String oldName, @Name("newName") String newName, @Name(value="nodes", defaultValue = "") List<Object> nodes) {
String cypherIterate = nodes != null && ! nodes.isEmpty() ? "UNWIND {nodes} AS n WITH n WHERE exists (n."+oldName+") return n" : "match (n) where exists (n."+oldName+") return n";
String cypherAction = "set n."+newName+"= n."+oldName+" remove n."+oldName;
Map<String, Object> parameters = MapUtil.map("batchSize", 100000, "parallel", true, "iterateList", true, "params", MapUtil.map("nodes", nodes));
return getResultOfBatchAndTotalWithInfo(newPeriodic().iterate(cypherIterate, cypherAction, parameters), db, null, null, oldName);
} | [
"@",
"Procedure",
"(",
"mode",
"=",
"Mode",
".",
"WRITE",
")",
"@",
"Description",
"(",
"\"apoc.refactor.rename.nodeProperty(oldName, newName, [nodes]) | rename all node's property from 'oldName' to 'newName'. If 'nodes' is provided renaming is applied to this set only\"",
")",
"public",
"Stream",
"<",
"BatchAndTotalResultWithInfo",
">",
"nodeProperty",
"(",
"@",
"Name",
"(",
"\"oldName\"",
")",
"String",
"oldName",
",",
"@",
"Name",
"(",
"\"newName\"",
")",
"String",
"newName",
",",
"@",
"Name",
"(",
"value",
"=",
"\"nodes\"",
",",
"defaultValue",
"=",
"\"\"",
")",
"List",
"<",
"Object",
">",
"nodes",
")",
"{",
"String",
"cypherIterate",
"=",
"nodes",
"!=",
"null",
"&&",
"!",
"nodes",
".",
"isEmpty",
"(",
")",
"?",
"\"UNWIND {nodes} AS n WITH n WHERE exists (n.\"",
"+",
"oldName",
"+",
"\") return n\"",
":",
"\"match (n) where exists (n.\"",
"+",
"oldName",
"+",
"\") return n\"",
";",
"String",
"cypherAction",
"=",
"\"set n.\"",
"+",
"newName",
"+",
"\"= n.\"",
"+",
"oldName",
"+",
"\" remove n.\"",
"+",
"oldName",
";",
"Map",
"<",
"String",
",",
"Object",
">",
"parameters",
"=",
"MapUtil",
".",
"map",
"(",
"\"batchSize\"",
",",
"100000",
",",
"\"parallel\"",
",",
"true",
",",
"\"iterateList\"",
",",
"true",
",",
"\"params\"",
",",
"MapUtil",
".",
"map",
"(",
"\"nodes\"",
",",
"nodes",
")",
")",
";",
"return",
"getResultOfBatchAndTotalWithInfo",
"(",
"newPeriodic",
"(",
")",
".",
"iterate",
"(",
"cypherIterate",
",",
"cypherAction",
",",
"parameters",
")",
",",
"db",
",",
"null",
",",
"null",
",",
"oldName",
")",
";",
"}"
] | Rename property of a node by creating a new one and deleting the old. | [
"Rename",
"property",
"of",
"a",
"node",
"by",
"creating",
"a",
"new",
"one",
"and",
"deleting",
"the",
"old",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/refactor/rename/Rename.java#L59-L66 |
23,754 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/meta/Meta.java | Meta.data | @Procedure
@Description("apoc.meta.data({config}) - examines a subset of the graph to provide a tabular meta information")
public Stream<MetaResult> data(@Name(value = "config",defaultValue = "{}") Map<String,Object> config) {
MetaConfig metaConfig = new MetaConfig(config);
return collectMetaData(metaConfig).values().stream().flatMap(x -> x.values().stream());
} | java | @Procedure
@Description("apoc.meta.data({config}) - examines a subset of the graph to provide a tabular meta information")
public Stream<MetaResult> data(@Name(value = "config",defaultValue = "{}") Map<String,Object> config) {
MetaConfig metaConfig = new MetaConfig(config);
return collectMetaData(metaConfig).values().stream().flatMap(x -> x.values().stream());
} | [
"@",
"Procedure",
"@",
"Description",
"(",
"\"apoc.meta.data({config}) - examines a subset of the graph to provide a tabular meta information\"",
")",
"public",
"Stream",
"<",
"MetaResult",
">",
"data",
"(",
"@",
"Name",
"(",
"value",
"=",
"\"config\"",
",",
"defaultValue",
"=",
"\"{}\"",
")",
"Map",
"<",
"String",
",",
"Object",
">",
"config",
")",
"{",
"MetaConfig",
"metaConfig",
"=",
"new",
"MetaConfig",
"(",
"config",
")",
";",
"return",
"collectMetaData",
"(",
"metaConfig",
")",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"x",
"->",
"x",
".",
"values",
"(",
")",
".",
"stream",
"(",
")",
")",
";",
"}"
] | todo put index sizes for indexed properties | [
"todo",
"put",
"index",
"sizes",
"for",
"indexed",
"properties"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/meta/Meta.java#L408-L413 |
23,755 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Algorithm.java | Algorithm.growArray | private static int [] growArray(int[] array, float growFactor) {
int currentSize = array.length;
int newArray[] = new int[(int)(currentSize * growFactor)];
System.arraycopy(array, 0, newArray, 0, currentSize);
return newArray;
} | java | private static int [] growArray(int[] array, float growFactor) {
int currentSize = array.length;
int newArray[] = new int[(int)(currentSize * growFactor)];
System.arraycopy(array, 0, newArray, 0, currentSize);
return newArray;
} | [
"private",
"static",
"int",
"[",
"]",
"growArray",
"(",
"int",
"[",
"]",
"array",
",",
"float",
"growFactor",
")",
"{",
"int",
"currentSize",
"=",
"array",
".",
"length",
";",
"int",
"newArray",
"[",
"]",
"=",
"new",
"int",
"[",
"(",
"int",
")",
"(",
"currentSize",
"*",
"growFactor",
")",
"]",
";",
"System",
".",
"arraycopy",
"(",
"array",
",",
"0",
",",
"newArray",
",",
"0",
",",
"currentSize",
")",
";",
"return",
"newArray",
";",
"}"
] | Not doing it right now because of the complications of the interface. | [
"Not",
"doing",
"it",
"right",
"now",
"because",
"of",
"the",
"complications",
"of",
"the",
"interface",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Algorithm.java#L119-L124 |
23,756 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.indexExists | private Boolean indexExists(String labelName, List<String> propertyNames) {
Schema schema = db.schema();
for (IndexDefinition indexDefinition : Iterables.asList(schema.getIndexes(Label.label(labelName)))) {
List<String> properties = Iterables.asList(indexDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | java | private Boolean indexExists(String labelName, List<String> propertyNames) {
Schema schema = db.schema();
for (IndexDefinition indexDefinition : Iterables.asList(schema.getIndexes(Label.label(labelName)))) {
List<String> properties = Iterables.asList(indexDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | [
"private",
"Boolean",
"indexExists",
"(",
"String",
"labelName",
",",
"List",
"<",
"String",
">",
"propertyNames",
")",
"{",
"Schema",
"schema",
"=",
"db",
".",
"schema",
"(",
")",
";",
"for",
"(",
"IndexDefinition",
"indexDefinition",
":",
"Iterables",
".",
"asList",
"(",
"schema",
".",
"getIndexes",
"(",
"Label",
".",
"label",
"(",
"labelName",
")",
")",
")",
")",
"{",
"List",
"<",
"String",
">",
"properties",
"=",
"Iterables",
".",
"asList",
"(",
"indexDefinition",
".",
"getPropertyKeys",
"(",
")",
")",
";",
"if",
"(",
"properties",
".",
"equals",
"(",
"propertyNames",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if an index exists for a given label and a list of properties
This method checks for index on nodes
@param labelName
@param propertyNames
@return true if the index exists otherwise it returns false | [
"Checks",
"if",
"an",
"index",
"exists",
"for",
"a",
"given",
"label",
"and",
"a",
"list",
"of",
"properties",
"This",
"method",
"checks",
"for",
"index",
"on",
"nodes"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L210-L222 |
23,757 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.constraintsExists | private Boolean constraintsExists(String labelName, List<String> propertyNames) {
Schema schema = db.schema();
for (ConstraintDefinition constraintDefinition : Iterables.asList(schema.getConstraints(Label.label(labelName)))) {
List<String> properties = Iterables.asList(constraintDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | java | private Boolean constraintsExists(String labelName, List<String> propertyNames) {
Schema schema = db.schema();
for (ConstraintDefinition constraintDefinition : Iterables.asList(schema.getConstraints(Label.label(labelName)))) {
List<String> properties = Iterables.asList(constraintDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | [
"private",
"Boolean",
"constraintsExists",
"(",
"String",
"labelName",
",",
"List",
"<",
"String",
">",
"propertyNames",
")",
"{",
"Schema",
"schema",
"=",
"db",
".",
"schema",
"(",
")",
";",
"for",
"(",
"ConstraintDefinition",
"constraintDefinition",
":",
"Iterables",
".",
"asList",
"(",
"schema",
".",
"getConstraints",
"(",
"Label",
".",
"label",
"(",
"labelName",
")",
")",
")",
")",
"{",
"List",
"<",
"String",
">",
"properties",
"=",
"Iterables",
".",
"asList",
"(",
"constraintDefinition",
".",
"getPropertyKeys",
"(",
")",
")",
";",
"if",
"(",
"properties",
".",
"equals",
"(",
"propertyNames",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if a constraint exists for a given label and a list of properties
This method checks for constraints on node
@param labelName
@param propertyNames
@return true if the constraint exists otherwise it returns false | [
"Checks",
"if",
"a",
"constraint",
"exists",
"for",
"a",
"given",
"label",
"and",
"a",
"list",
"of",
"properties",
"This",
"method",
"checks",
"for",
"constraints",
"on",
"node"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L232-L244 |
23,758 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.constraintsExistsForRelationship | private Boolean constraintsExistsForRelationship(String type, List<String> propertyNames) {
Schema schema = db.schema();
for (ConstraintDefinition constraintDefinition : Iterables.asList(schema.getConstraints(RelationshipType.withName(type)))) {
List<String> properties = Iterables.asList(constraintDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | java | private Boolean constraintsExistsForRelationship(String type, List<String> propertyNames) {
Schema schema = db.schema();
for (ConstraintDefinition constraintDefinition : Iterables.asList(schema.getConstraints(RelationshipType.withName(type)))) {
List<String> properties = Iterables.asList(constraintDefinition.getPropertyKeys());
if (properties.equals(propertyNames)) {
return true;
}
}
return false;
} | [
"private",
"Boolean",
"constraintsExistsForRelationship",
"(",
"String",
"type",
",",
"List",
"<",
"String",
">",
"propertyNames",
")",
"{",
"Schema",
"schema",
"=",
"db",
".",
"schema",
"(",
")",
";",
"for",
"(",
"ConstraintDefinition",
"constraintDefinition",
":",
"Iterables",
".",
"asList",
"(",
"schema",
".",
"getConstraints",
"(",
"RelationshipType",
".",
"withName",
"(",
"type",
")",
")",
")",
")",
"{",
"List",
"<",
"String",
">",
"properties",
"=",
"Iterables",
".",
"asList",
"(",
"constraintDefinition",
".",
"getPropertyKeys",
"(",
")",
")",
";",
"if",
"(",
"properties",
".",
"equals",
"(",
"propertyNames",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Checks if a constraint exists for a given type and a list of properties
This method checks for constraints on relationships
@param type
@param propertyNames
@return true if the constraint exists otherwise it returns false | [
"Checks",
"if",
"a",
"constraint",
"exists",
"for",
"a",
"given",
"type",
"and",
"a",
"list",
"of",
"properties",
"This",
"method",
"checks",
"for",
"constraints",
"on",
"relationships"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L254-L266 |
23,759 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.constraintsForRelationship | private Stream<ConstraintRelationshipInfo> constraintsForRelationship(Map<String,Object> config) {
Schema schema = db.schema();
SchemaConfig schemaConfig = new SchemaConfig(config);
Set<String> includeRelationships = schemaConfig.getRelationships();
Set<String> excludeRelationships = schemaConfig.getExcludeRelationships();
try ( Statement ignore = tx.acquireStatement() ) {
TokenRead tokenRead = tx.tokenRead();
Iterable<ConstraintDefinition> constraintsIterator;
if(!includeRelationships.isEmpty()) {
constraintsIterator = includeRelationships.stream()
.filter(type -> !excludeRelationships.contains(type) && tokenRead.relationshipType(type) != -1)
.flatMap(type -> {
Iterable<ConstraintDefinition> constraintsForType = schema.getConstraints(RelationshipType.withName(type));
return StreamSupport.stream(constraintsForType.spliterator(), false);
})
.collect(Collectors.toList());
} else {
Iterable<ConstraintDefinition> allConstraints = schema.getConstraints();
constraintsIterator = StreamSupport.stream(allConstraints.spliterator(),false)
.filter(index -> !excludeRelationships.contains(index.getRelationshipType().name()))
.collect(Collectors.toList());
}
Stream<ConstraintRelationshipInfo> constraintRelationshipInfoStream = StreamSupport.stream(constraintsIterator.spliterator(), false)
.filter(constraintDefinition -> constraintDefinition.isConstraintType(ConstraintType.RELATIONSHIP_PROPERTY_EXISTENCE))
.map(this::relationshipInfoFromConstraintDefinition);
return constraintRelationshipInfoStream;
}
} | java | private Stream<ConstraintRelationshipInfo> constraintsForRelationship(Map<String,Object> config) {
Schema schema = db.schema();
SchemaConfig schemaConfig = new SchemaConfig(config);
Set<String> includeRelationships = schemaConfig.getRelationships();
Set<String> excludeRelationships = schemaConfig.getExcludeRelationships();
try ( Statement ignore = tx.acquireStatement() ) {
TokenRead tokenRead = tx.tokenRead();
Iterable<ConstraintDefinition> constraintsIterator;
if(!includeRelationships.isEmpty()) {
constraintsIterator = includeRelationships.stream()
.filter(type -> !excludeRelationships.contains(type) && tokenRead.relationshipType(type) != -1)
.flatMap(type -> {
Iterable<ConstraintDefinition> constraintsForType = schema.getConstraints(RelationshipType.withName(type));
return StreamSupport.stream(constraintsForType.spliterator(), false);
})
.collect(Collectors.toList());
} else {
Iterable<ConstraintDefinition> allConstraints = schema.getConstraints();
constraintsIterator = StreamSupport.stream(allConstraints.spliterator(),false)
.filter(index -> !excludeRelationships.contains(index.getRelationshipType().name()))
.collect(Collectors.toList());
}
Stream<ConstraintRelationshipInfo> constraintRelationshipInfoStream = StreamSupport.stream(constraintsIterator.spliterator(), false)
.filter(constraintDefinition -> constraintDefinition.isConstraintType(ConstraintType.RELATIONSHIP_PROPERTY_EXISTENCE))
.map(this::relationshipInfoFromConstraintDefinition);
return constraintRelationshipInfoStream;
}
} | [
"private",
"Stream",
"<",
"ConstraintRelationshipInfo",
">",
"constraintsForRelationship",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"config",
")",
"{",
"Schema",
"schema",
"=",
"db",
".",
"schema",
"(",
")",
";",
"SchemaConfig",
"schemaConfig",
"=",
"new",
"SchemaConfig",
"(",
"config",
")",
";",
"Set",
"<",
"String",
">",
"includeRelationships",
"=",
"schemaConfig",
".",
"getRelationships",
"(",
")",
";",
"Set",
"<",
"String",
">",
"excludeRelationships",
"=",
"schemaConfig",
".",
"getExcludeRelationships",
"(",
")",
";",
"try",
"(",
"Statement",
"ignore",
"=",
"tx",
".",
"acquireStatement",
"(",
")",
")",
"{",
"TokenRead",
"tokenRead",
"=",
"tx",
".",
"tokenRead",
"(",
")",
";",
"Iterable",
"<",
"ConstraintDefinition",
">",
"constraintsIterator",
";",
"if",
"(",
"!",
"includeRelationships",
".",
"isEmpty",
"(",
")",
")",
"{",
"constraintsIterator",
"=",
"includeRelationships",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"type",
"->",
"!",
"excludeRelationships",
".",
"contains",
"(",
"type",
")",
"&&",
"tokenRead",
".",
"relationshipType",
"(",
"type",
")",
"!=",
"-",
"1",
")",
".",
"flatMap",
"(",
"type",
"->",
"{",
"Iterable",
"<",
"ConstraintDefinition",
">",
"constraintsForType",
"=",
"schema",
".",
"getConstraints",
"(",
"RelationshipType",
".",
"withName",
"(",
"type",
")",
")",
";",
"return",
"StreamSupport",
".",
"stream",
"(",
"constraintsForType",
".",
"spliterator",
"(",
")",
",",
"false",
")",
";",
"}",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}",
"else",
"{",
"Iterable",
"<",
"ConstraintDefinition",
">",
"allConstraints",
"=",
"schema",
".",
"getConstraints",
"(",
")",
";",
"constraintsIterator",
"=",
"StreamSupport",
".",
"stream",
"(",
"allConstraints",
".",
"spliterator",
"(",
")",
",",
"false",
")",
".",
"filter",
"(",
"index",
"->",
"!",
"excludeRelationships",
".",
"contains",
"(",
"index",
".",
"getRelationshipType",
"(",
")",
".",
"name",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}",
"Stream",
"<",
"ConstraintRelationshipInfo",
">",
"constraintRelationshipInfoStream",
"=",
"StreamSupport",
".",
"stream",
"(",
"constraintsIterator",
".",
"spliterator",
"(",
")",
",",
"false",
")",
".",
"filter",
"(",
"constraintDefinition",
"->",
"constraintDefinition",
".",
"isConstraintType",
"(",
"ConstraintType",
".",
"RELATIONSHIP_PROPERTY_EXISTENCE",
")",
")",
".",
"map",
"(",
"this",
"::",
"relationshipInfoFromConstraintDefinition",
")",
";",
"return",
"constraintRelationshipInfoStream",
";",
"}",
"}"
] | Collects constraints for relationships
@return | [
"Collects",
"constraints",
"for",
"relationships"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L345-L377 |
23,760 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.nodeInfoFromConstraintDescriptor | private IndexConstraintNodeInfo nodeInfoFromConstraintDescriptor(ConstraintDescriptor constraintDescriptor, TokenNameLookup tokens) {
String labelName = tokens.labelGetName(constraintDescriptor.schema().keyId());
List<String> properties = new ArrayList<>();
Arrays.stream(constraintDescriptor.schema().getPropertyIds()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i)));
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
StringUtils.EMPTY,
ConstraintType.NODE_PROPERTY_EXISTENCE.toString(),
"NO FAILURE",
0,
0,
0,
constraintDescriptor.userDescription(tokens)
);
} | java | private IndexConstraintNodeInfo nodeInfoFromConstraintDescriptor(ConstraintDescriptor constraintDescriptor, TokenNameLookup tokens) {
String labelName = tokens.labelGetName(constraintDescriptor.schema().keyId());
List<String> properties = new ArrayList<>();
Arrays.stream(constraintDescriptor.schema().getPropertyIds()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i)));
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
StringUtils.EMPTY,
ConstraintType.NODE_PROPERTY_EXISTENCE.toString(),
"NO FAILURE",
0,
0,
0,
constraintDescriptor.userDescription(tokens)
);
} | [
"private",
"IndexConstraintNodeInfo",
"nodeInfoFromConstraintDescriptor",
"(",
"ConstraintDescriptor",
"constraintDescriptor",
",",
"TokenNameLookup",
"tokens",
")",
"{",
"String",
"labelName",
"=",
"tokens",
".",
"labelGetName",
"(",
"constraintDescriptor",
".",
"schema",
"(",
")",
".",
"keyId",
"(",
")",
")",
";",
"List",
"<",
"String",
">",
"properties",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Arrays",
".",
"stream",
"(",
"constraintDescriptor",
".",
"schema",
"(",
")",
".",
"getPropertyIds",
"(",
")",
")",
".",
"forEach",
"(",
"(",
"i",
")",
"-",
">",
"properties",
".",
"add",
"(",
"tokens",
".",
"propertyKeyGetName",
"(",
"i",
")",
")",
")",
";",
"return",
"new",
"IndexConstraintNodeInfo",
"(",
"// Pretty print for index name",
"String",
".",
"format",
"(",
"\":%s(%s)\"",
",",
"labelName",
",",
"StringUtils",
".",
"join",
"(",
"properties",
",",
"\",\"",
")",
")",
",",
"labelName",
",",
"properties",
",",
"StringUtils",
".",
"EMPTY",
",",
"ConstraintType",
".",
"NODE_PROPERTY_EXISTENCE",
".",
"toString",
"(",
")",
",",
"\"NO FAILURE\"",
",",
"0",
",",
"0",
",",
"0",
",",
"constraintDescriptor",
".",
"userDescription",
"(",
"tokens",
")",
")",
";",
"}"
] | ConstraintInfo info from ConstraintDescriptor
@param constraintDescriptor
@param tokens
@return | [
"ConstraintInfo",
"info",
"from",
"ConstraintDescriptor"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L386-L403 |
23,761 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.nodeInfoFromIndexDefinition | private IndexConstraintNodeInfo nodeInfoFromIndexDefinition(IndexReference indexReference, SchemaRead schemaRead, TokenNameLookup tokens){
int[] labelIds = indexReference.schema().getEntityTokenIds();
if (labelIds.length != 1) throw new IllegalStateException("Index with more than one label");
String labelName = tokens.labelGetName(labelIds[0]);
List<String> properties = new ArrayList<>();
Arrays.stream(indexReference.properties()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i)));
try {
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
schemaRead.indexGetState(indexReference).toString(),
!indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE",
schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100,
schemaRead.indexSize(indexReference),
schemaRead.indexUniqueValuesSelectivity(indexReference),
indexReference.userDescription(tokens)
);
} catch(IndexNotFoundKernelException e) {
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
"NOT_FOUND",
!indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
"NOT_FOUND",
0,0,0,
indexReference.userDescription(tokens)
);
}
} | java | private IndexConstraintNodeInfo nodeInfoFromIndexDefinition(IndexReference indexReference, SchemaRead schemaRead, TokenNameLookup tokens){
int[] labelIds = indexReference.schema().getEntityTokenIds();
if (labelIds.length != 1) throw new IllegalStateException("Index with more than one label");
String labelName = tokens.labelGetName(labelIds[0]);
List<String> properties = new ArrayList<>();
Arrays.stream(indexReference.properties()).forEach((i) -> properties.add(tokens.propertyKeyGetName(i)));
try {
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
schemaRead.indexGetState(indexReference).toString(),
!indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
schemaRead.indexGetState(indexReference).equals(InternalIndexState.FAILED) ? schemaRead.indexGetFailure(indexReference) : "NO FAILURE",
schemaRead.indexGetPopulationProgress(indexReference).getCompleted() / schemaRead.indexGetPopulationProgress(indexReference).getTotal() * 100,
schemaRead.indexSize(indexReference),
schemaRead.indexUniqueValuesSelectivity(indexReference),
indexReference.userDescription(tokens)
);
} catch(IndexNotFoundKernelException e) {
return new IndexConstraintNodeInfo(
// Pretty print for index name
String.format(":%s(%s)", labelName, StringUtils.join(properties, ",")),
labelName,
properties,
"NOT_FOUND",
!indexReference.isUnique() ? "INDEX" : "UNIQUENESS",
"NOT_FOUND",
0,0,0,
indexReference.userDescription(tokens)
);
}
} | [
"private",
"IndexConstraintNodeInfo",
"nodeInfoFromIndexDefinition",
"(",
"IndexReference",
"indexReference",
",",
"SchemaRead",
"schemaRead",
",",
"TokenNameLookup",
"tokens",
")",
"{",
"int",
"[",
"]",
"labelIds",
"=",
"indexReference",
".",
"schema",
"(",
")",
".",
"getEntityTokenIds",
"(",
")",
";",
"if",
"(",
"labelIds",
".",
"length",
"!=",
"1",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Index with more than one label\"",
")",
";",
"String",
"labelName",
"=",
"tokens",
".",
"labelGetName",
"(",
"labelIds",
"[",
"0",
"]",
")",
";",
"List",
"<",
"String",
">",
"properties",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"Arrays",
".",
"stream",
"(",
"indexReference",
".",
"properties",
"(",
")",
")",
".",
"forEach",
"(",
"(",
"i",
")",
"-",
">",
"properties",
".",
"add",
"(",
"tokens",
".",
"propertyKeyGetName",
"(",
"i",
")",
")",
")",
";",
"try",
"{",
"return",
"new",
"IndexConstraintNodeInfo",
"(",
"// Pretty print for index name",
"String",
".",
"format",
"(",
"\":%s(%s)\"",
",",
"labelName",
",",
"StringUtils",
".",
"join",
"(",
"properties",
",",
"\",\"",
")",
")",
",",
"labelName",
",",
"properties",
",",
"schemaRead",
".",
"indexGetState",
"(",
"indexReference",
")",
".",
"toString",
"(",
")",
",",
"!",
"indexReference",
".",
"isUnique",
"(",
")",
"?",
"\"INDEX\"",
":",
"\"UNIQUENESS\"",
",",
"schemaRead",
".",
"indexGetState",
"(",
"indexReference",
")",
".",
"equals",
"(",
"InternalIndexState",
".",
"FAILED",
")",
"?",
"schemaRead",
".",
"indexGetFailure",
"(",
"indexReference",
")",
":",
"\"NO FAILURE\"",
",",
"schemaRead",
".",
"indexGetPopulationProgress",
"(",
"indexReference",
")",
".",
"getCompleted",
"(",
")",
"/",
"schemaRead",
".",
"indexGetPopulationProgress",
"(",
"indexReference",
")",
".",
"getTotal",
"(",
")",
"*",
"100",
",",
"schemaRead",
".",
"indexSize",
"(",
"indexReference",
")",
",",
"schemaRead",
".",
"indexUniqueValuesSelectivity",
"(",
"indexReference",
")",
",",
"indexReference",
".",
"userDescription",
"(",
"tokens",
")",
")",
";",
"}",
"catch",
"(",
"IndexNotFoundKernelException",
"e",
")",
"{",
"return",
"new",
"IndexConstraintNodeInfo",
"(",
"// Pretty print for index name",
"String",
".",
"format",
"(",
"\":%s(%s)\"",
",",
"labelName",
",",
"StringUtils",
".",
"join",
"(",
"properties",
",",
"\",\"",
")",
")",
",",
"labelName",
",",
"properties",
",",
"\"NOT_FOUND\"",
",",
"!",
"indexReference",
".",
"isUnique",
"(",
")",
"?",
"\"INDEX\"",
":",
"\"UNIQUENESS\"",
",",
"\"NOT_FOUND\"",
",",
"0",
",",
"0",
",",
"0",
",",
"indexReference",
".",
"userDescription",
"(",
"tokens",
")",
")",
";",
"}",
"}"
] | Index info from IndexDefinition
@param indexReference
@param schemaRead
@param tokens
@return | [
"Index",
"info",
"from",
"IndexDefinition"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L413-L446 |
23,762 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/schema/Schemas.java | Schemas.relationshipInfoFromConstraintDefinition | private ConstraintRelationshipInfo relationshipInfoFromConstraintDefinition(ConstraintDefinition constraintDefinition) {
return new ConstraintRelationshipInfo(
String.format("CONSTRAINT %s", constraintDefinition.toString()),
constraintDefinition.getConstraintType().name(),
Iterables.asList(constraintDefinition.getPropertyKeys()),
""
);
} | java | private ConstraintRelationshipInfo relationshipInfoFromConstraintDefinition(ConstraintDefinition constraintDefinition) {
return new ConstraintRelationshipInfo(
String.format("CONSTRAINT %s", constraintDefinition.toString()),
constraintDefinition.getConstraintType().name(),
Iterables.asList(constraintDefinition.getPropertyKeys()),
""
);
} | [
"private",
"ConstraintRelationshipInfo",
"relationshipInfoFromConstraintDefinition",
"(",
"ConstraintDefinition",
"constraintDefinition",
")",
"{",
"return",
"new",
"ConstraintRelationshipInfo",
"(",
"String",
".",
"format",
"(",
"\"CONSTRAINT %s\"",
",",
"constraintDefinition",
".",
"toString",
"(",
")",
")",
",",
"constraintDefinition",
".",
"getConstraintType",
"(",
")",
".",
"name",
"(",
")",
",",
"Iterables",
".",
"asList",
"(",
"constraintDefinition",
".",
"getPropertyKeys",
"(",
")",
")",
",",
"\"\"",
")",
";",
"}"
] | Constraint info from ConstraintDefinition for relationships
@param constraintDefinition
@return | [
"Constraint",
"info",
"from",
"ConstraintDefinition",
"for",
"relationships"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/schema/Schemas.java#L454-L461 |
23,763 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/temporal/TemporalProcedures.java | TemporalProcedures.format | @UserFunction( "apoc.temporal.format" )
@Description( "apoc.temporal.format(input, format) | Format a temporal value" )
public String format(
@Name( "temporal" ) Object input,
@Name( value = "format", defaultValue = "yyyy-MM-dd") String format
) {
try {
DateTimeFormatter formatter = getOrCreate(format);
if (input instanceof LocalDate) {
return ((LocalDate) input).format(formatter);
} else if (input instanceof ZonedDateTime) {
return ((ZonedDateTime) input).format(formatter);
} else if (input instanceof LocalDateTime) {
return ((LocalDateTime) input).format(formatter);
} else if (input instanceof LocalTime) {
return ((LocalTime) input).format(formatter);
} else if (input instanceof OffsetTime) {
return ((OffsetTime) input).format(formatter);
} else if (input instanceof DurationValue) {
return formatDuration(input, format);
}
} catch (Exception e){
throw new RuntimeException("Available formats are:\n" +
String.join("\n", getTypes()) +
"\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats " +
"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
}
return input.toString();
} | java | @UserFunction( "apoc.temporal.format" )
@Description( "apoc.temporal.format(input, format) | Format a temporal value" )
public String format(
@Name( "temporal" ) Object input,
@Name( value = "format", defaultValue = "yyyy-MM-dd") String format
) {
try {
DateTimeFormatter formatter = getOrCreate(format);
if (input instanceof LocalDate) {
return ((LocalDate) input).format(formatter);
} else if (input instanceof ZonedDateTime) {
return ((ZonedDateTime) input).format(formatter);
} else if (input instanceof LocalDateTime) {
return ((LocalDateTime) input).format(formatter);
} else if (input instanceof LocalTime) {
return ((LocalTime) input).format(formatter);
} else if (input instanceof OffsetTime) {
return ((OffsetTime) input).format(formatter);
} else if (input instanceof DurationValue) {
return formatDuration(input, format);
}
} catch (Exception e){
throw new RuntimeException("Available formats are:\n" +
String.join("\n", getTypes()) +
"\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats " +
"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
}
return input.toString();
} | [
"@",
"UserFunction",
"(",
"\"apoc.temporal.format\"",
")",
"@",
"Description",
"(",
"\"apoc.temporal.format(input, format) | Format a temporal value\"",
")",
"public",
"String",
"format",
"(",
"@",
"Name",
"(",
"\"temporal\"",
")",
"Object",
"input",
",",
"@",
"Name",
"(",
"value",
"=",
"\"format\"",
",",
"defaultValue",
"=",
"\"yyyy-MM-dd\"",
")",
"String",
"format",
")",
"{",
"try",
"{",
"DateTimeFormatter",
"formatter",
"=",
"getOrCreate",
"(",
"format",
")",
";",
"if",
"(",
"input",
"instanceof",
"LocalDate",
")",
"{",
"return",
"(",
"(",
"LocalDate",
")",
"input",
")",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"ZonedDateTime",
")",
"{",
"return",
"(",
"(",
"ZonedDateTime",
")",
"input",
")",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"LocalDateTime",
")",
"{",
"return",
"(",
"(",
"LocalDateTime",
")",
"input",
")",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"LocalTime",
")",
"{",
"return",
"(",
"(",
"LocalTime",
")",
"input",
")",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"OffsetTime",
")",
"{",
"return",
"(",
"(",
"OffsetTime",
")",
"input",
")",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"else",
"if",
"(",
"input",
"instanceof",
"DurationValue",
")",
"{",
"return",
"formatDuration",
"(",
"input",
",",
"format",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Available formats are:\\n\"",
"+",
"String",
".",
"join",
"(",
"\"\\n\"",
",",
"getTypes",
"(",
")",
")",
"+",
"\"\\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats \"",
"+",
"\"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html\"",
")",
";",
"}",
"return",
"input",
".",
"toString",
"(",
")",
";",
"}"
] | Format a temporal value to a String
@param input Any temporal type
@param format A valid DateTime format pattern (ie yyyy-MM-dd'T'HH:mm:ss.SSSS)
@return | [
"Format",
"a",
"temporal",
"value",
"to",
"a",
"String"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/temporal/TemporalProcedures.java#L22-L52 |
23,764 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/temporal/TemporalProcedures.java | TemporalProcedures.formatDuration | @UserFunction( "apoc.temporal.formatDuration" )
@Description( "apoc.temporal.formatDuration(input, format) | Format a Duration" )
public String formatDuration(
@Name("input") Object input,
@Name("format") String format
) {
try {
LocalDateTime midnight = LocalDateTime.of(0, 1, 1, 0, 0, 0, 0);
LocalDateTime newDuration = midnight.plus( (DurationValue) input );
DateTimeFormatter formatter = getOrCreate(format);
return newDuration.format(formatter);
} catch (Exception e){
throw new RuntimeException("Available formats are:\n" +
String.join("\n", getTypes()) +
"\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats " +
"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
}
} | java | @UserFunction( "apoc.temporal.formatDuration" )
@Description( "apoc.temporal.formatDuration(input, format) | Format a Duration" )
public String formatDuration(
@Name("input") Object input,
@Name("format") String format
) {
try {
LocalDateTime midnight = LocalDateTime.of(0, 1, 1, 0, 0, 0, 0);
LocalDateTime newDuration = midnight.plus( (DurationValue) input );
DateTimeFormatter formatter = getOrCreate(format);
return newDuration.format(formatter);
} catch (Exception e){
throw new RuntimeException("Available formats are:\n" +
String.join("\n", getTypes()) +
"\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats " +
"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html");
}
} | [
"@",
"UserFunction",
"(",
"\"apoc.temporal.formatDuration\"",
")",
"@",
"Description",
"(",
"\"apoc.temporal.formatDuration(input, format) | Format a Duration\"",
")",
"public",
"String",
"formatDuration",
"(",
"@",
"Name",
"(",
"\"input\"",
")",
"Object",
"input",
",",
"@",
"Name",
"(",
"\"format\"",
")",
"String",
"format",
")",
"{",
"try",
"{",
"LocalDateTime",
"midnight",
"=",
"LocalDateTime",
".",
"of",
"(",
"0",
",",
"1",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"LocalDateTime",
"newDuration",
"=",
"midnight",
".",
"plus",
"(",
"(",
"DurationValue",
")",
"input",
")",
";",
"DateTimeFormatter",
"formatter",
"=",
"getOrCreate",
"(",
"format",
")",
";",
"return",
"newDuration",
".",
"format",
"(",
"formatter",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Available formats are:\\n\"",
"+",
"String",
".",
"join",
"(",
"\"\\n\"",
",",
"getTypes",
"(",
")",
")",
"+",
"\"\\nSee also: https://www.elastic.co/guide/en/elasticsearch/reference/5.5/mapping-date-format.html#built-in-date-formats \"",
"+",
"\"and https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html\"",
")",
";",
"}",
"}"
] | Convert a Duration into a LocalTime and format the value as a String
@param input
@param format
@return | [
"Convert",
"a",
"Duration",
"into",
"a",
"LocalTime",
"and",
"format",
"the",
"value",
"as",
"a",
"String"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/temporal/TemporalProcedures.java#L61-L80 |
23,765 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/couchbase/CouchbaseConnection.java | CouchbaseConnection.getMajorVersion | protected int getMajorVersion() {
return this.cluster.authenticate(this.passwordAuthenticator).clusterManager().info(5,TimeUnit.SECONDS).getMinVersion().major();
} | java | protected int getMajorVersion() {
return this.cluster.authenticate(this.passwordAuthenticator).clusterManager().info(5,TimeUnit.SECONDS).getMinVersion().major();
} | [
"protected",
"int",
"getMajorVersion",
"(",
")",
"{",
"return",
"this",
".",
"cluster",
".",
"authenticate",
"(",
"this",
".",
"passwordAuthenticator",
")",
".",
"clusterManager",
"(",
")",
".",
"info",
"(",
"5",
",",
"TimeUnit",
".",
"SECONDS",
")",
".",
"getMinVersion",
"(",
")",
".",
"major",
"(",
")",
";",
"}"
] | Get the major version of Couchbase server, that is 4.x or 5.x
@return | [
"Get",
"the",
"major",
"version",
"of",
"Couchbase",
"server",
"that",
"is",
"4",
".",
"x",
"or",
"5",
".",
"x"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/couchbase/CouchbaseConnection.java#L88-L90 |
23,766 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/couchbase/CouchbaseConnection.java | CouchbaseConnection.executeStatement | public List<JsonObject> executeStatement(String statement) {
SimpleN1qlQuery query = N1qlQuery.simple(statement);
return executeQuery(query);
} | java | public List<JsonObject> executeStatement(String statement) {
SimpleN1qlQuery query = N1qlQuery.simple(statement);
return executeQuery(query);
} | [
"public",
"List",
"<",
"JsonObject",
">",
"executeStatement",
"(",
"String",
"statement",
")",
"{",
"SimpleN1qlQuery",
"query",
"=",
"N1qlQuery",
".",
"simple",
"(",
"statement",
")",
";",
"return",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Executes a plain un-parameterized N1QL kernelTransaction.
@param statement the raw kernelTransaction string to execute
@return the list of {@link JsonObject}s retrieved by this query
@see N1qlQuery#simple(Statement) | [
"Executes",
"a",
"plain",
"un",
"-",
"parameterized",
"N1QL",
"kernelTransaction",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/couchbase/CouchbaseConnection.java#L208-L211 |
23,767 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/couchbase/CouchbaseConnection.java | CouchbaseConnection.executeParametrizedStatement | public List<JsonObject> executeParametrizedStatement(String statement, List<Object> parameters) {
JsonArray positionalParams = JsonArray.from(parameters);
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, positionalParams);
return executeQuery(query);
} | java | public List<JsonObject> executeParametrizedStatement(String statement, List<Object> parameters) {
JsonArray positionalParams = JsonArray.from(parameters);
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, positionalParams);
return executeQuery(query);
} | [
"public",
"List",
"<",
"JsonObject",
">",
"executeParametrizedStatement",
"(",
"String",
"statement",
",",
"List",
"<",
"Object",
">",
"parameters",
")",
"{",
"JsonArray",
"positionalParams",
"=",
"JsonArray",
".",
"from",
"(",
"parameters",
")",
";",
"ParameterizedN1qlQuery",
"query",
"=",
"N1qlQuery",
".",
"parameterized",
"(",
"statement",
",",
"positionalParams",
")",
";",
"return",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Executes a N1QL kernelTransaction with positional parameters.
@param statement the raw kernelTransaction string to execute (containing positional
placeholders: $1, $2, ...)
@param parameters the values for the positional placeholders in kernelTransaction
@return the list of {@link JsonObject}s retrieved by this query
@see N1qlQuery#parameterized(Statement, JsonArray) | [
"Executes",
"a",
"N1QL",
"kernelTransaction",
"with",
"positional",
"parameters",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/couchbase/CouchbaseConnection.java#L222-L226 |
23,768 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/couchbase/CouchbaseConnection.java | CouchbaseConnection.executeParametrizedStatement | public List<JsonObject> executeParametrizedStatement(String statement, List<String> parameterNames,
List<Object> parameterValues) {
JsonObject namedParams = JsonObject.create();
for (int param = 0; param < parameterNames.size(); param++) {
namedParams.put(parameterNames.get(param), parameterValues.get(param));
}
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, namedParams);
return executeQuery(query);
} | java | public List<JsonObject> executeParametrizedStatement(String statement, List<String> parameterNames,
List<Object> parameterValues) {
JsonObject namedParams = JsonObject.create();
for (int param = 0; param < parameterNames.size(); param++) {
namedParams.put(parameterNames.get(param), parameterValues.get(param));
}
ParameterizedN1qlQuery query = N1qlQuery.parameterized(statement, namedParams);
return executeQuery(query);
} | [
"public",
"List",
"<",
"JsonObject",
">",
"executeParametrizedStatement",
"(",
"String",
"statement",
",",
"List",
"<",
"String",
">",
"parameterNames",
",",
"List",
"<",
"Object",
">",
"parameterValues",
")",
"{",
"JsonObject",
"namedParams",
"=",
"JsonObject",
".",
"create",
"(",
")",
";",
"for",
"(",
"int",
"param",
"=",
"0",
";",
"param",
"<",
"parameterNames",
".",
"size",
"(",
")",
";",
"param",
"++",
")",
"{",
"namedParams",
".",
"put",
"(",
"parameterNames",
".",
"get",
"(",
"param",
")",
",",
"parameterValues",
".",
"get",
"(",
"param",
")",
")",
";",
"}",
"ParameterizedN1qlQuery",
"query",
"=",
"N1qlQuery",
".",
"parameterized",
"(",
"statement",
",",
"namedParams",
")",
";",
"return",
"executeQuery",
"(",
"query",
")",
";",
"}"
] | Executes a N1QL kernelTransaction with named parameters.
@param statement the raw kernelTransaction string to execute (containing named
placeholders: $param1, $param2, ...)
@param parameterNames the placeholders' names in kernelTransaction
@param parameterValues the values for the named placeholders in kernelTransaction
@return the list of {@link JsonObject}s retrieved by this query
@see N1qlQuery#parameterized(Statement, JsonObject) | [
"Executes",
"a",
"N1QL",
"kernelTransaction",
"with",
"named",
"parameters",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/couchbase/CouchbaseConnection.java#L238-L246 |
23,769 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/generate/relationship/ErdosRenyiRelationshipGenerator.java | ErdosRenyiRelationshipGenerator.doGenerateEdgesWithOmitList | private List<Pair<Integer, Integer>> doGenerateEdgesWithOmitList() {
final int numberOfNodes = getConfiguration().getNumberOfNodes();
final int numberOfEdges = getConfiguration().getNumberOfEdges();
final long maxEdges = numberOfNodes * (numberOfNodes - 1) / 2;
final List<Pair<Integer, Integer>> edges = new LinkedList<>();
for (Long index : edgeIndices(numberOfEdges, maxEdges)) {
edges.add(indexToEdgeBijection(index));
}
return edges;
} | java | private List<Pair<Integer, Integer>> doGenerateEdgesWithOmitList() {
final int numberOfNodes = getConfiguration().getNumberOfNodes();
final int numberOfEdges = getConfiguration().getNumberOfEdges();
final long maxEdges = numberOfNodes * (numberOfNodes - 1) / 2;
final List<Pair<Integer, Integer>> edges = new LinkedList<>();
for (Long index : edgeIndices(numberOfEdges, maxEdges)) {
edges.add(indexToEdgeBijection(index));
}
return edges;
} | [
"private",
"List",
"<",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
">",
"doGenerateEdgesWithOmitList",
"(",
")",
"{",
"final",
"int",
"numberOfNodes",
"=",
"getConfiguration",
"(",
")",
".",
"getNumberOfNodes",
"(",
")",
";",
"final",
"int",
"numberOfEdges",
"=",
"getConfiguration",
"(",
")",
".",
"getNumberOfEdges",
"(",
")",
";",
"final",
"long",
"maxEdges",
"=",
"numberOfNodes",
"*",
"(",
"numberOfNodes",
"-",
"1",
")",
"/",
"2",
";",
"final",
"List",
"<",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
">",
"edges",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"Long",
"index",
":",
"edgeIndices",
"(",
"numberOfEdges",
",",
"maxEdges",
")",
")",
"{",
"edges",
".",
"add",
"(",
"indexToEdgeBijection",
"(",
"index",
")",
")",
";",
"}",
"return",
"edges",
";",
"}"
] | Improved implementation of Erdos-Renyi generator based on bijection from
edge labels to edge realisations. Works very well for large number of nodes,
but is slow with increasing number of edges. Best for denser networks, with
a clear giant component.
@return edge list | [
"Improved",
"implementation",
"of",
"Erdos",
"-",
"Renyi",
"generator",
"based",
"on",
"bijection",
"from",
"edge",
"labels",
"to",
"edge",
"realisations",
".",
"Works",
"very",
"well",
"for",
"large",
"number",
"of",
"nodes",
"but",
"is",
"slow",
"with",
"increasing",
"number",
"of",
"edges",
".",
"Best",
"for",
"denser",
"networks",
"with",
"a",
"clear",
"giant",
"component",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/generate/relationship/ErdosRenyiRelationshipGenerator.java#L87-L99 |
23,770 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/generate/relationship/ErdosRenyiRelationshipGenerator.java | ErdosRenyiRelationshipGenerator.indexToEdgeBijection | private Pair<Integer, Integer> indexToEdgeBijection(long index) {
long i = (long) Math.ceil((Math.sqrt(1 + 8 * (index + 1)) - 1) / 2);
long diff = index + 1 - (i * (i - 1)) / 2;
return Pair.of((int) i, (int) diff - 1);
} | java | private Pair<Integer, Integer> indexToEdgeBijection(long index) {
long i = (long) Math.ceil((Math.sqrt(1 + 8 * (index + 1)) - 1) / 2);
long diff = index + 1 - (i * (i - 1)) / 2;
return Pair.of((int) i, (int) diff - 1);
} | [
"private",
"Pair",
"<",
"Integer",
",",
"Integer",
">",
"indexToEdgeBijection",
"(",
"long",
"index",
")",
"{",
"long",
"i",
"=",
"(",
"long",
")",
"Math",
".",
"ceil",
"(",
"(",
"Math",
".",
"sqrt",
"(",
"1",
"+",
"8",
"*",
"(",
"index",
"+",
"1",
")",
")",
"-",
"1",
")",
"/",
"2",
")",
";",
"long",
"diff",
"=",
"index",
"+",
"1",
"-",
"(",
"i",
"*",
"(",
"i",
"-",
"1",
")",
")",
"/",
"2",
";",
"return",
"Pair",
".",
"of",
"(",
"(",
"int",
")",
"i",
",",
"(",
"int",
")",
"diff",
"-",
"1",
")",
";",
"}"
] | Maps an index in a hypothetical list of all edges to the actual edge.
@param index index
@return an edge based on its unique label | [
"Maps",
"an",
"index",
"in",
"a",
"hypothetical",
"list",
"of",
"all",
"edges",
"to",
"the",
"actual",
"edge",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/generate/relationship/ErdosRenyiRelationshipGenerator.java#L107-L112 |
23,771 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/util/Util.java | Util.transactionIsTerminated | public static boolean transactionIsTerminated(TerminationGuard db) {
try {
db.check();
return false;
} catch (TransactionGuardException | TransactionTerminatedException | NotInTransactionException tge) {
return true;
}
} | java | public static boolean transactionIsTerminated(TerminationGuard db) {
try {
db.check();
return false;
} catch (TransactionGuardException | TransactionTerminatedException | NotInTransactionException tge) {
return true;
}
} | [
"public",
"static",
"boolean",
"transactionIsTerminated",
"(",
"TerminationGuard",
"db",
")",
"{",
"try",
"{",
"db",
".",
"check",
"(",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"TransactionGuardException",
"|",
"TransactionTerminatedException",
"|",
"NotInTransactionException",
"tge",
")",
"{",
"return",
"true",
";",
"}",
"}"
] | Given a context related to the procedure invocation this method checks if the transaction is terminated in some way
@param db
@return | [
"Given",
"a",
"context",
"related",
"to",
"the",
"procedure",
"invocation",
"this",
"method",
"checks",
"if",
"the",
"transaction",
"is",
"terminated",
"in",
"some",
"way"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/util/Util.java#L635-L642 |
23,772 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/load/Xml.java | Xml.handleTypeAndAttributes | private void handleTypeAndAttributes(Node node, Map<String, Object> elementMap) {
// Set type
if (node.getLocalName() != null) {
elementMap.put("_type", node.getLocalName());
}
// Set the attributes
if (node.getAttributes() != null) {
NamedNodeMap attributeMap = node.getAttributes();
for (int i = 0; i < attributeMap.getLength(); i++) {
Node attribute = attributeMap.item(i);
elementMap.put(attribute.getNodeName(), attribute.getNodeValue());
}
}
} | java | private void handleTypeAndAttributes(Node node, Map<String, Object> elementMap) {
// Set type
if (node.getLocalName() != null) {
elementMap.put("_type", node.getLocalName());
}
// Set the attributes
if (node.getAttributes() != null) {
NamedNodeMap attributeMap = node.getAttributes();
for (int i = 0; i < attributeMap.getLength(); i++) {
Node attribute = attributeMap.item(i);
elementMap.put(attribute.getNodeName(), attribute.getNodeValue());
}
}
} | [
"private",
"void",
"handleTypeAndAttributes",
"(",
"Node",
"node",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"elementMap",
")",
"{",
"// Set type",
"if",
"(",
"node",
".",
"getLocalName",
"(",
")",
"!=",
"null",
")",
"{",
"elementMap",
".",
"put",
"(",
"\"_type\"",
",",
"node",
".",
"getLocalName",
"(",
")",
")",
";",
"}",
"// Set the attributes",
"if",
"(",
"node",
".",
"getAttributes",
"(",
")",
"!=",
"null",
")",
"{",
"NamedNodeMap",
"attributeMap",
"=",
"node",
".",
"getAttributes",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"attributeMap",
".",
"getLength",
"(",
")",
";",
"i",
"++",
")",
"{",
"Node",
"attribute",
"=",
"attributeMap",
".",
"item",
"(",
"i",
")",
";",
"elementMap",
".",
"put",
"(",
"attribute",
".",
"getNodeName",
"(",
")",
",",
"attribute",
".",
"getNodeValue",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Collects type and attributes for the node
@param node
@param elementMap | [
"Collects",
"type",
"and",
"attributes",
"for",
"the",
"node"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/load/Xml.java#L267-L281 |
23,773 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/load/Xml.java | Xml.handleTextNode | private void handleTextNode(Node node, Map<String, Object> elementMap) {
Object text = "";
int nodeType = node.getNodeType();
switch (nodeType) {
case Node.TEXT_NODE:
text = normalizeText(node.getNodeValue());
break;
case Node.CDATA_SECTION_NODE:
text = normalizeText(((CharacterData) node).getData());
break;
default:
break;
}
// If the text is valid ...
if (!StringUtils.isEmpty(text.toString())) {
// We check if we have already collected some text previously
Object previousText = elementMap.get("_text");
if (previousText != null) {
// If we just have a "_text" key than we need to collect to a List
text = Arrays.asList(previousText.toString(), text);
}
elementMap.put("_text", text);
}
} | java | private void handleTextNode(Node node, Map<String, Object> elementMap) {
Object text = "";
int nodeType = node.getNodeType();
switch (nodeType) {
case Node.TEXT_NODE:
text = normalizeText(node.getNodeValue());
break;
case Node.CDATA_SECTION_NODE:
text = normalizeText(((CharacterData) node).getData());
break;
default:
break;
}
// If the text is valid ...
if (!StringUtils.isEmpty(text.toString())) {
// We check if we have already collected some text previously
Object previousText = elementMap.get("_text");
if (previousText != null) {
// If we just have a "_text" key than we need to collect to a List
text = Arrays.asList(previousText.toString(), text);
}
elementMap.put("_text", text);
}
} | [
"private",
"void",
"handleTextNode",
"(",
"Node",
"node",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"elementMap",
")",
"{",
"Object",
"text",
"=",
"\"\"",
";",
"int",
"nodeType",
"=",
"node",
".",
"getNodeType",
"(",
")",
";",
"switch",
"(",
"nodeType",
")",
"{",
"case",
"Node",
".",
"TEXT_NODE",
":",
"text",
"=",
"normalizeText",
"(",
"node",
".",
"getNodeValue",
"(",
")",
")",
";",
"break",
";",
"case",
"Node",
".",
"CDATA_SECTION_NODE",
":",
"text",
"=",
"normalizeText",
"(",
"(",
"(",
"CharacterData",
")",
"node",
")",
".",
"getData",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"// If the text is valid ...",
"if",
"(",
"!",
"StringUtils",
".",
"isEmpty",
"(",
"text",
".",
"toString",
"(",
")",
")",
")",
"{",
"// We check if we have already collected some text previously",
"Object",
"previousText",
"=",
"elementMap",
".",
"get",
"(",
"\"_text\"",
")",
";",
"if",
"(",
"previousText",
"!=",
"null",
")",
"{",
"// If we just have a \"_text\" key than we need to collect to a List",
"text",
"=",
"Arrays",
".",
"asList",
"(",
"previousText",
".",
"toString",
"(",
")",
",",
"text",
")",
";",
"}",
"elementMap",
".",
"put",
"(",
"\"_text\"",
",",
"text",
")",
";",
"}",
"}"
] | Handle TEXT nodes and CDATA nodes
@param node
@param elementMap | [
"Handle",
"TEXT",
"nodes",
"and",
"CDATA",
"nodes"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/load/Xml.java#L289-L313 |
23,774 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/load/Xml.java | Xml.normalizeText | private String normalizeText(String text) {
String[] tokens = StringUtils.split(text, "\n");
for (int i = 0; i < tokens.length; i++) {
tokens[i] = tokens[i].trim();
}
return StringUtils.join(tokens, " ").trim();
} | java | private String normalizeText(String text) {
String[] tokens = StringUtils.split(text, "\n");
for (int i = 0; i < tokens.length; i++) {
tokens[i] = tokens[i].trim();
}
return StringUtils.join(tokens, " ").trim();
} | [
"private",
"String",
"normalizeText",
"(",
"String",
"text",
")",
"{",
"String",
"[",
"]",
"tokens",
"=",
"StringUtils",
".",
"split",
"(",
"text",
",",
"\"\\n\"",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"tokens",
".",
"length",
";",
"i",
"++",
")",
"{",
"tokens",
"[",
"i",
"]",
"=",
"tokens",
"[",
"i",
"]",
".",
"trim",
"(",
")",
";",
"}",
"return",
"StringUtils",
".",
"join",
"(",
"tokens",
",",
"\" \"",
")",
".",
"trim",
"(",
")",
";",
"}"
] | Remove trailing whitespaces and new line characters
@param text
@return | [
"Remove",
"trailing",
"whitespaces",
"and",
"new",
"line",
"characters"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/load/Xml.java#L321-L328 |
23,775 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/export/csv/CsvHeaderFields.java | CsvHeaderFields.processHeader | public static List<CsvHeaderField> processHeader(final String header, final char delimiter, final char quotationCharacter) {
final String separatorRegex = Pattern.quote(String.valueOf(delimiter));
final List<String> attributes = Arrays.asList(header.split(separatorRegex));
final List<CsvHeaderField> fieldEntries =
IntStream.range(0, attributes.size())
.mapToObj(i -> CsvHeaderField.parse(i, attributes.get(i), quotationCharacter))
.collect(Collectors.toList());
return fieldEntries;
} | java | public static List<CsvHeaderField> processHeader(final String header, final char delimiter, final char quotationCharacter) {
final String separatorRegex = Pattern.quote(String.valueOf(delimiter));
final List<String> attributes = Arrays.asList(header.split(separatorRegex));
final List<CsvHeaderField> fieldEntries =
IntStream.range(0, attributes.size())
.mapToObj(i -> CsvHeaderField.parse(i, attributes.get(i), quotationCharacter))
.collect(Collectors.toList());
return fieldEntries;
} | [
"public",
"static",
"List",
"<",
"CsvHeaderField",
">",
"processHeader",
"(",
"final",
"String",
"header",
",",
"final",
"char",
"delimiter",
",",
"final",
"char",
"quotationCharacter",
")",
"{",
"final",
"String",
"separatorRegex",
"=",
"Pattern",
".",
"quote",
"(",
"String",
".",
"valueOf",
"(",
"delimiter",
")",
")",
";",
"final",
"List",
"<",
"String",
">",
"attributes",
"=",
"Arrays",
".",
"asList",
"(",
"header",
".",
"split",
"(",
"separatorRegex",
")",
")",
";",
"final",
"List",
"<",
"CsvHeaderField",
">",
"fieldEntries",
"=",
"IntStream",
".",
"range",
"(",
"0",
",",
"attributes",
".",
"size",
"(",
")",
")",
".",
"mapToObj",
"(",
"i",
"->",
"CsvHeaderField",
".",
"parse",
"(",
"i",
",",
"attributes",
".",
"get",
"(",
"i",
")",
",",
"quotationCharacter",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"return",
"fieldEntries",
";",
"}"
] | Processes CSV header. Works for both nodes and relationships.
@param header
@param delimiter
@param quotationCharacter
@return | [
"Processes",
"CSV",
"header",
".",
"Works",
"for",
"both",
"nodes",
"and",
"relationships",
"."
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/export/csv/CsvHeaderFields.java#L19-L29 |
23,776 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/path/NodeEvaluators.java | NodeEvaluators.endAndTerminatorNodeEvaluator | public static Evaluator endAndTerminatorNodeEvaluator(List<Node> endNodes, List<Node> terminatorNodes) {
Evaluator endNodeEvaluator = null;
Evaluator terminatorNodeEvaluator = null;
if (!endNodes.isEmpty()) {
Node[] nodes = endNodes.toArray(new Node[endNodes.size()]);
endNodeEvaluator = Evaluators.includeWhereEndNodeIs(nodes);
}
if (!terminatorNodes.isEmpty()) {
Node[] nodes = terminatorNodes.toArray(new Node[terminatorNodes.size()]);
terminatorNodeEvaluator = Evaluators.pruneWhereEndNodeIs(nodes);
}
if (endNodeEvaluator != null || terminatorNodeEvaluator != null) {
return new EndAndTerminatorNodeEvaluator(endNodeEvaluator, terminatorNodeEvaluator);
}
return null;
} | java | public static Evaluator endAndTerminatorNodeEvaluator(List<Node> endNodes, List<Node> terminatorNodes) {
Evaluator endNodeEvaluator = null;
Evaluator terminatorNodeEvaluator = null;
if (!endNodes.isEmpty()) {
Node[] nodes = endNodes.toArray(new Node[endNodes.size()]);
endNodeEvaluator = Evaluators.includeWhereEndNodeIs(nodes);
}
if (!terminatorNodes.isEmpty()) {
Node[] nodes = terminatorNodes.toArray(new Node[terminatorNodes.size()]);
terminatorNodeEvaluator = Evaluators.pruneWhereEndNodeIs(nodes);
}
if (endNodeEvaluator != null || terminatorNodeEvaluator != null) {
return new EndAndTerminatorNodeEvaluator(endNodeEvaluator, terminatorNodeEvaluator);
}
return null;
} | [
"public",
"static",
"Evaluator",
"endAndTerminatorNodeEvaluator",
"(",
"List",
"<",
"Node",
">",
"endNodes",
",",
"List",
"<",
"Node",
">",
"terminatorNodes",
")",
"{",
"Evaluator",
"endNodeEvaluator",
"=",
"null",
";",
"Evaluator",
"terminatorNodeEvaluator",
"=",
"null",
";",
"if",
"(",
"!",
"endNodes",
".",
"isEmpty",
"(",
")",
")",
"{",
"Node",
"[",
"]",
"nodes",
"=",
"endNodes",
".",
"toArray",
"(",
"new",
"Node",
"[",
"endNodes",
".",
"size",
"(",
")",
"]",
")",
";",
"endNodeEvaluator",
"=",
"Evaluators",
".",
"includeWhereEndNodeIs",
"(",
"nodes",
")",
";",
"}",
"if",
"(",
"!",
"terminatorNodes",
".",
"isEmpty",
"(",
")",
")",
"{",
"Node",
"[",
"]",
"nodes",
"=",
"terminatorNodes",
".",
"toArray",
"(",
"new",
"Node",
"[",
"terminatorNodes",
".",
"size",
"(",
")",
"]",
")",
";",
"terminatorNodeEvaluator",
"=",
"Evaluators",
".",
"pruneWhereEndNodeIs",
"(",
"nodes",
")",
";",
"}",
"if",
"(",
"endNodeEvaluator",
"!=",
"null",
"||",
"terminatorNodeEvaluator",
"!=",
"null",
")",
"{",
"return",
"new",
"EndAndTerminatorNodeEvaluator",
"(",
"endNodeEvaluator",
",",
"terminatorNodeEvaluator",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns an evaluator which handles end nodes and terminator nodes
Returns null if both lists are empty | [
"Returns",
"an",
"evaluator",
"which",
"handles",
"end",
"nodes",
"and",
"terminator",
"nodes",
"Returns",
"null",
"if",
"both",
"lists",
"are",
"empty"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/path/NodeEvaluators.java#L24-L43 |
23,777 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/CoreGraphAlgorithms.java | CoreGraphAlgorithms.interleaveBits | private static int interleaveBits(int odd, int even) {
int val = 0;
// Replaced this line with the improved code provided by Tuska
// int n = Math.max(Integer.highestOneBit(odd), Integer.highestOneBit(even));
int max = Math.max(odd, even);
int n = 0;
while (max > 0) {
n++;
max >>= 1;
}
for (int i = 0; i < n; i++) {
int bitMask = 1 << i;
int a = (even & bitMask) > 0 ? (1 << (2 * i)) : 0;
int b = (odd & bitMask) > 0 ? (1 << (2 * i + 1)) : 0;
val += a + b;
}
return val;
} | java | private static int interleaveBits(int odd, int even) {
int val = 0;
// Replaced this line with the improved code provided by Tuska
// int n = Math.max(Integer.highestOneBit(odd), Integer.highestOneBit(even));
int max = Math.max(odd, even);
int n = 0;
while (max > 0) {
n++;
max >>= 1;
}
for (int i = 0; i < n; i++) {
int bitMask = 1 << i;
int a = (even & bitMask) > 0 ? (1 << (2 * i)) : 0;
int b = (odd & bitMask) > 0 ? (1 << (2 * i + 1)) : 0;
val += a + b;
}
return val;
} | [
"private",
"static",
"int",
"interleaveBits",
"(",
"int",
"odd",
",",
"int",
"even",
")",
"{",
"int",
"val",
"=",
"0",
";",
"// Replaced this line with the improved code provided by Tuska",
"// int n = Math.max(Integer.highestOneBit(odd), Integer.highestOneBit(even));",
"int",
"max",
"=",
"Math",
".",
"max",
"(",
"odd",
",",
"even",
")",
";",
"int",
"n",
"=",
"0",
";",
"while",
"(",
"max",
">",
"0",
")",
"{",
"n",
"++",
";",
"max",
">>=",
"1",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"n",
";",
"i",
"++",
")",
"{",
"int",
"bitMask",
"=",
"1",
"<<",
"i",
";",
"int",
"a",
"=",
"(",
"even",
"&",
"bitMask",
")",
">",
"0",
"?",
"(",
"1",
"<<",
"(",
"2",
"*",
"i",
")",
")",
":",
"0",
";",
"int",
"b",
"=",
"(",
"odd",
"&",
"bitMask",
")",
">",
"0",
"?",
"(",
"1",
"<<",
"(",
"2",
"*",
"i",
"+",
"1",
")",
")",
":",
"0",
";",
"val",
"+=",
"a",
"+",
"b",
";",
"}",
"return",
"val",
";",
"}"
] | Interleave the bits from two input integer values
@param odd integer holding bit values for odd bit positions
@param even integer holding bit values for even bit positions
@return the integer that results from interleaving the input bits
@todo: I'm sure there's a more elegant way of doing this ! | [
"Interleave",
"the",
"bits",
"from",
"two",
"input",
"integer",
"values"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/CoreGraphAlgorithms.java#L90-L109 |
23,778 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/CoreGraphAlgorithms.java | CoreGraphAlgorithms.init | public CoreGraphAlgorithms init(String label, String rel) {
TokenRead token = ktx.tokenRead();
int labelId = token.nodeLabel(label);
int relTypeId = token.relationshipType(rel);
loadNodes(labelId, relTypeId);
loadRels(labelId, relTypeId);
return this;
} | java | public CoreGraphAlgorithms init(String label, String rel) {
TokenRead token = ktx.tokenRead();
int labelId = token.nodeLabel(label);
int relTypeId = token.relationshipType(rel);
loadNodes(labelId, relTypeId);
loadRels(labelId, relTypeId);
return this;
} | [
"public",
"CoreGraphAlgorithms",
"init",
"(",
"String",
"label",
",",
"String",
"rel",
")",
"{",
"TokenRead",
"token",
"=",
"ktx",
".",
"tokenRead",
"(",
")",
";",
"int",
"labelId",
"=",
"token",
".",
"nodeLabel",
"(",
"label",
")",
";",
"int",
"relTypeId",
"=",
"token",
".",
"relationshipType",
"(",
"rel",
")",
";",
"loadNodes",
"(",
"labelId",
",",
"relTypeId",
")",
";",
"loadRels",
"(",
"labelId",
",",
"relTypeId",
")",
";",
"return",
"this",
";",
"}"
] | keep threads with open worker-tx for reads | [
"keep",
"threads",
"with",
"open",
"worker",
"-",
"tx",
"for",
"reads"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/CoreGraphAlgorithms.java#L541-L548 |
23,779 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.withDefault | public Chunks withDefault(int defaultValue) {
this.defaultValue = defaultValue;
if (defaultValue != 0) {
for (int[] chunk : chunks) {
Arrays.fill(chunk, defaultValue);
}
}
return this;
} | java | public Chunks withDefault(int defaultValue) {
this.defaultValue = defaultValue;
if (defaultValue != 0) {
for (int[] chunk : chunks) {
Arrays.fill(chunk, defaultValue);
}
}
return this;
} | [
"public",
"Chunks",
"withDefault",
"(",
"int",
"defaultValue",
")",
"{",
"this",
".",
"defaultValue",
"=",
"defaultValue",
";",
"if",
"(",
"defaultValue",
"!=",
"0",
")",
"{",
"for",
"(",
"int",
"[",
"]",
"chunk",
":",
"chunks",
")",
"{",
"Arrays",
".",
"fill",
"(",
"chunk",
",",
"defaultValue",
")",
";",
"}",
"}",
"return",
"this",
";",
"}"
] | call directly after construction, todo move to constructor or static factory | [
"call",
"directly",
"after",
"construction",
"todo",
"move",
"to",
"constructor",
"or",
"static",
"factory"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L48-L56 |
23,780 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.set | void set(int index, int value) {
int chunk = assertSpace(index);
chunks[chunk][index & mask] = value;
} | java | void set(int index, int value) {
int chunk = assertSpace(index);
chunks[chunk][index & mask] = value;
} | [
"void",
"set",
"(",
"int",
"index",
",",
"int",
"value",
")",
"{",
"int",
"chunk",
"=",
"assertSpace",
"(",
"index",
")",
";",
"chunks",
"[",
"chunk",
"]",
"[",
"index",
"&",
"mask",
"]",
"=",
"value",
";",
"}"
] | Sets a value an grows chunks dynamically if exceeding size or missing chunk encountered | [
"Sets",
"a",
"value",
"an",
"grows",
"chunks",
"dynamically",
"if",
"exceeding",
"size",
"or",
"missing",
"chunk",
"encountered"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L61-L64 |
23,781 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.newChunk | private int[] newChunk() {
if (defaultValue==0) return new int[chunkSize];
if (baseChunk==null) {
baseChunk = new int[chunkSize];
Arrays.fill(baseChunk,defaultValue);
}
return baseChunk.clone();
} | java | private int[] newChunk() {
if (defaultValue==0) return new int[chunkSize];
if (baseChunk==null) {
baseChunk = new int[chunkSize];
Arrays.fill(baseChunk,defaultValue);
}
return baseChunk.clone();
} | [
"private",
"int",
"[",
"]",
"newChunk",
"(",
")",
"{",
"if",
"(",
"defaultValue",
"==",
"0",
")",
"return",
"new",
"int",
"[",
"chunkSize",
"]",
";",
"if",
"(",
"baseChunk",
"==",
"null",
")",
"{",
"baseChunk",
"=",
"new",
"int",
"[",
"chunkSize",
"]",
";",
"Arrays",
".",
"fill",
"(",
"baseChunk",
",",
"defaultValue",
")",
";",
"}",
"return",
"baseChunk",
".",
"clone",
"(",
")",
";",
"}"
] | todo use pool | [
"todo",
"use",
"pool"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L122-L130 |
23,782 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.sumUp | public void sumUp() {
int offset=0;
int tmp=0;
for (int i = 0; i < numChunks; i++) {
int[] chunk = chunks[i];
if (chunk==null) throw new IllegalStateException("Chunks are not continous, null fragement at offset "+i);
for (int j = 0; j < chunkSize; j++) {
tmp = chunk[j];
chunk[j] = offset;
offset += tmp;
}
}
} | java | public void sumUp() {
int offset=0;
int tmp=0;
for (int i = 0; i < numChunks; i++) {
int[] chunk = chunks[i];
if (chunk==null) throw new IllegalStateException("Chunks are not continous, null fragement at offset "+i);
for (int j = 0; j < chunkSize; j++) {
tmp = chunk[j];
chunk[j] = offset;
offset += tmp;
}
}
} | [
"public",
"void",
"sumUp",
"(",
")",
"{",
"int",
"offset",
"=",
"0",
";",
"int",
"tmp",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"numChunks",
";",
"i",
"++",
")",
"{",
"int",
"[",
"]",
"chunk",
"=",
"chunks",
"[",
"i",
"]",
";",
"if",
"(",
"chunk",
"==",
"null",
")",
"throw",
"new",
"IllegalStateException",
"(",
"\"Chunks are not continous, null fragement at offset \"",
"+",
"i",
")",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"chunkSize",
";",
"j",
"++",
")",
"{",
"tmp",
"=",
"chunk",
"[",
"j",
"]",
";",
"chunk",
"[",
"j",
"]",
"=",
"offset",
";",
"offset",
"+=",
"tmp",
";",
"}",
"}",
"}"
] | special operation implemented inline to compute and store sum up until here | [
"special",
"operation",
"implemented",
"inline",
"to",
"compute",
"and",
"store",
"sum",
"up",
"until",
"here"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L135-L147 |
23,783 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.add | public void add(Chunks c) {
assert c.chunkBits == chunkBits;
assert c.defaultValue == defaultValue;
int[][] oChunks = c.chunks;
if (c.numChunks > numChunks) growTo(c.numChunks-1);
for (int i = 0; i < oChunks.length; i++) {
int[] oChunk = oChunks[i];
if (oChunk!=null) {
if (chunks[i]==null) {
chunks[i]=oChunk.clone();
} else {
int[] chunk = chunks[i];
for (int j = 0; j < oChunk.length; j++) {
chunk[j] += oChunk[j];
}
}
}
}
this.maxIndex = Math.max(this.maxIndex,c.maxIndex);
} | java | public void add(Chunks c) {
assert c.chunkBits == chunkBits;
assert c.defaultValue == defaultValue;
int[][] oChunks = c.chunks;
if (c.numChunks > numChunks) growTo(c.numChunks-1);
for (int i = 0; i < oChunks.length; i++) {
int[] oChunk = oChunks[i];
if (oChunk!=null) {
if (chunks[i]==null) {
chunks[i]=oChunk.clone();
} else {
int[] chunk = chunks[i];
for (int j = 0; j < oChunk.length; j++) {
chunk[j] += oChunk[j];
}
}
}
}
this.maxIndex = Math.max(this.maxIndex,c.maxIndex);
} | [
"public",
"void",
"add",
"(",
"Chunks",
"c",
")",
"{",
"assert",
"c",
".",
"chunkBits",
"==",
"chunkBits",
";",
"assert",
"c",
".",
"defaultValue",
"==",
"defaultValue",
";",
"int",
"[",
"]",
"[",
"]",
"oChunks",
"=",
"c",
".",
"chunks",
";",
"if",
"(",
"c",
".",
"numChunks",
">",
"numChunks",
")",
"growTo",
"(",
"c",
".",
"numChunks",
"-",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"oChunks",
".",
"length",
";",
"i",
"++",
")",
"{",
"int",
"[",
"]",
"oChunk",
"=",
"oChunks",
"[",
"i",
"]",
";",
"if",
"(",
"oChunk",
"!=",
"null",
")",
"{",
"if",
"(",
"chunks",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"chunks",
"[",
"i",
"]",
"=",
"oChunk",
".",
"clone",
"(",
")",
";",
"}",
"else",
"{",
"int",
"[",
"]",
"chunk",
"=",
"chunks",
"[",
"i",
"]",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"oChunk",
".",
"length",
";",
"j",
"++",
")",
"{",
"chunk",
"[",
"j",
"]",
"+=",
"oChunk",
"[",
"j",
"]",
";",
"}",
"}",
"}",
"}",
"this",
".",
"maxIndex",
"=",
"Math",
".",
"max",
"(",
"this",
".",
"maxIndex",
",",
"c",
".",
"maxIndex",
")",
";",
"}"
] | adds values from another Chunks to the current one
missing chunks are cloned over
@param c other Chunks | [
"adds",
"values",
"from",
"another",
"Chunks",
"to",
"the",
"current",
"one",
"missing",
"chunks",
"are",
"cloned",
"over"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L154-L174 |
23,784 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.mergeAllChunks | public int[] mergeAllChunks() {
int[] merged = new int[chunkSize*numChunks];
int filledChunks = Math.min(numChunks,getFilledChunks()+1);
for (int i = 0; i < filledChunks ; i++) {
if (chunks[i]!=null) {
System.arraycopy(chunks[i],0,merged,i*chunkSize,chunkSize);
}
}
if (defaultValue!=0) Arrays.fill(merged, size(),merged.length,defaultValue);
return merged;
} | java | public int[] mergeAllChunks() {
int[] merged = new int[chunkSize*numChunks];
int filledChunks = Math.min(numChunks,getFilledChunks()+1);
for (int i = 0; i < filledChunks ; i++) {
if (chunks[i]!=null) {
System.arraycopy(chunks[i],0,merged,i*chunkSize,chunkSize);
}
}
if (defaultValue!=0) Arrays.fill(merged, size(),merged.length,defaultValue);
return merged;
} | [
"public",
"int",
"[",
"]",
"mergeAllChunks",
"(",
")",
"{",
"int",
"[",
"]",
"merged",
"=",
"new",
"int",
"[",
"chunkSize",
"*",
"numChunks",
"]",
";",
"int",
"filledChunks",
"=",
"Math",
".",
"min",
"(",
"numChunks",
",",
"getFilledChunks",
"(",
")",
"+",
"1",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"filledChunks",
";",
"i",
"++",
")",
"{",
"if",
"(",
"chunks",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"System",
".",
"arraycopy",
"(",
"chunks",
"[",
"i",
"]",
",",
"0",
",",
"merged",
",",
"i",
"*",
"chunkSize",
",",
"chunkSize",
")",
";",
"}",
"}",
"if",
"(",
"defaultValue",
"!=",
"0",
")",
"Arrays",
".",
"fill",
"(",
"merged",
",",
"size",
"(",
")",
",",
"merged",
".",
"length",
",",
"defaultValue",
")",
";",
"return",
"merged",
";",
"}"
] | turn this chunked array into a regular int-array, mostly for compatibility
also copying unused space at the end filled with default value | [
"turn",
"this",
"chunked",
"array",
"into",
"a",
"regular",
"int",
"-",
"array",
"mostly",
"for",
"compatibility",
"also",
"copying",
"unused",
"space",
"at",
"the",
"end",
"filled",
"with",
"default",
"value"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L198-L208 |
23,785 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/algorithms/Chunks.java | Chunks.mergeChunks | public int[] mergeChunks() {
int filledChunks = getFilledChunks();
int[] merged = new int[size()];
for (int i = 0; i < filledChunks ; i++) {
if (chunks[i]!=null) {
System.arraycopy(chunks[i], 0, merged, i * chunkSize, chunkSize);
}
}
int remainder = size() % chunkSize;
if (remainder != 0 && chunks[filledChunks]!=null) {
System.arraycopy(chunks[filledChunks], 0, merged, (filledChunks) * chunkSize, remainder);
}
return merged;
} | java | public int[] mergeChunks() {
int filledChunks = getFilledChunks();
int[] merged = new int[size()];
for (int i = 0; i < filledChunks ; i++) {
if (chunks[i]!=null) {
System.arraycopy(chunks[i], 0, merged, i * chunkSize, chunkSize);
}
}
int remainder = size() % chunkSize;
if (remainder != 0 && chunks[filledChunks]!=null) {
System.arraycopy(chunks[filledChunks], 0, merged, (filledChunks) * chunkSize, remainder);
}
return merged;
} | [
"public",
"int",
"[",
"]",
"mergeChunks",
"(",
")",
"{",
"int",
"filledChunks",
"=",
"getFilledChunks",
"(",
")",
";",
"int",
"[",
"]",
"merged",
"=",
"new",
"int",
"[",
"size",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"filledChunks",
";",
"i",
"++",
")",
"{",
"if",
"(",
"chunks",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"System",
".",
"arraycopy",
"(",
"chunks",
"[",
"i",
"]",
",",
"0",
",",
"merged",
",",
"i",
"*",
"chunkSize",
",",
"chunkSize",
")",
";",
"}",
"}",
"int",
"remainder",
"=",
"size",
"(",
")",
"%",
"chunkSize",
";",
"if",
"(",
"remainder",
"!=",
"0",
"&&",
"chunks",
"[",
"filledChunks",
"]",
"!=",
"null",
")",
"{",
"System",
".",
"arraycopy",
"(",
"chunks",
"[",
"filledChunks",
"]",
",",
"0",
",",
"merged",
",",
"(",
"filledChunks",
")",
"*",
"chunkSize",
",",
"remainder",
")",
";",
"}",
"return",
"merged",
";",
"}"
] | turn this chunked array into a regular int-array, mostly for compatibility
cuts off unused space at the end | [
"turn",
"this",
"chunked",
"array",
"into",
"a",
"regular",
"int",
"-",
"array",
"mostly",
"for",
"compatibility",
"cuts",
"off",
"unused",
"space",
"at",
"the",
"end"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/algorithms/Chunks.java#L214-L227 |
23,786 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/generate/utils/WeightedReservoirSampler.java | WeightedReservoirSampler.randomIndexChoice | public int randomIndexChoice(List<Integer> weights) {
int result = 0, index;
double maxKey = 0.0;
double u, key;
int weight;
for (ListIterator<Integer> it = weights.listIterator(); it.hasNext(); ) {
index = it.nextIndex();
weight = it.next();
u = random.nextDouble();
key = Math.pow(u, (1.0/weight)); // Protect from zero division?
if (key > maxKey) {
maxKey = key;
result = index;
}
}
return result;
} | java | public int randomIndexChoice(List<Integer> weights) {
int result = 0, index;
double maxKey = 0.0;
double u, key;
int weight;
for (ListIterator<Integer> it = weights.listIterator(); it.hasNext(); ) {
index = it.nextIndex();
weight = it.next();
u = random.nextDouble();
key = Math.pow(u, (1.0/weight)); // Protect from zero division?
if (key > maxKey) {
maxKey = key;
result = index;
}
}
return result;
} | [
"public",
"int",
"randomIndexChoice",
"(",
"List",
"<",
"Integer",
">",
"weights",
")",
"{",
"int",
"result",
"=",
"0",
",",
"index",
";",
"double",
"maxKey",
"=",
"0.0",
";",
"double",
"u",
",",
"key",
";",
"int",
"weight",
";",
"for",
"(",
"ListIterator",
"<",
"Integer",
">",
"it",
"=",
"weights",
".",
"listIterator",
"(",
")",
";",
"it",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"index",
"=",
"it",
".",
"nextIndex",
"(",
")",
";",
"weight",
"=",
"it",
".",
"next",
"(",
")",
";",
"u",
"=",
"random",
".",
"nextDouble",
"(",
")",
";",
"key",
"=",
"Math",
".",
"pow",
"(",
"u",
",",
"(",
"1.0",
"/",
"weight",
")",
")",
";",
"// Protect from zero division?",
"if",
"(",
"key",
">",
"maxKey",
")",
"{",
"maxKey",
"=",
"key",
";",
"result",
"=",
"index",
";",
"}",
"}",
"return",
"result",
";",
"}"
] | Returns an integer at random, weighted according to its index
@param weights weights to sample from
@return index chosen according to the weight supplied | [
"Returns",
"an",
"integer",
"at",
"random",
"weighted",
"according",
"to",
"its",
"index"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/generate/utils/WeightedReservoirSampler.java#L31-L50 |
23,787 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/algo/Cover.java | Cover.coverNodes | public static Stream<Relationship> coverNodes(Collection<Node> nodes) {
return nodes.stream()
.flatMap(n ->
StreamSupport.stream(n.getRelationships(Direction.OUTGOING)
.spliterator(),false)
.filter(r -> nodes.contains(r.getEndNode())));
} | java | public static Stream<Relationship> coverNodes(Collection<Node> nodes) {
return nodes.stream()
.flatMap(n ->
StreamSupport.stream(n.getRelationships(Direction.OUTGOING)
.spliterator(),false)
.filter(r -> nodes.contains(r.getEndNode())));
} | [
"public",
"static",
"Stream",
"<",
"Relationship",
">",
"coverNodes",
"(",
"Collection",
"<",
"Node",
">",
"nodes",
")",
"{",
"return",
"nodes",
".",
"stream",
"(",
")",
".",
"flatMap",
"(",
"n",
"->",
"StreamSupport",
".",
"stream",
"(",
"n",
".",
"getRelationships",
"(",
"Direction",
".",
"OUTGOING",
")",
".",
"spliterator",
"(",
")",
",",
"false",
")",
".",
"filter",
"(",
"r",
"->",
"nodes",
".",
"contains",
"(",
"r",
".",
"getEndNode",
"(",
")",
")",
")",
")",
";",
"}"
] | non-parallelized utility method for use by other procedures | [
"non",
"-",
"parallelized",
"utility",
"method",
"for",
"use",
"by",
"other",
"procedures"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/algo/Cover.java#L43-L49 |
23,788 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/index/IndexUpdateTransactionEventHandler.java | IndexUpdateTransactionEventHandler.initIndexConfiguration | private synchronized Map<String, Map<String, Collection<Index<Node>>>> initIndexConfiguration() {
Map<String, Map<String, Collection<Index<Node>>>> indexesByLabelAndProperty = new HashMap<>();
try (Transaction tx = graphDatabaseService.beginTx() ) {
final IndexManager indexManager = graphDatabaseService.index();
for (String indexName : indexManager.nodeIndexNames()) {
final Index<Node> index = indexManager.forNodes(indexName);
Map<String, String> indexConfig = indexManager.getConfiguration(index);
if (Util.toBoolean(indexConfig.get("autoUpdate"))) {
String labels = indexConfig.getOrDefault("labels", "");
for (String label : labels.split(":")) {
Map<String, Collection<Index<Node>>> propertyKeyToIndexMap = indexesByLabelAndProperty.computeIfAbsent(label, s -> new HashMap<>());
String[] keysForLabel = indexConfig.getOrDefault("keysForLabel:" + label, "").split(":");
for (String property : keysForLabel) {
propertyKeyToIndexMap.computeIfAbsent(property, s -> new ArrayList<>()).add(index);
}
}
}
}
tx.success();
}
return indexesByLabelAndProperty;
} | java | private synchronized Map<String, Map<String, Collection<Index<Node>>>> initIndexConfiguration() {
Map<String, Map<String, Collection<Index<Node>>>> indexesByLabelAndProperty = new HashMap<>();
try (Transaction tx = graphDatabaseService.beginTx() ) {
final IndexManager indexManager = graphDatabaseService.index();
for (String indexName : indexManager.nodeIndexNames()) {
final Index<Node> index = indexManager.forNodes(indexName);
Map<String, String> indexConfig = indexManager.getConfiguration(index);
if (Util.toBoolean(indexConfig.get("autoUpdate"))) {
String labels = indexConfig.getOrDefault("labels", "");
for (String label : labels.split(":")) {
Map<String, Collection<Index<Node>>> propertyKeyToIndexMap = indexesByLabelAndProperty.computeIfAbsent(label, s -> new HashMap<>());
String[] keysForLabel = indexConfig.getOrDefault("keysForLabel:" + label, "").split(":");
for (String property : keysForLabel) {
propertyKeyToIndexMap.computeIfAbsent(property, s -> new ArrayList<>()).add(index);
}
}
}
}
tx.success();
}
return indexesByLabelAndProperty;
} | [
"private",
"synchronized",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Collection",
"<",
"Index",
"<",
"Node",
">",
">",
">",
">",
"initIndexConfiguration",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"Collection",
"<",
"Index",
"<",
"Node",
">",
">",
">",
">",
"indexesByLabelAndProperty",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"try",
"(",
"Transaction",
"tx",
"=",
"graphDatabaseService",
".",
"beginTx",
"(",
")",
")",
"{",
"final",
"IndexManager",
"indexManager",
"=",
"graphDatabaseService",
".",
"index",
"(",
")",
";",
"for",
"(",
"String",
"indexName",
":",
"indexManager",
".",
"nodeIndexNames",
"(",
")",
")",
"{",
"final",
"Index",
"<",
"Node",
">",
"index",
"=",
"indexManager",
".",
"forNodes",
"(",
"indexName",
")",
";",
"Map",
"<",
"String",
",",
"String",
">",
"indexConfig",
"=",
"indexManager",
".",
"getConfiguration",
"(",
"index",
")",
";",
"if",
"(",
"Util",
".",
"toBoolean",
"(",
"indexConfig",
".",
"get",
"(",
"\"autoUpdate\"",
")",
")",
")",
"{",
"String",
"labels",
"=",
"indexConfig",
".",
"getOrDefault",
"(",
"\"labels\"",
",",
"\"\"",
")",
";",
"for",
"(",
"String",
"label",
":",
"labels",
".",
"split",
"(",
"\":\"",
")",
")",
"{",
"Map",
"<",
"String",
",",
"Collection",
"<",
"Index",
"<",
"Node",
">",
">",
">",
"propertyKeyToIndexMap",
"=",
"indexesByLabelAndProperty",
".",
"computeIfAbsent",
"(",
"label",
",",
"s",
"->",
"new",
"HashMap",
"<>",
"(",
")",
")",
";",
"String",
"[",
"]",
"keysForLabel",
"=",
"indexConfig",
".",
"getOrDefault",
"(",
"\"keysForLabel:\"",
"+",
"label",
",",
"\"\"",
")",
".",
"split",
"(",
"\":\"",
")",
";",
"for",
"(",
"String",
"property",
":",
"keysForLabel",
")",
"{",
"propertyKeyToIndexMap",
".",
"computeIfAbsent",
"(",
"property",
",",
"s",
"->",
"new",
"ArrayList",
"<>",
"(",
")",
")",
".",
"add",
"(",
"index",
")",
";",
"}",
"}",
"}",
"}",
"tx",
".",
"success",
"(",
")",
";",
"}",
"return",
"indexesByLabelAndProperty",
";",
"}"
] | might be run from a scheduler, so we need to make sure we have a transaction | [
"might",
"be",
"run",
"from",
"a",
"scheduler",
"so",
"we",
"need",
"to",
"make",
"sure",
"we",
"have",
"a",
"transaction"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/index/IndexUpdateTransactionEventHandler.java#L223-L247 |
23,789 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/index/IndexUpdateTransactionEventHandler.java | IndexUpdateTransactionEventHandler.forceTxRollover | public synchronized void forceTxRollover() {
if (async) {
try {
forceTxRolloverFlag = false;
indexCommandQueue.put(FORCE_TX_ROLLOVER);
while (!forceTxRolloverFlag) {
Thread.sleep(5);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} | java | public synchronized void forceTxRollover() {
if (async) {
try {
forceTxRolloverFlag = false;
indexCommandQueue.put(FORCE_TX_ROLLOVER);
while (!forceTxRolloverFlag) {
Thread.sleep(5);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} | [
"public",
"synchronized",
"void",
"forceTxRollover",
"(",
")",
"{",
"if",
"(",
"async",
")",
"{",
"try",
"{",
"forceTxRolloverFlag",
"=",
"false",
";",
"indexCommandQueue",
".",
"put",
"(",
"FORCE_TX_ROLLOVER",
")",
";",
"while",
"(",
"!",
"forceTxRolloverFlag",
")",
"{",
"Thread",
".",
"sleep",
"(",
"5",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}",
"}"
] | to be used from unit tests to ensure a tx rollover has happenend | [
"to",
"be",
"used",
"from",
"unit",
"tests",
"to",
"ensure",
"a",
"tx",
"rollover",
"has",
"happenend"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/index/IndexUpdateTransactionEventHandler.java#L372-L385 |
23,790 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/periodic/Periodic.java | Periodic.iterate | @Procedure(mode = Mode.WRITE)
@Description("apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0}) YIELD batches, total - run the second statement for each item returned by the first statement. Returns number of batches and total processed rows")
public Stream<BatchAndTotalResult> iterate(
@Name("cypherIterate") String cypherIterate,
@Name("cypherAction") String cypherAction,
@Name("config") Map<String,Object> config) {
long batchSize = Util.toLong(config.getOrDefault("batchSize", 10000));
int concurrency = Util.toInteger(config.getOrDefault("concurrency", 50));
boolean parallel = Util.toBoolean(config.getOrDefault("parallel", false));
boolean iterateList = Util.toBoolean(config.getOrDefault("iterateList", true));
long retries = Util.toLong(config.getOrDefault("retries", 0)); // todo sleep/delay or push to end of batch to try again or immediate ?
Map<String,Object> params = (Map)config.getOrDefault("params", Collections.emptyMap());
int failedParams = Util.toInteger(config.getOrDefault("failedParams", -1));
try (Result result = db.execute(slottedRuntime(cypherIterate),params)) {
Pair<String,Boolean> prepared = prepareInnerStatement(cypherAction, iterateList, result.columns(), "_batch");
String innerStatement = prepared.first();
iterateList=prepared.other();
log.info("starting batching from `%s` operation using iteration `%s` in separate thread", cypherIterate,cypherAction);
return iterateAndExecuteBatchedInSeparateThread((int)batchSize, parallel, iterateList, retries, result, (p) -> db.execute(innerStatement, merge(params, p)).close(), concurrency, failedParams);
}
} | java | @Procedure(mode = Mode.WRITE)
@Description("apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0}) YIELD batches, total - run the second statement for each item returned by the first statement. Returns number of batches and total processed rows")
public Stream<BatchAndTotalResult> iterate(
@Name("cypherIterate") String cypherIterate,
@Name("cypherAction") String cypherAction,
@Name("config") Map<String,Object> config) {
long batchSize = Util.toLong(config.getOrDefault("batchSize", 10000));
int concurrency = Util.toInteger(config.getOrDefault("concurrency", 50));
boolean parallel = Util.toBoolean(config.getOrDefault("parallel", false));
boolean iterateList = Util.toBoolean(config.getOrDefault("iterateList", true));
long retries = Util.toLong(config.getOrDefault("retries", 0)); // todo sleep/delay or push to end of batch to try again or immediate ?
Map<String,Object> params = (Map)config.getOrDefault("params", Collections.emptyMap());
int failedParams = Util.toInteger(config.getOrDefault("failedParams", -1));
try (Result result = db.execute(slottedRuntime(cypherIterate),params)) {
Pair<String,Boolean> prepared = prepareInnerStatement(cypherAction, iterateList, result.columns(), "_batch");
String innerStatement = prepared.first();
iterateList=prepared.other();
log.info("starting batching from `%s` operation using iteration `%s` in separate thread", cypherIterate,cypherAction);
return iterateAndExecuteBatchedInSeparateThread((int)batchSize, parallel, iterateList, retries, result, (p) -> db.execute(innerStatement, merge(params, p)).close(), concurrency, failedParams);
}
} | [
"@",
"Procedure",
"(",
"mode",
"=",
"Mode",
".",
"WRITE",
")",
"@",
"Description",
"(",
"\"apoc.periodic.iterate('statement returning items', 'statement per item', {batchSize:1000,iterateList:true,parallel:false,params:{},concurrency:50,retries:0}) YIELD batches, total - run the second statement for each item returned by the first statement. Returns number of batches and total processed rows\"",
")",
"public",
"Stream",
"<",
"BatchAndTotalResult",
">",
"iterate",
"(",
"@",
"Name",
"(",
"\"cypherIterate\"",
")",
"String",
"cypherIterate",
",",
"@",
"Name",
"(",
"\"cypherAction\"",
")",
"String",
"cypherAction",
",",
"@",
"Name",
"(",
"\"config\"",
")",
"Map",
"<",
"String",
",",
"Object",
">",
"config",
")",
"{",
"long",
"batchSize",
"=",
"Util",
".",
"toLong",
"(",
"config",
".",
"getOrDefault",
"(",
"\"batchSize\"",
",",
"10000",
")",
")",
";",
"int",
"concurrency",
"=",
"Util",
".",
"toInteger",
"(",
"config",
".",
"getOrDefault",
"(",
"\"concurrency\"",
",",
"50",
")",
")",
";",
"boolean",
"parallel",
"=",
"Util",
".",
"toBoolean",
"(",
"config",
".",
"getOrDefault",
"(",
"\"parallel\"",
",",
"false",
")",
")",
";",
"boolean",
"iterateList",
"=",
"Util",
".",
"toBoolean",
"(",
"config",
".",
"getOrDefault",
"(",
"\"iterateList\"",
",",
"true",
")",
")",
";",
"long",
"retries",
"=",
"Util",
".",
"toLong",
"(",
"config",
".",
"getOrDefault",
"(",
"\"retries\"",
",",
"0",
")",
")",
";",
"// todo sleep/delay or push to end of batch to try again or immediate ?",
"Map",
"<",
"String",
",",
"Object",
">",
"params",
"=",
"(",
"Map",
")",
"config",
".",
"getOrDefault",
"(",
"\"params\"",
",",
"Collections",
".",
"emptyMap",
"(",
")",
")",
";",
"int",
"failedParams",
"=",
"Util",
".",
"toInteger",
"(",
"config",
".",
"getOrDefault",
"(",
"\"failedParams\"",
",",
"-",
"1",
")",
")",
";",
"try",
"(",
"Result",
"result",
"=",
"db",
".",
"execute",
"(",
"slottedRuntime",
"(",
"cypherIterate",
")",
",",
"params",
")",
")",
"{",
"Pair",
"<",
"String",
",",
"Boolean",
">",
"prepared",
"=",
"prepareInnerStatement",
"(",
"cypherAction",
",",
"iterateList",
",",
"result",
".",
"columns",
"(",
")",
",",
"\"_batch\"",
")",
";",
"String",
"innerStatement",
"=",
"prepared",
".",
"first",
"(",
")",
";",
"iterateList",
"=",
"prepared",
".",
"other",
"(",
")",
";",
"log",
".",
"info",
"(",
"\"starting batching from `%s` operation using iteration `%s` in separate thread\"",
",",
"cypherIterate",
",",
"cypherAction",
")",
";",
"return",
"iterateAndExecuteBatchedInSeparateThread",
"(",
"(",
"int",
")",
"batchSize",
",",
"parallel",
",",
"iterateList",
",",
"retries",
",",
"result",
",",
"(",
"p",
")",
"-",
"",
">",
"db",
".",
"execute",
"(",
"innerStatement",
",",
"merge",
"(",
"params",
",",
"p",
")",
")",
".",
"close",
"(",
")",
",",
"concurrency",
",",
"failedParams",
")",
";",
"}",
"}"
] | invoke cypherAction in batched transactions being feeded from cypherIteration running in main thread
@param cypherIterate
@param cypherAction | [
"invoke",
"cypherAction",
"in",
"batched",
"transactions",
"being",
"feeded",
"from",
"cypherIteration",
"running",
"in",
"main",
"thread"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/periodic/Periodic.java#L259-L280 |
23,791 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/mongodb/MongoDBColl.java | MongoDBColl.documentToPackableMap | private Map<String, Object> documentToPackableMap(Map<String, Object> document) {
if (compatibleValues) {
try {
return jsonMapper.readValue(jsonMapper.writeValueAsBytes(document), new TypeReference<Map<String, Object>>() {
});
} catch (Exception e) {
throw new RuntimeException("Cannot convert document to json and back to Map " + e.getMessage());
}
}
/**
* A document in MongoDB has a special field "_id" of type ObjectId
* This object is not "packable" by Neo4jPacker so it must be converted to a value that Neo4j can deal with
*
* If the document is not null we simply override the ObjectId instance with its string representation
*/
if (document != null) {
Object objectId = document.get("_id");
if (objectId != null) {
document.put("_id", objectId.toString());
}
}
return document;
} | java | private Map<String, Object> documentToPackableMap(Map<String, Object> document) {
if (compatibleValues) {
try {
return jsonMapper.readValue(jsonMapper.writeValueAsBytes(document), new TypeReference<Map<String, Object>>() {
});
} catch (Exception e) {
throw new RuntimeException("Cannot convert document to json and back to Map " + e.getMessage());
}
}
/**
* A document in MongoDB has a special field "_id" of type ObjectId
* This object is not "packable" by Neo4jPacker so it must be converted to a value that Neo4j can deal with
*
* If the document is not null we simply override the ObjectId instance with its string representation
*/
if (document != null) {
Object objectId = document.get("_id");
if (objectId != null) {
document.put("_id", objectId.toString());
}
}
return document;
} | [
"private",
"Map",
"<",
"String",
",",
"Object",
">",
"documentToPackableMap",
"(",
"Map",
"<",
"String",
",",
"Object",
">",
"document",
")",
"{",
"if",
"(",
"compatibleValues",
")",
"{",
"try",
"{",
"return",
"jsonMapper",
".",
"readValue",
"(",
"jsonMapper",
".",
"writeValueAsBytes",
"(",
"document",
")",
",",
"new",
"TypeReference",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Cannot convert document to json and back to Map \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"/**\n * A document in MongoDB has a special field \"_id\" of type ObjectId\n * This object is not \"packable\" by Neo4jPacker so it must be converted to a value that Neo4j can deal with\n *\n * If the document is not null we simply override the ObjectId instance with its string representation\n */",
"if",
"(",
"document",
"!=",
"null",
")",
"{",
"Object",
"objectId",
"=",
"document",
".",
"get",
"(",
"\"_id\"",
")",
";",
"if",
"(",
"objectId",
"!=",
"null",
")",
"{",
"document",
".",
"put",
"(",
"\"_id\"",
",",
"objectId",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"return",
"document",
";",
"}"
] | It translates a MongoDB document into a Map where the "_id" field is not an ObjectId
but a simple String representation of it
@param document
@return | [
"It",
"translates",
"a",
"MongoDB",
"document",
"into",
"a",
"Map",
"where",
"the",
"_id",
"field",
"is",
"not",
"an",
"ObjectId",
"but",
"a",
"simple",
"String",
"representation",
"of",
"it"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/mongodb/MongoDBColl.java#L67-L93 |
23,792 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/es/ElasticSearch.java | ElasticSearch.getQueryUrl | protected String getQueryUrl(String hostOrKey, String index, String type, String id, Object query) {
return getElasticSearchUrl(hostOrKey) + formatQueryUrl(index, type, id, query);
} | java | protected String getQueryUrl(String hostOrKey, String index, String type, String id, Object query) {
return getElasticSearchUrl(hostOrKey) + formatQueryUrl(index, type, id, query);
} | [
"protected",
"String",
"getQueryUrl",
"(",
"String",
"hostOrKey",
",",
"String",
"index",
",",
"String",
"type",
",",
"String",
"id",
",",
"Object",
"query",
")",
"{",
"return",
"getElasticSearchUrl",
"(",
"hostOrKey",
")",
"+",
"formatQueryUrl",
"(",
"index",
",",
"type",
",",
"id",
",",
"query",
")",
";",
"}"
] | Get the full Elasticsearch url
@param hostOrKey
@param index
@param type
@param id
@param query
@return | [
"Get",
"the",
"full",
"Elasticsearch",
"url"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/es/ElasticSearch.java#L51-L53 |
23,793 | neo4j-contrib/neo4j-apoc-procedures | src/main/java/apoc/nodes/Nodes.java | Nodes.getDegreeSafe | private int getDegreeSafe(Node node, RelationshipType relType, Direction direction) {
if (relType == null) {
return node.getDegree(direction);
}
return node.getDegree(relType, direction);
} | java | private int getDegreeSafe(Node node, RelationshipType relType, Direction direction) {
if (relType == null) {
return node.getDegree(direction);
}
return node.getDegree(relType, direction);
} | [
"private",
"int",
"getDegreeSafe",
"(",
"Node",
"node",
",",
"RelationshipType",
"relType",
",",
"Direction",
"direction",
")",
"{",
"if",
"(",
"relType",
"==",
"null",
")",
"{",
"return",
"node",
".",
"getDegree",
"(",
"direction",
")",
";",
"}",
"return",
"node",
".",
"getDegree",
"(",
"relType",
",",
"direction",
")",
";",
"}"
] | works in cases when relType is null | [
"works",
"in",
"cases",
"when",
"relType",
"is",
"null"
] | e8386975d1c512c0e4388a1a61f5496121c04f86 | https://github.com/neo4j-contrib/neo4j-apoc-procedures/blob/e8386975d1c512c0e4388a1a61f5496121c04f86/src/main/java/apoc/nodes/Nodes.java#L498-L504 |
23,794 | square/wire | wire-java-generator/src/main/java/com/squareup/wire/java/JavaGenerator.java | JavaGenerator.sanitizeJavadoc | static String sanitizeJavadoc(String documentation) {
// Remove trailing whitespace on each line.
documentation = documentation.replaceAll("[^\\S\n]+\n", "\n");
documentation = documentation.replaceAll("\\s+$", "");
documentation = documentation.replaceAll("\\*/", "*/");
// Rewrite '@see <url>' to use an html anchor tag
documentation = documentation.replaceAll(
"@see (http:" + URL_CHARS + "+)", "@see <a href=\"$1\">$1</a>");
return documentation;
} | java | static String sanitizeJavadoc(String documentation) {
// Remove trailing whitespace on each line.
documentation = documentation.replaceAll("[^\\S\n]+\n", "\n");
documentation = documentation.replaceAll("\\s+$", "");
documentation = documentation.replaceAll("\\*/", "*/");
// Rewrite '@see <url>' to use an html anchor tag
documentation = documentation.replaceAll(
"@see (http:" + URL_CHARS + "+)", "@see <a href=\"$1\">$1</a>");
return documentation;
} | [
"static",
"String",
"sanitizeJavadoc",
"(",
"String",
"documentation",
")",
"{",
"// Remove trailing whitespace on each line.",
"documentation",
"=",
"documentation",
".",
"replaceAll",
"(",
"\"[^\\\\S\\n]+\\n\"",
",",
"\"\\n\"",
")",
";",
"documentation",
"=",
"documentation",
".",
"replaceAll",
"(",
"\"\\\\s+$\"",
",",
"\"\"",
")",
";",
"documentation",
"=",
"documentation",
".",
"replaceAll",
"(",
"\"\\\\*/\"",
",",
"\"*/\"",
")",
";",
"// Rewrite '@see <url>' to use an html anchor tag",
"documentation",
"=",
"documentation",
".",
"replaceAll",
"(",
"\"@see (http:\"",
"+",
"URL_CHARS",
"+",
"\"+)\"",
",",
"\"@see <a href=\\\"$1\\\">$1</a>\"",
")",
";",
"return",
"documentation",
";",
"}"
] | A grab-bag of fixes for things that can go wrong when converting to javadoc. | [
"A",
"grab",
"-",
"bag",
"of",
"fixes",
"for",
"things",
"that",
"can",
"go",
"wrong",
"when",
"converting",
"to",
"javadoc",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-java-generator/src/main/java/com/squareup/wire/java/JavaGenerator.java#L362-L371 |
23,795 | square/wire | wire-schema/src/main/java/com/squareup/wire/schema/Options.java | Options.union | @SuppressWarnings("unchecked")
private Object union(Linker linker, Object a, Object b) {
if (a instanceof List) {
return union((List<?>) a, (List<?>) b);
} else if (a instanceof Map) {
return union(linker, (Map<ProtoMember, Object>) a, (Map<ProtoMember, Object>) b);
} else {
linker.addError("conflicting options: %s, %s", a, b);
return a; // Just return any placeholder.
}
} | java | @SuppressWarnings("unchecked")
private Object union(Linker linker, Object a, Object b) {
if (a instanceof List) {
return union((List<?>) a, (List<?>) b);
} else if (a instanceof Map) {
return union(linker, (Map<ProtoMember, Object>) a, (Map<ProtoMember, Object>) b);
} else {
linker.addError("conflicting options: %s, %s", a, b);
return a; // Just return any placeholder.
}
} | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"private",
"Object",
"union",
"(",
"Linker",
"linker",
",",
"Object",
"a",
",",
"Object",
"b",
")",
"{",
"if",
"(",
"a",
"instanceof",
"List",
")",
"{",
"return",
"union",
"(",
"(",
"List",
"<",
"?",
">",
")",
"a",
",",
"(",
"List",
"<",
"?",
">",
")",
"b",
")",
";",
"}",
"else",
"if",
"(",
"a",
"instanceof",
"Map",
")",
"{",
"return",
"union",
"(",
"linker",
",",
"(",
"Map",
"<",
"ProtoMember",
",",
"Object",
">",
")",
"a",
",",
"(",
"Map",
"<",
"ProtoMember",
",",
"Object",
">",
")",
"b",
")",
";",
"}",
"else",
"{",
"linker",
".",
"addError",
"(",
"\"conflicting options: %s, %s\"",
",",
"a",
",",
"b",
")",
";",
"return",
"a",
";",
"// Just return any placeholder.",
"}",
"}"
] | Combine values for the same key, resolving conflicts based on their type. | [
"Combine",
"values",
"for",
"the",
"same",
"key",
"resolving",
"conflicts",
"based",
"on",
"their",
"type",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/Options.java#L238-L248 |
23,796 | square/wire | wire-schema/src/main/java/com/squareup/wire/schema/SchemaLoader.java | SchemaLoader.loadDescriptorProto | private ProtoFile loadDescriptorProto() throws IOException {
InputStream resourceAsStream = SchemaLoader.class.getResourceAsStream("/" + DESCRIPTOR_PROTO);
try (BufferedSource buffer = Okio.buffer(Okio.source(resourceAsStream))) {
String data = buffer.readUtf8();
Location location = Location.get("", DESCRIPTOR_PROTO);
ProtoFileElement element = ProtoParser.parse(location, data);
return ProtoFile.get(element);
}
} | java | private ProtoFile loadDescriptorProto() throws IOException {
InputStream resourceAsStream = SchemaLoader.class.getResourceAsStream("/" + DESCRIPTOR_PROTO);
try (BufferedSource buffer = Okio.buffer(Okio.source(resourceAsStream))) {
String data = buffer.readUtf8();
Location location = Location.get("", DESCRIPTOR_PROTO);
ProtoFileElement element = ProtoParser.parse(location, data);
return ProtoFile.get(element);
}
} | [
"private",
"ProtoFile",
"loadDescriptorProto",
"(",
")",
"throws",
"IOException",
"{",
"InputStream",
"resourceAsStream",
"=",
"SchemaLoader",
".",
"class",
".",
"getResourceAsStream",
"(",
"\"/\"",
"+",
"DESCRIPTOR_PROTO",
")",
";",
"try",
"(",
"BufferedSource",
"buffer",
"=",
"Okio",
".",
"buffer",
"(",
"Okio",
".",
"source",
"(",
"resourceAsStream",
")",
")",
")",
"{",
"String",
"data",
"=",
"buffer",
".",
"readUtf8",
"(",
")",
";",
"Location",
"location",
"=",
"Location",
".",
"get",
"(",
"\"\"",
",",
"DESCRIPTOR_PROTO",
")",
";",
"ProtoFileElement",
"element",
"=",
"ProtoParser",
".",
"parse",
"(",
"location",
",",
"data",
")",
";",
"return",
"ProtoFile",
".",
"get",
"(",
"element",
")",
";",
"}",
"}"
] | Returns Google's protobuf descriptor, which defines standard options like default, deprecated,
and java_package. If the user has provided their own version of the descriptor proto, that is
preferred. | [
"Returns",
"Google",
"s",
"protobuf",
"descriptor",
"which",
"defines",
"standard",
"options",
"like",
"default",
"deprecated",
"and",
"java_package",
".",
"If",
"the",
"user",
"has",
"provided",
"their",
"own",
"version",
"of",
"the",
"descriptor",
"proto",
"that",
"is",
"preferred",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/SchemaLoader.java#L175-L183 |
23,797 | square/wire | wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java | SyntaxReader.readString | public String readString() {
skipWhitespace(true);
char c = peekChar();
return c == '"' || c == '\'' ? readQuotedString() : readWord();
} | java | public String readString() {
skipWhitespace(true);
char c = peekChar();
return c == '"' || c == '\'' ? readQuotedString() : readWord();
} | [
"public",
"String",
"readString",
"(",
")",
"{",
"skipWhitespace",
"(",
"true",
")",
";",
"char",
"c",
"=",
"peekChar",
"(",
")",
";",
"return",
"c",
"==",
"'",
"'",
"||",
"c",
"==",
"'",
"'",
"?",
"readQuotedString",
"(",
")",
":",
"readWord",
"(",
")",
";",
"}"
] | Reads a quoted or unquoted string and returns it. | [
"Reads",
"a",
"quoted",
"or",
"unquoted",
"string",
"and",
"returns",
"it",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java#L79-L83 |
23,798 | square/wire | wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java | SyntaxReader.readWord | public String readWord() {
skipWhitespace(true);
int start = pos;
while (pos < data.length) {
char c = data[pos];
if ((c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9')
|| (c == '_')
|| (c == '-')
|| (c == '.')) {
pos++;
} else {
break;
}
}
if (start == pos) {
throw unexpected("expected a word");
}
return new String(data, start, pos - start);
} | java | public String readWord() {
skipWhitespace(true);
int start = pos;
while (pos < data.length) {
char c = data[pos];
if ((c >= 'a' && c <= 'z')
|| (c >= 'A' && c <= 'Z')
|| (c >= '0' && c <= '9')
|| (c == '_')
|| (c == '-')
|| (c == '.')) {
pos++;
} else {
break;
}
}
if (start == pos) {
throw unexpected("expected a word");
}
return new String(data, start, pos - start);
} | [
"public",
"String",
"readWord",
"(",
")",
"{",
"skipWhitespace",
"(",
"true",
")",
";",
"int",
"start",
"=",
"pos",
";",
"while",
"(",
"pos",
"<",
"data",
".",
"length",
")",
"{",
"char",
"c",
"=",
"data",
"[",
"pos",
"]",
";",
"if",
"(",
"(",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
")",
"||",
"(",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
")",
"||",
"(",
"c",
">=",
"'",
"'",
"&&",
"c",
"<=",
"'",
"'",
")",
"||",
"(",
"c",
"==",
"'",
"'",
")",
"||",
"(",
"c",
"==",
"'",
"'",
")",
"||",
"(",
"c",
"==",
"'",
"'",
")",
")",
"{",
"pos",
"++",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"if",
"(",
"start",
"==",
"pos",
")",
"{",
"throw",
"unexpected",
"(",
"\"expected a word\"",
")",
";",
"}",
"return",
"new",
"String",
"(",
"data",
",",
"start",
",",
"pos",
"-",
"start",
")",
";",
"}"
] | Reads a non-empty word and returns it. | [
"Reads",
"a",
"non",
"-",
"empty",
"word",
"and",
"returns",
"it",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java#L191-L211 |
23,799 | square/wire | wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java | SyntaxReader.readComment | private String readComment() {
if (pos == data.length || data[pos] != '/') throw new AssertionError();
pos++;
int commentType = pos < data.length ? data[pos++] : -1;
if (commentType == '*') {
StringBuilder result = new StringBuilder();
boolean startOfLine = true;
for (; pos + 1 < data.length; pos++) {
char c = data[pos];
if (c == '*' && data[pos + 1] == '/') {
pos += 2;
return result.toString().trim();
}
if (c == '\n') {
result.append('\n');
newline();
startOfLine = true;
} else if (!startOfLine) {
result.append(c);
} else if (c == '*') {
if (data[pos + 1] == ' ') {
pos += 1; // Skip a single leading space, if present.
}
startOfLine = false;
} else if (!Character.isWhitespace(c)) {
result.append(c);
startOfLine = false;
}
}
throw unexpected("unterminated comment");
} else if (commentType == '/') {
if (pos < data.length && data[pos] == ' ') {
pos += 1; // Skip a single leading space, if present.
}
int start = pos;
while (pos < data.length) {
char c = data[pos++];
if (c == '\n') {
newline();
break;
}
}
return new String(data, start, pos - 1 - start);
} else {
throw unexpected("unexpected '/'");
}
} | java | private String readComment() {
if (pos == data.length || data[pos] != '/') throw new AssertionError();
pos++;
int commentType = pos < data.length ? data[pos++] : -1;
if (commentType == '*') {
StringBuilder result = new StringBuilder();
boolean startOfLine = true;
for (; pos + 1 < data.length; pos++) {
char c = data[pos];
if (c == '*' && data[pos + 1] == '/') {
pos += 2;
return result.toString().trim();
}
if (c == '\n') {
result.append('\n');
newline();
startOfLine = true;
} else if (!startOfLine) {
result.append(c);
} else if (c == '*') {
if (data[pos + 1] == ' ') {
pos += 1; // Skip a single leading space, if present.
}
startOfLine = false;
} else if (!Character.isWhitespace(c)) {
result.append(c);
startOfLine = false;
}
}
throw unexpected("unterminated comment");
} else if (commentType == '/') {
if (pos < data.length && data[pos] == ' ') {
pos += 1; // Skip a single leading space, if present.
}
int start = pos;
while (pos < data.length) {
char c = data[pos++];
if (c == '\n') {
newline();
break;
}
}
return new String(data, start, pos - 1 - start);
} else {
throw unexpected("unexpected '/'");
}
} | [
"private",
"String",
"readComment",
"(",
")",
"{",
"if",
"(",
"pos",
"==",
"data",
".",
"length",
"||",
"data",
"[",
"pos",
"]",
"!=",
"'",
"'",
")",
"throw",
"new",
"AssertionError",
"(",
")",
";",
"pos",
"++",
";",
"int",
"commentType",
"=",
"pos",
"<",
"data",
".",
"length",
"?",
"data",
"[",
"pos",
"++",
"]",
":",
"-",
"1",
";",
"if",
"(",
"commentType",
"==",
"'",
"'",
")",
"{",
"StringBuilder",
"result",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"startOfLine",
"=",
"true",
";",
"for",
"(",
";",
"pos",
"+",
"1",
"<",
"data",
".",
"length",
";",
"pos",
"++",
")",
"{",
"char",
"c",
"=",
"data",
"[",
"pos",
"]",
";",
"if",
"(",
"c",
"==",
"'",
"'",
"&&",
"data",
"[",
"pos",
"+",
"1",
"]",
"==",
"'",
"'",
")",
"{",
"pos",
"+=",
"2",
";",
"return",
"result",
".",
"toString",
"(",
")",
".",
"trim",
"(",
")",
";",
"}",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"result",
".",
"append",
"(",
"'",
"'",
")",
";",
"newline",
"(",
")",
";",
"startOfLine",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"!",
"startOfLine",
")",
"{",
"result",
".",
"append",
"(",
"c",
")",
";",
"}",
"else",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"data",
"[",
"pos",
"+",
"1",
"]",
"==",
"'",
"'",
")",
"{",
"pos",
"+=",
"1",
";",
"// Skip a single leading space, if present.",
"}",
"startOfLine",
"=",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"Character",
".",
"isWhitespace",
"(",
"c",
")",
")",
"{",
"result",
".",
"append",
"(",
"c",
")",
";",
"startOfLine",
"=",
"false",
";",
"}",
"}",
"throw",
"unexpected",
"(",
"\"unterminated comment\"",
")",
";",
"}",
"else",
"if",
"(",
"commentType",
"==",
"'",
"'",
")",
"{",
"if",
"(",
"pos",
"<",
"data",
".",
"length",
"&&",
"data",
"[",
"pos",
"]",
"==",
"'",
"'",
")",
"{",
"pos",
"+=",
"1",
";",
"// Skip a single leading space, if present.",
"}",
"int",
"start",
"=",
"pos",
";",
"while",
"(",
"pos",
"<",
"data",
".",
"length",
")",
"{",
"char",
"c",
"=",
"data",
"[",
"pos",
"++",
"]",
";",
"if",
"(",
"c",
"==",
"'",
"'",
")",
"{",
"newline",
"(",
")",
";",
"break",
";",
"}",
"}",
"return",
"new",
"String",
"(",
"data",
",",
"start",
",",
"pos",
"-",
"1",
"-",
"start",
")",
";",
"}",
"else",
"{",
"throw",
"unexpected",
"(",
"\"unexpected '/'\"",
")",
";",
"}",
"}"
] | Reads a comment and returns its body. | [
"Reads",
"a",
"comment",
"and",
"returns",
"its",
"body",
"."
] | 4a9a00dfadfc14d6a0780b85810418f9cbc78a49 | https://github.com/square/wire/blob/4a9a00dfadfc14d6a0780b85810418f9cbc78a49/wire-schema/src/main/java/com/squareup/wire/schema/internal/parser/SyntaxReader.java#L246-L293 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.