hexsha
stringlengths 40
40
| repo
stringlengths 4
114
| path
stringlengths 6
369
| license
sequence | language
stringclasses 1
value | identifier
stringlengths 1
123
| original_docstring
stringlengths 8
49.2k
| docstring
stringlengths 5
8.63k
| docstring_tokens
sequence | code
stringlengths 25
988k
| code_tokens
sequence | short_docstring
stringlengths 0
6.18k
| short_docstring_tokens
sequence | comment
sequence | parameters
list | docstring_params
dict |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
54d3142b0d42b62fcbd0a60de8d14af5cc6b22e0 | eFaps/eFaps-WebApp | src/main/java/org/efaps/ui/wicket/pages/dialog/DialogPage.java | [
"Apache-2.0"
] | Java | AjaxGoOnBtn | /**
* AjaxLink that closes the ModalWindow this Page was opened in.
*/ | AjaxLink that closes the ModalWindow this Page was opened in. | [
"AjaxLink",
"that",
"closes",
"the",
"ModalWindow",
"this",
"Page",
"was",
"opened",
"in",
"."
] | public class AjaxGoOnBtn
extends AjaxButton<Void>
{
/** Needed for serialization. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new ajax go on btn.
*
* @param _wicketId wicket id of this component
* @param _label the label
*/
public AjaxGoOnBtn(final String _wicketId,
final String _label)
{
super(_wicketId, AjaxButton.ICON.ACCEPT.getReference(), _label);
setSubmit(false);
}
@Override
public void onRequest(final AjaxRequestTarget _target)
{
final AbstractContentPage page = (AbstractContentPage) DialogPage.this.pageReference.getPage();
final AjaxSubmitCloseButton beh = page.visitChildren(AjaxSubmitCloseButton.class,
new IVisitor<Component, AjaxSubmitCloseButton>()
{
@Override
public void component(final Component _component,
final IVisit<AjaxSubmitCloseButton> _visit)
{
_visit.stop((AjaxSubmitCloseButton) _component);
}
});
beh.setValidated(true);
final ModalWindowContainer modal = page.getModal();
modal.close(_target);
}
} | [
"public",
"class",
"AjaxGoOnBtn",
"extends",
"AjaxButton",
"<",
"Void",
">",
"{",
"/** Needed for serialization. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n * Instantiates a new ajax go on btn.\n *\n * @param _wicketId wicket id of this component\n * @param _label the label\n */",
"public",
"AjaxGoOnBtn",
"(",
"final",
"String",
"_wicketId",
",",
"final",
"String",
"_label",
")",
"{",
"super",
"(",
"_wicketId",
",",
"AjaxButton",
".",
"ICON",
".",
"ACCEPT",
".",
"getReference",
"(",
")",
",",
"_label",
")",
";",
"setSubmit",
"(",
"false",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onRequest",
"(",
"final",
"AjaxRequestTarget",
"_target",
")",
"{",
"final",
"AbstractContentPage",
"page",
"=",
"(",
"AbstractContentPage",
")",
"DialogPage",
".",
"this",
".",
"pageReference",
".",
"getPage",
"(",
")",
";",
"final",
"AjaxSubmitCloseButton",
"beh",
"=",
"page",
".",
"visitChildren",
"(",
"AjaxSubmitCloseButton",
".",
"class",
",",
"new",
"IVisitor",
"<",
"Component",
",",
"AjaxSubmitCloseButton",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"component",
"(",
"final",
"Component",
"_component",
",",
"final",
"IVisit",
"<",
"AjaxSubmitCloseButton",
">",
"_visit",
")",
"{",
"_visit",
".",
"stop",
"(",
"(",
"AjaxSubmitCloseButton",
")",
"_component",
")",
";",
"}",
"}",
")",
";",
"beh",
".",
"setValidated",
"(",
"true",
")",
";",
"final",
"ModalWindowContainer",
"modal",
"=",
"page",
".",
"getModal",
"(",
")",
";",
"modal",
".",
"close",
"(",
"_target",
")",
";",
"}",
"}"
] | AjaxLink that closes the ModalWindow this Page was opened in. | [
"AjaxLink",
"that",
"closes",
"the",
"ModalWindow",
"this",
"Page",
"was",
"opened",
"in",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54d3142b0d42b62fcbd0a60de8d14af5cc6b22e0 | eFaps/eFaps-WebApp | src/main/java/org/efaps/ui/wicket/pages/dialog/DialogPage.java | [
"Apache-2.0"
] | Java | AjaxCloseBtn | /**
* AjaxLink that closes the ModalWindow this Page was opened in.
*/ | AjaxLink that closes the ModalWindow this Page was opened in. | [
"AjaxLink",
"that",
"closes",
"the",
"ModalWindow",
"this",
"Page",
"was",
"opened",
"in",
"."
] | public class AjaxCloseBtn
extends AjaxButton<Void>
{
/** Needed for serialization. */
private static final long serialVersionUID = 1L;
/**
* Instantiates a new ajax close btn.
*
* @param _wicketId wicket id of this component
* @param _label the label
*/
public AjaxCloseBtn(final String _wicketId,
final String _label)
{
super(_wicketId, AjaxButton.ICON.CANCEL.getReference(), _label);
setSubmit(false);
}
/**
* @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
* @param _target request target
*/
@Override
public void onRequest(final AjaxRequestTarget _target)
{
DialogPage.this.pageReference.getPage().visitChildren(ModalWindowContainer.class,
new IVisitor<ModalWindowContainer, Void>()
{
@Override
public void component(final ModalWindowContainer _modal,
final IVisit<Void> _visit)
{
_modal.close(_target);
}
});
final StringBuilder bldr = new StringBuilder();
bldr.append("var cD = top.frames[0].document").append(".getElementById('eFapsContentDiv');")
.append("if(cD!=null){")
.append("cD.getElementsByTagName('input');")
.append("if(inp!=null){")
.append(" inp[0].focus();")
.append("}")
.append("}");
_target.appendJavaScript(bldr.toString());
}
} | [
"public",
"class",
"AjaxCloseBtn",
"extends",
"AjaxButton",
"<",
"Void",
">",
"{",
"/** Needed for serialization. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n * Instantiates a new ajax close btn.\n *\n * @param _wicketId wicket id of this component\n * @param _label the label\n */",
"public",
"AjaxCloseBtn",
"(",
"final",
"String",
"_wicketId",
",",
"final",
"String",
"_label",
")",
"{",
"super",
"(",
"_wicketId",
",",
"AjaxButton",
".",
"ICON",
".",
"CANCEL",
".",
"getReference",
"(",
")",
",",
"_label",
")",
";",
"setSubmit",
"(",
"false",
")",
";",
"}",
"/**\n * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)\n * @param _target request target\n */",
"@",
"Override",
"public",
"void",
"onRequest",
"(",
"final",
"AjaxRequestTarget",
"_target",
")",
"{",
"DialogPage",
".",
"this",
".",
"pageReference",
".",
"getPage",
"(",
")",
".",
"visitChildren",
"(",
"ModalWindowContainer",
".",
"class",
",",
"new",
"IVisitor",
"<",
"ModalWindowContainer",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"component",
"(",
"final",
"ModalWindowContainer",
"_modal",
",",
"final",
"IVisit",
"<",
"Void",
">",
"_visit",
")",
"{",
"_modal",
".",
"close",
"(",
"_target",
")",
";",
"}",
"}",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"bldr",
".",
"append",
"(",
"\"",
"var cD = top.frames[0].document",
"\"",
")",
".",
"append",
"(",
"\"",
".getElementById('eFapsContentDiv');",
"\"",
")",
".",
"append",
"(",
"\"",
"if(cD!=null){",
"\"",
")",
".",
"append",
"(",
"\"",
"cD.getElementsByTagName('input');",
"\"",
")",
".",
"append",
"(",
"\"",
"if(inp!=null){",
"\"",
")",
".",
"append",
"(",
"\"",
" inp[0].focus();",
"\"",
")",
".",
"append",
"(",
"\"",
"}",
"\"",
")",
".",
"append",
"(",
"\"",
"}",
"\"",
")",
";",
"_target",
".",
"appendJavaScript",
"(",
"bldr",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | AjaxLink that closes the ModalWindow this Page was opened in. | [
"AjaxLink",
"that",
"closes",
"the",
"ModalWindow",
"this",
"Page",
"was",
"opened",
"in",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54d3142b0d42b62fcbd0a60de8d14af5cc6b22e0 | eFaps/eFaps-WebApp | src/main/java/org/efaps/ui/wicket/pages/dialog/DialogPage.java | [
"Apache-2.0"
] | Java | AjaxSubmitBtn | /**
* AjaxLink that submits the Parameters and closes the ModalWindow.
*/ | AjaxLink that submits the Parameters and closes the ModalWindow. | [
"AjaxLink",
"that",
"submits",
"the",
"Parameters",
"and",
"closes",
"the",
"ModalWindow",
"."
] | public class AjaxSubmitBtn
extends AjaxButton<ICmdUIObject>
{
/** Needed for serialization. */
private static final long serialVersionUID = 1L;
/**
* the Oids that will be submitted.
*/
private final String[] oids;
/**
* Form was validated.
*/
private boolean validated = false;
/**
* Instantiates a new ajax submit btn.
*
* @param _wicketId wicket id of this component
* @param _model model for this component
* @param _oids oids
* @param _label the label
*/
public AjaxSubmitBtn(final String _wicketId,
final IModel<ICmdUIObject> _model,
final String[] _oids,
final String _label)
{
super(_wicketId, _model, AjaxButton.ICON.ACCEPT.getReference(), _label);
this.oids = _oids;
setSubmit(false);
}
/**
* @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)
* @param _target request target
*/
@Override
public void onRequest(final AjaxRequestTarget _target)
{
final ICmdUIObject model = getModelObject();
try {
final boolean showFile = model.getCommand().isTargetShowFile();
if (isValidated() || validate(_target)) {
model.executeEvents(EventType.UI_COMMAND_EXECUTE, ParameterValues.OTHERS, this.oids);
DialogPage.this.pageReference.getPage().visitChildren(ModalWindowContainer.class,
new IVisitor<ModalWindowContainer, Void>()
{
@Override
public void component(final ModalWindowContainer _modal,
final IVisit<Void> _visit)
{
_modal.setWindowClosedCallback(new UpdateParentCallback(
DialogPage.this.pageReference, _modal, true, showFile));
_modal.setUpdateParent(true);
_modal.close(_target);
}
});
}
} catch (final EFapsException e) {
throw new RestartResponseException(new ErrorPage(e));
}
}
/**
* Executes the Validation-Events related to the CommandAbstract which
* called this Form.
*
* @param _target AjaxRequestTarget to be used in the case a ModalPage
* should be called
* @return true if the Validation was valid, otherwise false
* @throws EFapsException on error
*/
private boolean validate(final AjaxRequestTarget _target)
throws EFapsException
{
setValidated(true);
boolean ret = true;
boolean goOn = true;
final ICmdUIObject cmdObject = (ICmdUIObject) getDefaultModelObject();
final List<Return> returns = cmdObject.executeEvents(EventType.UI_VALIDATE,
ParameterValues.OTHERS, this.oids);
final StringBuilder bldr = new StringBuilder();
for (final Return oneReturn : returns) {
if (oneReturn.get(ReturnValues.VALUES) != null || oneReturn.get(ReturnValues.SNIPLETT) != null) {
if (oneReturn.get(ReturnValues.VALUES) != null) {
bldr.append(oneReturn.get(ReturnValues.VALUES));
} else {
bldr.append(oneReturn.get(ReturnValues.SNIPLETT));
}
ret = false;
if (oneReturn.get(ReturnValues.TRUE) == null) {
goOn = false;
}
} else {
if (oneReturn.get(ReturnValues.TRUE) == null) {
ret = false;
// that is the case if it is wrong configured!
}
}
}
if (!ret) {
getPage().visitChildren(Label.class, new IVisitor<Label, Void>()
{
@Override
public void component(final Label _label,
final IVisit<Void> _visit)
{
final Component label = new Label("textLabel", bldr.toString()).setOutputMarkupId(true)
.setEscapeModelStrings(false);
_label.replaceWith(label);
_target.add(label);
_visit.stop();
}
});
if (!goOn) {
final StringBuilder js = new StringBuilder()
.append(" query(\".eFapsWarnDialogButton1\").style(\"display\", \"none\");");
_target.appendJavaScript(DojoWrapper.require(js, DojoClasses.query, DojoClasses.NodeListDom));
}
}
return ret;
}
/**
* Getter method for the instance variable {@link #validated}.
*
* @return value of instance variable {@link #validated}
*/
public boolean isValidated()
{
return this.validated;
}
/**
* Setter method for instance variable {@link #validated}.
*
* @param _validated value for instance variable {@link #validated}
*/
public void setValidated(final boolean _validated)
{
this.validated = _validated;
}
} | [
"public",
"class",
"AjaxSubmitBtn",
"extends",
"AjaxButton",
"<",
"ICmdUIObject",
">",
"{",
"/** Needed for serialization. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\n * the Oids that will be submitted.\n */",
"private",
"final",
"String",
"[",
"]",
"oids",
";",
"/**\n * Form was validated.\n */",
"private",
"boolean",
"validated",
"=",
"false",
";",
"/**\n * Instantiates a new ajax submit btn.\n *\n * @param _wicketId wicket id of this component\n * @param _model model for this component\n * @param _oids oids\n * @param _label the label\n */",
"public",
"AjaxSubmitBtn",
"(",
"final",
"String",
"_wicketId",
",",
"final",
"IModel",
"<",
"ICmdUIObject",
">",
"_model",
",",
"final",
"String",
"[",
"]",
"_oids",
",",
"final",
"String",
"_label",
")",
"{",
"super",
"(",
"_wicketId",
",",
"_model",
",",
"AjaxButton",
".",
"ICON",
".",
"ACCEPT",
".",
"getReference",
"(",
")",
",",
"_label",
")",
";",
"this",
".",
"oids",
"=",
"_oids",
";",
"setSubmit",
"(",
"false",
")",
";",
"}",
"/**\n * @see org.apache.wicket.ajax.markup.html.AjaxLink#onClick(org.apache.wicket.ajax.AjaxRequestTarget)\n * @param _target request target\n */",
"@",
"Override",
"public",
"void",
"onRequest",
"(",
"final",
"AjaxRequestTarget",
"_target",
")",
"{",
"final",
"ICmdUIObject",
"model",
"=",
"getModelObject",
"(",
")",
";",
"try",
"{",
"final",
"boolean",
"showFile",
"=",
"model",
".",
"getCommand",
"(",
")",
".",
"isTargetShowFile",
"(",
")",
";",
"if",
"(",
"isValidated",
"(",
")",
"||",
"validate",
"(",
"_target",
")",
")",
"{",
"model",
".",
"executeEvents",
"(",
"EventType",
".",
"UI_COMMAND_EXECUTE",
",",
"ParameterValues",
".",
"OTHERS",
",",
"this",
".",
"oids",
")",
";",
"DialogPage",
".",
"this",
".",
"pageReference",
".",
"getPage",
"(",
")",
".",
"visitChildren",
"(",
"ModalWindowContainer",
".",
"class",
",",
"new",
"IVisitor",
"<",
"ModalWindowContainer",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"component",
"(",
"final",
"ModalWindowContainer",
"_modal",
",",
"final",
"IVisit",
"<",
"Void",
">",
"_visit",
")",
"{",
"_modal",
".",
"setWindowClosedCallback",
"(",
"new",
"UpdateParentCallback",
"(",
"DialogPage",
".",
"this",
".",
"pageReference",
",",
"_modal",
",",
"true",
",",
"showFile",
")",
")",
";",
"_modal",
".",
"setUpdateParent",
"(",
"true",
")",
";",
"_modal",
".",
"close",
"(",
"_target",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"catch",
"(",
"final",
"EFapsException",
"e",
")",
"{",
"throw",
"new",
"RestartResponseException",
"(",
"new",
"ErrorPage",
"(",
"e",
")",
")",
";",
"}",
"}",
"/**\n * Executes the Validation-Events related to the CommandAbstract which\n * called this Form.\n *\n * @param _target AjaxRequestTarget to be used in the case a ModalPage\n * should be called\n * @return true if the Validation was valid, otherwise false\n * @throws EFapsException on error\n */",
"private",
"boolean",
"validate",
"(",
"final",
"AjaxRequestTarget",
"_target",
")",
"throws",
"EFapsException",
"{",
"setValidated",
"(",
"true",
")",
";",
"boolean",
"ret",
"=",
"true",
";",
"boolean",
"goOn",
"=",
"true",
";",
"final",
"ICmdUIObject",
"cmdObject",
"=",
"(",
"ICmdUIObject",
")",
"getDefaultModelObject",
"(",
")",
";",
"final",
"List",
"<",
"Return",
">",
"returns",
"=",
"cmdObject",
".",
"executeEvents",
"(",
"EventType",
".",
"UI_VALIDATE",
",",
"ParameterValues",
".",
"OTHERS",
",",
"this",
".",
"oids",
")",
";",
"final",
"StringBuilder",
"bldr",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"final",
"Return",
"oneReturn",
":",
"returns",
")",
"{",
"if",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"VALUES",
")",
"!=",
"null",
"||",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"SNIPLETT",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"VALUES",
")",
"!=",
"null",
")",
"{",
"bldr",
".",
"append",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"VALUES",
")",
")",
";",
"}",
"else",
"{",
"bldr",
".",
"append",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"SNIPLETT",
")",
")",
";",
"}",
"ret",
"=",
"false",
";",
"if",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"TRUE",
")",
"==",
"null",
")",
"{",
"goOn",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"oneReturn",
".",
"get",
"(",
"ReturnValues",
".",
"TRUE",
")",
"==",
"null",
")",
"{",
"ret",
"=",
"false",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"ret",
")",
"{",
"getPage",
"(",
")",
".",
"visitChildren",
"(",
"Label",
".",
"class",
",",
"new",
"IVisitor",
"<",
"Label",
",",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"component",
"(",
"final",
"Label",
"_label",
",",
"final",
"IVisit",
"<",
"Void",
">",
"_visit",
")",
"{",
"final",
"Component",
"label",
"=",
"new",
"Label",
"(",
"\"",
"textLabel",
"\"",
",",
"bldr",
".",
"toString",
"(",
")",
")",
".",
"setOutputMarkupId",
"(",
"true",
")",
".",
"setEscapeModelStrings",
"(",
"false",
")",
";",
"_label",
".",
"replaceWith",
"(",
"label",
")",
";",
"_target",
".",
"add",
"(",
"label",
")",
";",
"_visit",
".",
"stop",
"(",
")",
";",
"}",
"}",
")",
";",
"if",
"(",
"!",
"goOn",
")",
"{",
"final",
"StringBuilder",
"js",
"=",
"new",
"StringBuilder",
"(",
")",
".",
"append",
"(",
"\"",
" query(",
"\\\"",
".eFapsWarnDialogButton1",
"\\\"",
").style(",
"\\\"",
"display",
"\\\"",
", ",
"\\\"",
"none",
"\\\"",
");",
"\"",
")",
";",
"_target",
".",
"appendJavaScript",
"(",
"DojoWrapper",
".",
"require",
"(",
"js",
",",
"DojoClasses",
".",
"query",
",",
"DojoClasses",
".",
"NodeListDom",
")",
")",
";",
"}",
"}",
"return",
"ret",
";",
"}",
"/**\n * Getter method for the instance variable {@link #validated}.\n *\n * @return value of instance variable {@link #validated}\n */",
"public",
"boolean",
"isValidated",
"(",
")",
"{",
"return",
"this",
".",
"validated",
";",
"}",
"/**\n * Setter method for instance variable {@link #validated}.\n *\n * @param _validated value for instance variable {@link #validated}\n */",
"public",
"void",
"setValidated",
"(",
"final",
"boolean",
"_validated",
")",
"{",
"this",
".",
"validated",
"=",
"_validated",
";",
"}",
"}"
] | AjaxLink that submits the Parameters and closes the ModalWindow. | [
"AjaxLink",
"that",
"submits",
"the",
"Parameters",
"and",
"closes",
"the",
"ModalWindow",
"."
] | [
"// that is the case if it is wrong configured!"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54d3142b0d42b62fcbd0a60de8d14af5cc6b22e0 | eFaps/eFaps-WebApp | src/main/java/org/efaps/ui/wicket/pages/dialog/DialogPage.java | [
"Apache-2.0"
] | Java | KeyListenerBehavior | /**
* CLass is used to listen to keyboard entries.
*/ | CLass is used to listen to keyboard entries. | [
"CLass",
"is",
"used",
"to",
"listen",
"to",
"keyboard",
"entries",
"."
] | private static final class KeyListenerBehavior
extends Behavior
{
/** Needed for serialization. */
private static final long serialVersionUID = 1L;
@Override
public void renderHead(final Component _component,
final IHeaderResponse _response)
{
super.renderHead(_component, _response);
final StringBuilder js = new StringBuilder();
js.append("function pressed (_event) {")
.append("var b=Wicket.$('").append(_component.getMarkupId())
.append("'); if (typeof(b.onclick) != 'undefined') { b.onclick(); }")
.append("}").append("window.onkeydown = pressed;");
_response.render(JavaScriptHeaderItem.forScript(js, DialogPage.class.getName()));
}
} | [
"private",
"static",
"final",
"class",
"KeyListenerBehavior",
"extends",
"Behavior",
"{",
"/** Needed for serialization. */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"@",
"Override",
"public",
"void",
"renderHead",
"(",
"final",
"Component",
"_component",
",",
"final",
"IHeaderResponse",
"_response",
")",
"{",
"super",
".",
"renderHead",
"(",
"_component",
",",
"_response",
")",
";",
"final",
"StringBuilder",
"js",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"js",
".",
"append",
"(",
"\"",
"function pressed (_event) {",
"\"",
")",
".",
"append",
"(",
"\"",
"var b=Wicket.$('",
"\"",
")",
".",
"append",
"(",
"_component",
".",
"getMarkupId",
"(",
")",
")",
".",
"append",
"(",
"\"",
"'); if (typeof(b.onclick) != 'undefined') { b.onclick(); }",
"\"",
")",
".",
"append",
"(",
"\"",
"}",
"\"",
")",
".",
"append",
"(",
"\"",
"window.onkeydown = pressed;",
"\"",
")",
";",
"_response",
".",
"render",
"(",
"JavaScriptHeaderItem",
".",
"forScript",
"(",
"js",
",",
"DialogPage",
".",
"class",
".",
"getName",
"(",
")",
")",
")",
";",
"}",
"}"
] | CLass is used to listen to keyboard entries. | [
"CLass",
"is",
"used",
"to",
"listen",
"to",
"keyboard",
"entries",
"."
] | [] | [
{
"param": "Behavior",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Behavior",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54d3bdb6f319d8f0f19cef23b67ed2637ddb97bc | cianom/oghma-launcher | src/main/java/com/opusreverie/oghma/launcher/ui/component/StyleUtil.java | [
"MIT"
] | Java | StyleUtil | /**
* Custom styling utility.
*
* @author Cian.
*/ | Custom styling utility.
@author Cian. | [
"Custom",
"styling",
"utility",
".",
"@author",
"Cian",
"."
] | public class StyleUtil {
public static void setComboTextColor(final ComboBox<?> combo, final String textColor) {
combo.setButtonCell(new CssListCell<>(textColor));
}
} | [
"public",
"class",
"StyleUtil",
"{",
"public",
"static",
"void",
"setComboTextColor",
"(",
"final",
"ComboBox",
"<",
"?",
">",
"combo",
",",
"final",
"String",
"textColor",
")",
"{",
"combo",
".",
"setButtonCell",
"(",
"new",
"CssListCell",
"<",
">",
"(",
"textColor",
")",
")",
";",
"}",
"}"
] | Custom styling utility. | [
"Custom",
"styling",
"utility",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54d6148b7c033d63c762981a38bbc97a5b5241e8 | TreeBASE/treebasetest | treebase-core/src/main/java/org/cipres/treebase/domain/matrix/MatrixDataType.java | [
"BSD-3-Clause"
] | Java | MatrixDataType | /**
* MatrixDataType.java
*
* Created on Mar 21, 2006
*
* @author Jin Ruan
*
*/ |
@author Jin Ruan | [
"@author",
"Jin",
"Ruan"
] | @Entity
@Table(name = "MATRIXDATATYPE")
@AttributeOverride(name = "id", column = @Column(name = "MATRIXDATATYPE_ID"))
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "matrixCache")
public class MatrixDataType extends AbstractPersistedObject {
private static final long serialVersionUID = 1208732648506944463L;
// TODO: add a subclass for build-in immutable data types:
public static final String MATRIX_DATATYPE_STANDARD = "Standard";
public static final String MATRIX_DATATYPE_DNA = "DNA";
public static final String MATRIX_DATATYPE_RNA = "RNA";
public static final String MATRIX_DATATYPE_NUCLEOTIDE = "Nucleotide";
public static final String MATRIX_DATATYPE_PROTEIN = "Protein";
public static final String MATRIX_DATATYPE_CONTINUOUS = "Continuous";
public static final String MATRIX_DATATYPE_DISTANCE = "Distance";
public static final String MATRIX_DATATYPE_MIXED = "Mixed";
private String mDescription;
private PhyloChar mDefaultCharacter;
/**
* Constructor.
*/
public MatrixDataType() {
super();
}
/**
* Return the Description field.
*
* @return String mDescription
*/
@Override
@Column(name = "Description", length = TBPersistable.COLUMN_LENGTH_STRING)
public String getDescription() {
return mDescription;
}
/**
* Set the Description field.
*/
public void setDescription(String pNewDescription) {
mDescription = pNewDescription;
}
/**
* Return the DefaultCharacter field.
*
* @return PhyloChar mDefaultCharacter
*/
@ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
@JoinColumn(name = "PHYLOCHAR_ID", nullable = true)
public PhyloChar getDefaultCharacter() {
return mDefaultCharacter;
}
/**
* Set the DefaultCharacter field.
*/
public void setDefaultCharacter(PhyloChar pNewDefaultCharacter) {
mDefaultCharacter = pNewDefaultCharacter;
}
/**
* Returns true if the data type is dna.
*
* @return
*/
@Transient
public boolean isDNA() {
return MATRIX_DATATYPE_DNA.equals(getDescription());
}
/**
* Returns true if the data type is rna.
*
* @return
*/
@Transient
public boolean isRNA() {
return MATRIX_DATATYPE_RNA.equals(getDescription());
}
/**
* Returns true if the data type is protein.
*
* @return
*/
@Transient
public boolean isProtein() {
return MATRIX_DATATYPE_PROTEIN.equals(getDescription());
}
/**
* Returns true if the data type is Standard.
*
* @return
*/
@Transient
public boolean isStandard() {
return MATRIX_DATATYPE_STANDARD.equals(getDescription());
}
/**
* Returns true if the data type is sequence.
*
* @return
*/
@Transient
public boolean isSequence() {
return (MATRIX_DATATYPE_DNA.equals(getDescription())
|| MATRIX_DATATYPE_NUCLEOTIDE.equals(getDescription())
|| MATRIX_DATATYPE_PROTEIN.equals(getDescription()) || MATRIX_DATATYPE_RNA
.equals(getDescription()));
}
} | [
"@",
"Entity",
"@",
"Table",
"(",
"name",
"=",
"\"",
"MATRIXDATATYPE",
"\"",
")",
"@",
"AttributeOverride",
"(",
"name",
"=",
"\"",
"id",
"\"",
",",
"column",
"=",
"@",
"Column",
"(",
"name",
"=",
"\"",
"MATRIXDATATYPE_ID",
"\"",
")",
")",
"@",
"Cache",
"(",
"usage",
"=",
"CacheConcurrencyStrategy",
".",
"NONSTRICT_READ_WRITE",
",",
"region",
"=",
"\"",
"matrixCache",
"\"",
")",
"public",
"class",
"MatrixDataType",
"extends",
"AbstractPersistedObject",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1208732648506944463L",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_STANDARD",
"=",
"\"",
"Standard",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_DNA",
"=",
"\"",
"DNA",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_RNA",
"=",
"\"",
"RNA",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_NUCLEOTIDE",
"=",
"\"",
"Nucleotide",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_PROTEIN",
"=",
"\"",
"Protein",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_CONTINUOUS",
"=",
"\"",
"Continuous",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_DISTANCE",
"=",
"\"",
"Distance",
"\"",
";",
"public",
"static",
"final",
"String",
"MATRIX_DATATYPE_MIXED",
"=",
"\"",
"Mixed",
"\"",
";",
"private",
"String",
"mDescription",
";",
"private",
"PhyloChar",
"mDefaultCharacter",
";",
"/**\r\n\t * Constructor.\r\n\t */",
"public",
"MatrixDataType",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"/**\r\n\t * Return the Description field.\r\n\t * \r\n\t * @return String mDescription\r\n\t */",
"@",
"Override",
"@",
"Column",
"(",
"name",
"=",
"\"",
"Description",
"\"",
",",
"length",
"=",
"TBPersistable",
".",
"COLUMN_LENGTH_STRING",
")",
"public",
"String",
"getDescription",
"(",
")",
"{",
"return",
"mDescription",
";",
"}",
"/**\r\n\t * Set the Description field.\r\n\t */",
"public",
"void",
"setDescription",
"(",
"String",
"pNewDescription",
")",
"{",
"mDescription",
"=",
"pNewDescription",
";",
"}",
"/**\r\n\t * Return the DefaultCharacter field.\r\n\t * \r\n\t * @return PhyloChar mDefaultCharacter\r\n\t */",
"@",
"ManyToOne",
"(",
"cascade",
"=",
"{",
"CascadeType",
".",
"PERSIST",
",",
"CascadeType",
".",
"MERGE",
"}",
")",
"@",
"JoinColumn",
"(",
"name",
"=",
"\"",
"PHYLOCHAR_ID",
"\"",
",",
"nullable",
"=",
"true",
")",
"public",
"PhyloChar",
"getDefaultCharacter",
"(",
")",
"{",
"return",
"mDefaultCharacter",
";",
"}",
"/**\r\n\t * Set the DefaultCharacter field.\r\n\t */",
"public",
"void",
"setDefaultCharacter",
"(",
"PhyloChar",
"pNewDefaultCharacter",
")",
"{",
"mDefaultCharacter",
"=",
"pNewDefaultCharacter",
";",
"}",
"/**\r\n\t * Returns true if the data type is dna.\r\n\t * \r\n\t * @return\r\n\t */",
"@",
"Transient",
"public",
"boolean",
"isDNA",
"(",
")",
"{",
"return",
"MATRIX_DATATYPE_DNA",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\r\n\t * Returns true if the data type is rna.\r\n\t * \r\n\t * @return\r\n\t */",
"@",
"Transient",
"public",
"boolean",
"isRNA",
"(",
")",
"{",
"return",
"MATRIX_DATATYPE_RNA",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\r\n\t * Returns true if the data type is protein.\r\n\t * \r\n\t * @return\r\n\t */",
"@",
"Transient",
"public",
"boolean",
"isProtein",
"(",
")",
"{",
"return",
"MATRIX_DATATYPE_PROTEIN",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\r\n\t * Returns true if the data type is Standard.\r\n\t * \r\n\t * @return\r\n\t */",
"@",
"Transient",
"public",
"boolean",
"isStandard",
"(",
")",
"{",
"return",
"MATRIX_DATATYPE_STANDARD",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\r\n\t * Returns true if the data type is sequence.\r\n\t * \r\n\t * @return\r\n\t */",
"@",
"Transient",
"public",
"boolean",
"isSequence",
"(",
")",
"{",
"return",
"(",
"MATRIX_DATATYPE_DNA",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
"||",
"MATRIX_DATATYPE_NUCLEOTIDE",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
"||",
"MATRIX_DATATYPE_PROTEIN",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
"||",
"MATRIX_DATATYPE_RNA",
".",
"equals",
"(",
"getDescription",
"(",
")",
")",
")",
";",
"}",
"}"
] | MatrixDataType.java | [
"MatrixDataType",
".",
"java"
] | [
"// TODO: add a subclass for build-in immutable data types:\r"
] | [
{
"param": "AbstractPersistedObject",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractPersistedObject",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54d9f0fcf374328737440923c96bc28bc5fd40ff | mikejritter/bagit-support | src/main/java/org/duraspace/bagit/serialize/ZipBagDeserializer.java | [
"Apache-2.0"
] | Java | ZipBagDeserializer | /**
* Deserializer for {@link gov.loc.repository.bagit.domain.Bag}s serialized using zip
*
* @author mikejritter
* @since 2020-02-01
*/ | Deserializer for gov.loc.repository.bagit.domain.Bags serialized using zip
@author mikejritter
@since 2020-02-01 | [
"Deserializer",
"for",
"gov",
".",
"loc",
".",
"repository",
".",
"bagit",
".",
"domain",
".",
"Bags",
"serialized",
"using",
"zip",
"@author",
"mikejritter",
"@since",
"2020",
"-",
"02",
"-",
"01"
] | public class ZipBagDeserializer implements BagDeserializer {
private final Logger logger = LoggerFactory.getLogger(ZipBagDeserializer.class);
protected ZipBagDeserializer() {
}
@Override
public Path deserialize(final Path root) throws IOException {
logger.info("Extracting serialized bag: {}", root.getFileName());
final Path parent = root.getParent();
final int rootNameCount = root.getNameCount();
Optional<String> filename = Optional.empty();
try (ZipArchiveInputStream inputStream = new ZipArchiveInputStream(Files.newInputStream(root))) {
ArchiveEntry entry;
while ((entry = inputStream.getNextEntry()) != null) {
final String name = entry.getName();
logger.debug("Handling entry {}", entry.getName());
final Path archiveFile = parent.resolve(name);
if (Files.notExists(archiveFile.getParent())) {
Files.createDirectories(archiveFile.getParent());
}
if (entry.isDirectory()) {
Files.createDirectories(archiveFile);
if (archiveFile.getNameCount() == rootNameCount) {
logger.debug("Archive name is {}", archiveFile.getFileName());
filename = Optional.of(archiveFile.getFileName().toString());
}
} else {
if (Files.exists(parent.resolve(name))) {
logger.warn("File {} already exists!", name);
} else {
Files.copy(inputStream, archiveFile);
}
}
}
}
final String extracted = filename.orElseGet(() -> {
// get the name from the tarball minus the extension
final String rootName = root.getFileName().toString();
final int dotIdx = rootName.lastIndexOf(".");
return rootName.substring(0, dotIdx);
});
return parent.resolve(extracted);
}
} | [
"public",
"class",
"ZipBagDeserializer",
"implements",
"BagDeserializer",
"{",
"private",
"final",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"ZipBagDeserializer",
".",
"class",
")",
";",
"protected",
"ZipBagDeserializer",
"(",
")",
"{",
"}",
"@",
"Override",
"public",
"Path",
"deserialize",
"(",
"final",
"Path",
"root",
")",
"throws",
"IOException",
"{",
"logger",
".",
"info",
"(",
"\"",
"Extracting serialized bag: {}",
"\"",
",",
"root",
".",
"getFileName",
"(",
")",
")",
";",
"final",
"Path",
"parent",
"=",
"root",
".",
"getParent",
"(",
")",
";",
"final",
"int",
"rootNameCount",
"=",
"root",
".",
"getNameCount",
"(",
")",
";",
"Optional",
"<",
"String",
">",
"filename",
"=",
"Optional",
".",
"empty",
"(",
")",
";",
"try",
"(",
"ZipArchiveInputStream",
"inputStream",
"=",
"new",
"ZipArchiveInputStream",
"(",
"Files",
".",
"newInputStream",
"(",
"root",
")",
")",
")",
"{",
"ArchiveEntry",
"entry",
";",
"while",
"(",
"(",
"entry",
"=",
"inputStream",
".",
"getNextEntry",
"(",
")",
")",
"!=",
"null",
")",
"{",
"final",
"String",
"name",
"=",
"entry",
".",
"getName",
"(",
")",
";",
"logger",
".",
"debug",
"(",
"\"",
"Handling entry {}",
"\"",
",",
"entry",
".",
"getName",
"(",
")",
")",
";",
"final",
"Path",
"archiveFile",
"=",
"parent",
".",
"resolve",
"(",
"name",
")",
";",
"if",
"(",
"Files",
".",
"notExists",
"(",
"archiveFile",
".",
"getParent",
"(",
")",
")",
")",
"{",
"Files",
".",
"createDirectories",
"(",
"archiveFile",
".",
"getParent",
"(",
")",
")",
";",
"}",
"if",
"(",
"entry",
".",
"isDirectory",
"(",
")",
")",
"{",
"Files",
".",
"createDirectories",
"(",
"archiveFile",
")",
";",
"if",
"(",
"archiveFile",
".",
"getNameCount",
"(",
")",
"==",
"rootNameCount",
")",
"{",
"logger",
".",
"debug",
"(",
"\"",
"Archive name is {}",
"\"",
",",
"archiveFile",
".",
"getFileName",
"(",
")",
")",
";",
"filename",
"=",
"Optional",
".",
"of",
"(",
"archiveFile",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"Files",
".",
"exists",
"(",
"parent",
".",
"resolve",
"(",
"name",
")",
")",
")",
"{",
"logger",
".",
"warn",
"(",
"\"",
"File {} already exists!",
"\"",
",",
"name",
")",
";",
"}",
"else",
"{",
"Files",
".",
"copy",
"(",
"inputStream",
",",
"archiveFile",
")",
";",
"}",
"}",
"}",
"}",
"final",
"String",
"extracted",
"=",
"filename",
".",
"orElseGet",
"(",
"(",
")",
"->",
"{",
"final",
"String",
"rootName",
"=",
"root",
".",
"getFileName",
"(",
")",
".",
"toString",
"(",
")",
";",
"final",
"int",
"dotIdx",
"=",
"rootName",
".",
"lastIndexOf",
"(",
"\"",
".",
"\"",
")",
";",
"return",
"rootName",
".",
"substring",
"(",
"0",
",",
"dotIdx",
")",
";",
"}",
")",
";",
"return",
"parent",
".",
"resolve",
"(",
"extracted",
")",
";",
"}",
"}"
] | Deserializer for {@link gov.loc.repository.bagit.domain.Bag}s serialized using zip
@author mikejritter
@since 2020-02-01 | [
"Deserializer",
"for",
"{",
"@link",
"gov",
".",
"loc",
".",
"repository",
".",
"bagit",
".",
"domain",
".",
"Bag",
"}",
"s",
"serialized",
"using",
"zip",
"@author",
"mikejritter",
"@since",
"2020",
"-",
"02",
"-",
"01"
] | [
"// get the name from the tarball minus the extension"
] | [
{
"param": "BagDeserializer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BagDeserializer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54dc592a6998a5b9682e3c5c0d7c1bf811cc3a49 | VivyTeam/spring-boot-starter-liiklus | starter/src/test/java/io/vivy/liiklus/support/TestLiiklusCloudEventPublisher.java | [
"MIT"
] | Java | TestLiiklusCloudEventPublisher | /**
* Publishes both value and liiklus event at the same time
*/ | Publishes both value and liiklus event at the same time | [
"Publishes",
"both",
"value",
"and",
"liiklus",
"event",
"at",
"the",
"same",
"time"
] | public class TestLiiklusCloudEventPublisher extends LiiklusPublisher {
private String topic;
private LiiklusClient liiklusClient;
public TestLiiklusCloudEventPublisher(String topic, LiiklusClient liiklusClient) {
super(topic, liiklusClient);
this.topic = topic;
this.liiklusClient = liiklusClient;
}
@Override
public Mono<PublishReply> publish(String key, byte[] value) {
return liiklusClient.publish(
PublishRequest.newBuilder()
.setKey(ByteString.copyFromUtf8(key))
.setTopic(topic)
.setLiiklusEvent(LiiklusEvent.newBuilder()
.setId(UUID.randomUUID().toString())
.setType("com.vivy.events.test.event")
.setSource("/test")
.setData(ByteString.copyFrom(value))
.build()
)
.build()
);
}
} | [
"public",
"class",
"TestLiiklusCloudEventPublisher",
"extends",
"LiiklusPublisher",
"{",
"private",
"String",
"topic",
";",
"private",
"LiiklusClient",
"liiklusClient",
";",
"public",
"TestLiiklusCloudEventPublisher",
"(",
"String",
"topic",
",",
"LiiklusClient",
"liiklusClient",
")",
"{",
"super",
"(",
"topic",
",",
"liiklusClient",
")",
";",
"this",
".",
"topic",
"=",
"topic",
";",
"this",
".",
"liiklusClient",
"=",
"liiklusClient",
";",
"}",
"@",
"Override",
"public",
"Mono",
"<",
"PublishReply",
">",
"publish",
"(",
"String",
"key",
",",
"byte",
"[",
"]",
"value",
")",
"{",
"return",
"liiklusClient",
".",
"publish",
"(",
"PublishRequest",
".",
"newBuilder",
"(",
")",
".",
"setKey",
"(",
"ByteString",
".",
"copyFromUtf8",
"(",
"key",
")",
")",
".",
"setTopic",
"(",
"topic",
")",
".",
"setLiiklusEvent",
"(",
"LiiklusEvent",
".",
"newBuilder",
"(",
")",
".",
"setId",
"(",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
".",
"setType",
"(",
"\"",
"com.vivy.events.test.event",
"\"",
")",
".",
"setSource",
"(",
"\"",
"/test",
"\"",
")",
".",
"setData",
"(",
"ByteString",
".",
"copyFrom",
"(",
"value",
")",
")",
".",
"build",
"(",
")",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}"
] | Publishes both value and liiklus event at the same time | [
"Publishes",
"both",
"value",
"and",
"liiklus",
"event",
"at",
"the",
"same",
"time"
] | [] | [
{
"param": "LiiklusPublisher",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "LiiklusPublisher",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54dccd745f91c31b038fd277a18378d2431a603e | MatzeS/blackbird_java | core/src/main/java/blackbird/core/DIBuilderRegistry.java | [
"MIT"
] | Java | DIBuilderRegistry | /**
* Register all DIBuilders to this registry so they can be used by blackbird.
* <p>
* TODO solve this via annotations/reflection
*/ | Register all DIBuilders to this registry so they can be used by blackbird.
TODO solve this via annotations/reflection | [
"Register",
"all",
"DIBuilders",
"to",
"this",
"registry",
"so",
"they",
"can",
"be",
"used",
"by",
"blackbird",
".",
"TODO",
"solve",
"this",
"via",
"annotations",
"/",
"reflection"
] | public class DIBuilderRegistry {
private static DIBuilderRegistry ourInstance = new DIBuilderRegistry();
private List<DIBuilder> builderList;
private DIBuilderRegistry() {
builderList = new ArrayList<>();
builderList.add(new DImplementation.Builder());
builderList.add(new LocalHostDevicePort.Builder());
builderList.add(new InfraredReceiverImplementation.Builder());
builderList.add(new RCReceiver.Implementation.Builder());
builderList.add(new AppleRemote.Implementation.Builder());
builderList.add(new AukeyRemote.Implementation.Builder());
builderList.add(new AukeySocket.Implementation.Builder());
builderList.add(new MCP23017.Implementation.Builder());
builderList.add(new RCSocketImplementation.Builder());
builderList.add(new LightController.Implementation.Builder());
builderList.add(new AVRDevice.Implementation.Builder());
builderList.add(new AVRI2CSlaveImplementation.Builder());
builderList.add(new blackbird.core.impl.avr.RCSocketImplementation.Builder());
builderList.add(new blackbird.core.impl.avr.RCReceiver.Implementation.Builder());
builderList.add(new DS18B20.Implementation.Builder());
builderList.add(new blackbird.core.impl.avr.InfraredReceiverImplementation.Builder());
builderList.add(new blackbird.core.impl.MPR121.Implementation.Builder());
builderList.add(new blackbird.core.impl.avr.AVRI2CMasterImplementation.Builder());
builderList.add(new LocalHostDeviceImplementation.Builder());
}
public static void addBuilder(DIBuilder builder) {
getInstance().builderList.add(builder);
}
public static List<DIBuilder> getBuilders() {
return getInstance().builderList;
}
public static DIBuilderRegistry getInstance() {
return ourInstance;
}
public static void removeBuilder(DIBuilder builder) {
getInstance().builderList.remove(builder);
}
} | [
"public",
"class",
"DIBuilderRegistry",
"{",
"private",
"static",
"DIBuilderRegistry",
"ourInstance",
"=",
"new",
"DIBuilderRegistry",
"(",
")",
";",
"private",
"List",
"<",
"DIBuilder",
">",
"builderList",
";",
"private",
"DIBuilderRegistry",
"(",
")",
"{",
"builderList",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"DImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"LocalHostDevicePort",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"InfraredReceiverImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"RCReceiver",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"AppleRemote",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"AukeyRemote",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"AukeySocket",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"MCP23017",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"RCSocketImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"LightController",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"AVRDevice",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"AVRI2CSlaveImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"blackbird",
".",
"core",
".",
"impl",
".",
"avr",
".",
"RCSocketImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"blackbird",
".",
"core",
".",
"impl",
".",
"avr",
".",
"RCReceiver",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"DS18B20",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"blackbird",
".",
"core",
".",
"impl",
".",
"avr",
".",
"InfraredReceiverImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"blackbird",
".",
"core",
".",
"impl",
".",
"MPR121",
".",
"Implementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"blackbird",
".",
"core",
".",
"impl",
".",
"avr",
".",
"AVRI2CMasterImplementation",
".",
"Builder",
"(",
")",
")",
";",
"builderList",
".",
"add",
"(",
"new",
"LocalHostDeviceImplementation",
".",
"Builder",
"(",
")",
")",
";",
"}",
"public",
"static",
"void",
"addBuilder",
"(",
"DIBuilder",
"builder",
")",
"{",
"getInstance",
"(",
")",
".",
"builderList",
".",
"add",
"(",
"builder",
")",
";",
"}",
"public",
"static",
"List",
"<",
"DIBuilder",
">",
"getBuilders",
"(",
")",
"{",
"return",
"getInstance",
"(",
")",
".",
"builderList",
";",
"}",
"public",
"static",
"DIBuilderRegistry",
"getInstance",
"(",
")",
"{",
"return",
"ourInstance",
";",
"}",
"public",
"static",
"void",
"removeBuilder",
"(",
"DIBuilder",
"builder",
")",
"{",
"getInstance",
"(",
")",
".",
"builderList",
".",
"remove",
"(",
"builder",
")",
";",
"}",
"}"
] | Register all DIBuilders to this registry so they can be used by blackbird. | [
"Register",
"all",
"DIBuilders",
"to",
"this",
"registry",
"so",
"they",
"can",
"be",
"used",
"by",
"blackbird",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54de94ce09232a9d0289df8019c66a6fb81bb26e | splitio/java-client | client/src/main/java/io/split/engine/matchers/AllKeysMatcher.java | [
"Apache-2.0"
] | Java | AllKeysMatcher | /**
* A matcher that matches all keys. It returns true for everything.
*
* @author adil
*/ | A matcher that matches all keys. It returns true for everything.
@author adil | [
"A",
"matcher",
"that",
"matches",
"all",
"keys",
".",
"It",
"returns",
"true",
"for",
"everything",
".",
"@author",
"adil"
] | public final class AllKeysMatcher implements Matcher {
@Override
public boolean match(Object matchValue, String bucketingKey, Map<String, Object> attributes, EvaluationContext evaluationContext) {
if (matchValue == null) {
return false;
}
return true;
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (this == obj) return true;
if (!(obj instanceof AllKeysMatcher)) return false;
return true;
}
@Override
public int hashCode() {
return 17;
}
@Override
public String toString() {
return "in segment all";
}
} | [
"public",
"final",
"class",
"AllKeysMatcher",
"implements",
"Matcher",
"{",
"@",
"Override",
"public",
"boolean",
"match",
"(",
"Object",
"matchValue",
",",
"String",
"bucketingKey",
",",
"Map",
"<",
"String",
",",
"Object",
">",
"attributes",
",",
"EvaluationContext",
"evaluationContext",
")",
"{",
"if",
"(",
"matchValue",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"obj",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"this",
"==",
"obj",
")",
"return",
"true",
";",
"if",
"(",
"!",
"(",
"obj",
"instanceof",
"AllKeysMatcher",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"return",
"17",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"in segment all",
"\"",
";",
"}",
"}"
] | A matcher that matches all keys. | [
"A",
"matcher",
"that",
"matches",
"all",
"keys",
"."
] | [] | [
{
"param": "Matcher",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Matcher",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54e0640fec6b440ede7239b8fe83db60c3a4fe1b | CSCSI/Triana | triana-toolboxes/common/src/main/java/common/string/StringGenPanel.java | [
"Apache-2.0"
] | Java | StringGenPanel | /**
* $POPUP_DESCRIPTION
*
* @author $AUTHOR
* @version $Revision: 2921 $
*/ | $POPUP_DESCRIPTION
@author $AUTHOR
@version $Revision: 2921 $ | [
"$POPUP_DESCRIPTION",
"@author",
"$AUTHOR",
"@version",
"$Revision",
":",
"2921",
"$"
] | public class StringGenPanel extends ParameterPanel implements ActionListener, FocusListener, ItemListener {
private JTextArea textarea = new JTextArea(10, 30);
private JMenuItem open = new JMenuItem("Open...");
private JMenuItem clear = new JMenuItem("Clear");
private JCheckBoxMenuItem wordwrap = new JCheckBoxMenuItem("Word Wrap", false);
/**
* This method is called before the panel is displayed. It should initialise the panel layout.
*/
public void init() {
setLayout(new BorderLayout());
JMenu filemenu = new JMenu("File");
filemenu.add(open);
filemenu.add(clear);
open.addActionListener(this);
clear.addActionListener(this);
JMenu viewmenu = new JMenu("View");
viewmenu.add(wordwrap);
wordwrap.addItemListener(this);
JMenuBar menu = new JMenuBar();
menu.add(filemenu);
menu.add(viewmenu);
setMenuBar(menu);
textarea.setLineWrap(false);
textarea.setWrapStyleWord(true);
textarea.addFocusListener(this);
textarea.setText(getParameter("str").toString());
JLabel label = new JLabel("Enter String:");
label.setBorder(new EmptyBorder(0, 0, 3, 0));
JScrollPane scroll = new JScrollPane(textarea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel textpanel = new JPanel(new BorderLayout());
textpanel.add(label, BorderLayout.NORTH);
textpanel.add(scroll, BorderLayout.CENTER);
add(textpanel, BorderLayout.CENTER);
}
/**
* This method is called when cancel is clicked on the parameter window. It should synchronize the GUI components
* with the task parameter values
*/
public void reset() {
textarea.setText(getParameter("str").toString());
}
/**
* This method is called when a parameter in the task is updated. It should update the GUI in response to the
* parameter update
*/
public void parameterUpdate(String paramname, Object value) {
if (paramname.equals("str")) {
textarea.setText(value.toString());
}
}
/**
* This method is called when the panel is being disposed off. It should clean-up subwindows, open files etc.
*/
public void dispose() {
textarea.removeFocusListener(this);
}
/**
* Opens a text file into the string gen
*/
private void open() {
TFileChooser chooser = new TFileChooser("Common.String.StringGen");
chooser.setDialogTitle("Open...");
chooser.setFileSelectionMode(TFileChooser.FILES_ONLY);
int result = chooser.showOpenDialog(this);
if (result == TFileChooser.APPROVE_OPTION) {
String str = "";
String line;
boolean init = true;
try {
BufferedReader reader = new BufferedReader(new FileReader(chooser.getSelectedFile()));
while ((line = reader.readLine()) != null) {
if (!init) {
str += "\n";
} else {
init = false;
}
str += line;
}
} catch (IOException except) {
ErrorDialog.show("Error Reading File: " + chooser.getSelectedFile(), except);
}
textarea.setText(str);
textarea.setCaretPosition(0);
}
}
/**
* Invoked when an action occurs.
*/
public void actionPerformed(ActionEvent event) {
if (event.getSource() == open) {
open();
} else if (event.getSource() == clear) {
textarea.setText("");
}
}
public void itemStateChanged(ItemEvent event) {
if (event.getSource() == wordwrap) {
textarea.setLineWrap(wordwrap.isSelected());
}
}
public void focusGained(FocusEvent event) {
}
public void focusLost(FocusEvent event) {
setParameter("str", textarea.getText());
}
} | [
"public",
"class",
"StringGenPanel",
"extends",
"ParameterPanel",
"implements",
"ActionListener",
",",
"FocusListener",
",",
"ItemListener",
"{",
"private",
"JTextArea",
"textarea",
"=",
"new",
"JTextArea",
"(",
"10",
",",
"30",
")",
";",
"private",
"JMenuItem",
"open",
"=",
"new",
"JMenuItem",
"(",
"\"",
"Open...",
"\"",
")",
";",
"private",
"JMenuItem",
"clear",
"=",
"new",
"JMenuItem",
"(",
"\"",
"Clear",
"\"",
")",
";",
"private",
"JCheckBoxMenuItem",
"wordwrap",
"=",
"new",
"JCheckBoxMenuItem",
"(",
"\"",
"Word Wrap",
"\"",
",",
"false",
")",
";",
"/**\n * This method is called before the panel is displayed. It should initialise the panel layout.\n */",
"public",
"void",
"init",
"(",
")",
"{",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"JMenu",
"filemenu",
"=",
"new",
"JMenu",
"(",
"\"",
"File",
"\"",
")",
";",
"filemenu",
".",
"add",
"(",
"open",
")",
";",
"filemenu",
".",
"add",
"(",
"clear",
")",
";",
"open",
".",
"addActionListener",
"(",
"this",
")",
";",
"clear",
".",
"addActionListener",
"(",
"this",
")",
";",
"JMenu",
"viewmenu",
"=",
"new",
"JMenu",
"(",
"\"",
"View",
"\"",
")",
";",
"viewmenu",
".",
"add",
"(",
"wordwrap",
")",
";",
"wordwrap",
".",
"addItemListener",
"(",
"this",
")",
";",
"JMenuBar",
"menu",
"=",
"new",
"JMenuBar",
"(",
")",
";",
"menu",
".",
"add",
"(",
"filemenu",
")",
";",
"menu",
".",
"add",
"(",
"viewmenu",
")",
";",
"setMenuBar",
"(",
"menu",
")",
";",
"textarea",
".",
"setLineWrap",
"(",
"false",
")",
";",
"textarea",
".",
"setWrapStyleWord",
"(",
"true",
")",
";",
"textarea",
".",
"addFocusListener",
"(",
"this",
")",
";",
"textarea",
".",
"setText",
"(",
"getParameter",
"(",
"\"",
"str",
"\"",
")",
".",
"toString",
"(",
")",
")",
";",
"JLabel",
"label",
"=",
"new",
"JLabel",
"(",
"\"",
"Enter String:",
"\"",
")",
";",
"label",
".",
"setBorder",
"(",
"new",
"EmptyBorder",
"(",
"0",
",",
"0",
",",
"3",
",",
"0",
")",
")",
";",
"JScrollPane",
"scroll",
"=",
"new",
"JScrollPane",
"(",
"textarea",
",",
"JScrollPane",
".",
"VERTICAL_SCROLLBAR_ALWAYS",
",",
"JScrollPane",
".",
"HORIZONTAL_SCROLLBAR_AS_NEEDED",
")",
";",
"JPanel",
"textpanel",
"=",
"new",
"JPanel",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"textpanel",
".",
"add",
"(",
"label",
",",
"BorderLayout",
".",
"NORTH",
")",
";",
"textpanel",
".",
"add",
"(",
"scroll",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"add",
"(",
"textpanel",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"}",
"/**\n * This method is called when cancel is clicked on the parameter window. It should synchronize the GUI components\n * with the task parameter values\n */",
"public",
"void",
"reset",
"(",
")",
"{",
"textarea",
".",
"setText",
"(",
"getParameter",
"(",
"\"",
"str",
"\"",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"/**\n * This method is called when a parameter in the task is updated. It should update the GUI in response to the\n * parameter update\n */",
"public",
"void",
"parameterUpdate",
"(",
"String",
"paramname",
",",
"Object",
"value",
")",
"{",
"if",
"(",
"paramname",
".",
"equals",
"(",
"\"",
"str",
"\"",
")",
")",
"{",
"textarea",
".",
"setText",
"(",
"value",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"/**\n * This method is called when the panel is being disposed off. It should clean-up subwindows, open files etc.\n */",
"public",
"void",
"dispose",
"(",
")",
"{",
"textarea",
".",
"removeFocusListener",
"(",
"this",
")",
";",
"}",
"/**\n * Opens a text file into the string gen\n */",
"private",
"void",
"open",
"(",
")",
"{",
"TFileChooser",
"chooser",
"=",
"new",
"TFileChooser",
"(",
"\"",
"Common.String.StringGen",
"\"",
")",
";",
"chooser",
".",
"setDialogTitle",
"(",
"\"",
"Open...",
"\"",
")",
";",
"chooser",
".",
"setFileSelectionMode",
"(",
"TFileChooser",
".",
"FILES_ONLY",
")",
";",
"int",
"result",
"=",
"chooser",
".",
"showOpenDialog",
"(",
"this",
")",
";",
"if",
"(",
"result",
"==",
"TFileChooser",
".",
"APPROVE_OPTION",
")",
"{",
"String",
"str",
"=",
"\"",
"\"",
";",
"String",
"line",
";",
"boolean",
"init",
"=",
"true",
";",
"try",
"{",
"BufferedReader",
"reader",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"chooser",
".",
"getSelectedFile",
"(",
")",
")",
")",
";",
"while",
"(",
"(",
"line",
"=",
"reader",
".",
"readLine",
"(",
")",
")",
"!=",
"null",
")",
"{",
"if",
"(",
"!",
"init",
")",
"{",
"str",
"+=",
"\"",
"\\n",
"\"",
";",
"}",
"else",
"{",
"init",
"=",
"false",
";",
"}",
"str",
"+=",
"line",
";",
"}",
"}",
"catch",
"(",
"IOException",
"except",
")",
"{",
"ErrorDialog",
".",
"show",
"(",
"\"",
"Error Reading File: ",
"\"",
"+",
"chooser",
".",
"getSelectedFile",
"(",
")",
",",
"except",
")",
";",
"}",
"textarea",
".",
"setText",
"(",
"str",
")",
";",
"textarea",
".",
"setCaretPosition",
"(",
"0",
")",
";",
"}",
"}",
"/**\n * Invoked when an action occurs.\n */",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getSource",
"(",
")",
"==",
"open",
")",
"{",
"open",
"(",
")",
";",
"}",
"else",
"if",
"(",
"event",
".",
"getSource",
"(",
")",
"==",
"clear",
")",
"{",
"textarea",
".",
"setText",
"(",
"\"",
"\"",
")",
";",
"}",
"}",
"public",
"void",
"itemStateChanged",
"(",
"ItemEvent",
"event",
")",
"{",
"if",
"(",
"event",
".",
"getSource",
"(",
")",
"==",
"wordwrap",
")",
"{",
"textarea",
".",
"setLineWrap",
"(",
"wordwrap",
".",
"isSelected",
"(",
")",
")",
";",
"}",
"}",
"public",
"void",
"focusGained",
"(",
"FocusEvent",
"event",
")",
"{",
"}",
"public",
"void",
"focusLost",
"(",
"FocusEvent",
"event",
")",
"{",
"setParameter",
"(",
"\"",
"str",
"\"",
",",
"textarea",
".",
"getText",
"(",
")",
")",
";",
"}",
"}"
] | $POPUP_DESCRIPTION
@author $AUTHOR
@version $Revision: 2921 $ | [
"$POPUP_DESCRIPTION",
"@author",
"$AUTHOR",
"@version",
"$Revision",
":",
"2921",
"$"
] | [] | [
{
"param": "ParameterPanel",
"type": null
},
{
"param": "ActionListener, FocusListener, ItemListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ParameterPanel",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ActionListener, FocusListener, ItemListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54e36f9129ea20f9eca32a3d0f2c0456c0197c6a | Tsvetelin98/Solar | net.solarnetwork.external.net.wimpi.modbus/src/net/wimpi/modbus/io/ModbusSerialTransaction.java | [
"Apache-2.0"
] | Java | ModbusSerialTransaction | /**
* Class implementing the <tt>ModbusTransaction</tt>
* interface.
*
* @author Dieter Wimberger
* @version 1.2rc2 (14/04/2014)
*/ | Class implementing the ModbusTransaction
interface.
| [
"Class",
"implementing",
"the",
"ModbusTransaction",
"interface",
"."
] | public class ModbusSerialTransaction
implements ModbusTransaction {
//class attributes
private static AtomicCounter c_TransactionID =
new AtomicCounter(Modbus.DEFAULT_TRANSACTION_ID);
//instance attributes and associations
private ModbusTransport m_IO;
private ModbusRequest m_Request;
private ModbusResponse m_Response;
private boolean m_ValidityCheck =
Modbus.DEFAULT_VALIDITYCHECK;
private int m_Retries = Modbus.DEFAULT_RETRIES;
private int m_TransDelayMS = Modbus.DEFAULT_TRANSMIT_DELAY;
private SerialConnection m_SerialCon;
private Mutex m_TransactionLock = new Mutex();
/**
* Constructs a new <tt>ModbusSerialTransaction</tt>
* instance.
*/
public ModbusSerialTransaction() {
}//constructor
/**
* Constructs a new <tt>ModbusSerialTransaction</tt>
* instance with a given <tt>ModbusRequest</tt> to
* be send when the transaction is executed.
* <p/>
*
* @param request a <tt>ModbusRequest</tt> instance.
*/
public ModbusSerialTransaction(ModbusRequest request) {
setRequest(request);
}//constructor
/**
* Constructs a new <tt>ModbusSerialTransaction</tt>
* instance with a given <tt>ModbusRequest</tt> to
* be send when the transaction is executed.
* <p/>
*
* @param con a <tt>TCPMasterConnection</tt> instance.
*/
public ModbusSerialTransaction(SerialConnection con) {
setSerialConnection(con);
}//constructor
/**
* Sets the port on which this <tt>ModbusTransaction</tt>
* should be executed.<p>
* <p/>
*
* @param con a <tt>SerialConnection</tt>.
*/
public void setSerialConnection(SerialConnection con) {
m_SerialCon = con;
m_IO = con.getModbusTransport();
}//setConnection
public int getTransactionID() {
return c_TransactionID.get();
}//getTransactionID
public void setRequest(ModbusRequest req) {
m_Request = req;
//m_Response = req.getResponse();
}//setRequest
public ModbusRequest getRequest() {
return m_Request;
}//getRequest
public ModbusResponse getResponse() {
return m_Response;
}//getResponse
public void setCheckingValidity(boolean b) {
m_ValidityCheck = b;
}//setCheckingValidity
public boolean isCheckingValidity() {
return m_ValidityCheck;
}//isCheckingValidity
public int getRetries() {
return m_Retries;
}//getRetries
public void setRetries(int num) {
m_Retries = num;
}//setRetries
/**
* Get the TransDelayMS value.
*
* @return the TransDelayMS value.
*/
public int getTransDelayMS() {
return m_TransDelayMS;
}
/**
* Set the TransDelayMS value.
*
* @param newTransDelayMS The new TransDelayMS value.
*/
public void setTransDelayMS(int newTransDelayMS) {
this.m_TransDelayMS = newTransDelayMS;
}
public void execute() throws ModbusIOException,
ModbusSlaveException,
ModbusException {
//1. assert executeability
assertExecutable();
try {
//2. Lock transaction
/**
* Note: The way this explicit synchronization is implemented at the moment,
* there is no ordering of pending threads. The Mutex will simply call notify()
* and the JVM will handle the rest.
*/
m_TransactionLock.acquire();
//3. write request, and read response,
// while holding the lock on the IO object
synchronized (m_IO) {
int tries = 0;
boolean finished = false;
//toggle the id
m_Request.setTransactionID(c_TransactionID.increment());
do {
try {
if (m_TransDelayMS > 0) {
try {
Thread.sleep(m_TransDelayMS);
} catch (InterruptedException ex) {
System.err.println("InterruptedException: " + ex.getMessage());
}
}
//write request message
m_IO.writeMessage(m_Request);
//read response message
m_Response = m_IO.readResponse();
finished = true;
} catch (ModbusIOException e) {
if (++tries >= m_Retries) {
throw e;
}
System.err.println("execute try " + tries + " error: " +
e.getMessage());
}
} while (!finished);
}
//4. deal with exceptions
if (m_Response instanceof ExceptionResponse) {
throw new ModbusSlaveException(
((ExceptionResponse) m_Response).getExceptionCode()
);
}
if (isCheckingValidity()) {
checkValidity();
}
} catch (InterruptedException ex) {
throw new ModbusIOException("Thread acquiring lock was interrupted.");
} finally {
m_TransactionLock.release();
}
}//execute
/**
* Asserts if this <tt>ModbusTCPTransaction</tt> is
* executable.
*
* @throws ModbusException if the transaction cannot be asserted.
*/
private void assertExecutable()
throws ModbusException {
if (m_Request == null ||
m_SerialCon == null) {
throw new ModbusException(
"Assertion failed, transaction not executable"
);
}
}//assertExecuteable
/**
* Checks the validity of the transaction, by
* checking if the values of the response correspond
* to the values of the request.
*
* @throws ModbusException if the transaction is not valid.
*/
protected void checkValidity() throws ModbusException {
}//checkValidity
} | [
"public",
"class",
"ModbusSerialTransaction",
"implements",
"ModbusTransaction",
"{",
"private",
"static",
"AtomicCounter",
"c_TransactionID",
"=",
"new",
"AtomicCounter",
"(",
"Modbus",
".",
"DEFAULT_TRANSACTION_ID",
")",
";",
"private",
"ModbusTransport",
"m_IO",
";",
"private",
"ModbusRequest",
"m_Request",
";",
"private",
"ModbusResponse",
"m_Response",
";",
"private",
"boolean",
"m_ValidityCheck",
"=",
"Modbus",
".",
"DEFAULT_VALIDITYCHECK",
";",
"private",
"int",
"m_Retries",
"=",
"Modbus",
".",
"DEFAULT_RETRIES",
";",
"private",
"int",
"m_TransDelayMS",
"=",
"Modbus",
".",
"DEFAULT_TRANSMIT_DELAY",
";",
"private",
"SerialConnection",
"m_SerialCon",
";",
"private",
"Mutex",
"m_TransactionLock",
"=",
"new",
"Mutex",
"(",
")",
";",
"/**\n * Constructs a new <tt>ModbusSerialTransaction</tt>\n * instance.\n */",
"public",
"ModbusSerialTransaction",
"(",
")",
"{",
"}",
"/**\n * Constructs a new <tt>ModbusSerialTransaction</tt>\n * instance with a given <tt>ModbusRequest</tt> to\n * be send when the transaction is executed.\n * <p/>\n *\n * @param request a <tt>ModbusRequest</tt> instance.\n */",
"public",
"ModbusSerialTransaction",
"(",
"ModbusRequest",
"request",
")",
"{",
"setRequest",
"(",
"request",
")",
";",
"}",
"/**\n * Constructs a new <tt>ModbusSerialTransaction</tt>\n * instance with a given <tt>ModbusRequest</tt> to\n * be send when the transaction is executed.\n * <p/>\n *\n * @param con a <tt>TCPMasterConnection</tt> instance.\n */",
"public",
"ModbusSerialTransaction",
"(",
"SerialConnection",
"con",
")",
"{",
"setSerialConnection",
"(",
"con",
")",
";",
"}",
"/**\n * Sets the port on which this <tt>ModbusTransaction</tt>\n * should be executed.<p>\n * <p/>\n *\n * @param con a <tt>SerialConnection</tt>.\n */",
"public",
"void",
"setSerialConnection",
"(",
"SerialConnection",
"con",
")",
"{",
"m_SerialCon",
"=",
"con",
";",
"m_IO",
"=",
"con",
".",
"getModbusTransport",
"(",
")",
";",
"}",
"public",
"int",
"getTransactionID",
"(",
")",
"{",
"return",
"c_TransactionID",
".",
"get",
"(",
")",
";",
"}",
"public",
"void",
"setRequest",
"(",
"ModbusRequest",
"req",
")",
"{",
"m_Request",
"=",
"req",
";",
"}",
"public",
"ModbusRequest",
"getRequest",
"(",
")",
"{",
"return",
"m_Request",
";",
"}",
"public",
"ModbusResponse",
"getResponse",
"(",
")",
"{",
"return",
"m_Response",
";",
"}",
"public",
"void",
"setCheckingValidity",
"(",
"boolean",
"b",
")",
"{",
"m_ValidityCheck",
"=",
"b",
";",
"}",
"public",
"boolean",
"isCheckingValidity",
"(",
")",
"{",
"return",
"m_ValidityCheck",
";",
"}",
"public",
"int",
"getRetries",
"(",
")",
"{",
"return",
"m_Retries",
";",
"}",
"public",
"void",
"setRetries",
"(",
"int",
"num",
")",
"{",
"m_Retries",
"=",
"num",
";",
"}",
"/**\n * Get the TransDelayMS value.\n *\n * @return the TransDelayMS value.\n */",
"public",
"int",
"getTransDelayMS",
"(",
")",
"{",
"return",
"m_TransDelayMS",
";",
"}",
"/**\n * Set the TransDelayMS value.\n *\n * @param newTransDelayMS The new TransDelayMS value.\n */",
"public",
"void",
"setTransDelayMS",
"(",
"int",
"newTransDelayMS",
")",
"{",
"this",
".",
"m_TransDelayMS",
"=",
"newTransDelayMS",
";",
"}",
"public",
"void",
"execute",
"(",
")",
"throws",
"ModbusIOException",
",",
"ModbusSlaveException",
",",
"ModbusException",
"{",
"assertExecutable",
"(",
")",
";",
"try",
"{",
"/**\n * Note: The way this explicit synchronization is implemented at the moment,\n * there is no ordering of pending threads. The Mutex will simply call notify()\n * and the JVM will handle the rest.\n */",
"m_TransactionLock",
".",
"acquire",
"(",
")",
";",
"synchronized",
"(",
"m_IO",
")",
"{",
"int",
"tries",
"=",
"0",
";",
"boolean",
"finished",
"=",
"false",
";",
"m_Request",
".",
"setTransactionID",
"(",
"c_TransactionID",
".",
"increment",
"(",
")",
")",
";",
"do",
"{",
"try",
"{",
"if",
"(",
"m_TransDelayMS",
">",
"0",
")",
"{",
"try",
"{",
"Thread",
".",
"sleep",
"(",
"m_TransDelayMS",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"InterruptedException: ",
"\"",
"+",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"m_IO",
".",
"writeMessage",
"(",
"m_Request",
")",
";",
"m_Response",
"=",
"m_IO",
".",
"readResponse",
"(",
")",
";",
"finished",
"=",
"true",
";",
"}",
"catch",
"(",
"ModbusIOException",
"e",
")",
"{",
"if",
"(",
"++",
"tries",
">=",
"m_Retries",
")",
"{",
"throw",
"e",
";",
"}",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"execute try ",
"\"",
"+",
"tries",
"+",
"\"",
" error: ",
"\"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"while",
"(",
"!",
"finished",
")",
";",
"}",
"if",
"(",
"m_Response",
"instanceof",
"ExceptionResponse",
")",
"{",
"throw",
"new",
"ModbusSlaveException",
"(",
"(",
"(",
"ExceptionResponse",
")",
"m_Response",
")",
".",
"getExceptionCode",
"(",
")",
")",
";",
"}",
"if",
"(",
"isCheckingValidity",
"(",
")",
")",
"{",
"checkValidity",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"InterruptedException",
"ex",
")",
"{",
"throw",
"new",
"ModbusIOException",
"(",
"\"",
"Thread acquiring lock was interrupted.",
"\"",
")",
";",
"}",
"finally",
"{",
"m_TransactionLock",
".",
"release",
"(",
")",
";",
"}",
"}",
"/**\n * Asserts if this <tt>ModbusTCPTransaction</tt> is\n * executable.\n *\n * @throws ModbusException if the transaction cannot be asserted.\n */",
"private",
"void",
"assertExecutable",
"(",
")",
"throws",
"ModbusException",
"{",
"if",
"(",
"m_Request",
"==",
"null",
"||",
"m_SerialCon",
"==",
"null",
")",
"{",
"throw",
"new",
"ModbusException",
"(",
"\"",
"Assertion failed, transaction not executable",
"\"",
")",
";",
"}",
"}",
"/**\n * Checks the validity of the transaction, by\n * checking if the values of the response correspond\n * to the values of the request.\n *\n * @throws ModbusException if the transaction is not valid.\n */",
"protected",
"void",
"checkValidity",
"(",
")",
"throws",
"ModbusException",
"{",
"}",
"}"
] | Class implementing the <tt>ModbusTransaction</tt>
interface. | [
"Class",
"implementing",
"the",
"<tt",
">",
"ModbusTransaction<",
"/",
"tt",
">",
"interface",
"."
] | [
"//class attributes",
"//instance attributes and associations",
"//constructor",
"//constructor",
"//constructor",
"//setConnection",
"//getTransactionID",
"//m_Response = req.getResponse();",
"//setRequest",
"//getRequest",
"//getResponse",
"//setCheckingValidity",
"//isCheckingValidity",
"//getRetries",
"//setRetries",
"//1. assert executeability",
"//2. Lock transaction",
"//3. write request, and read response,",
"// while holding the lock on the IO object",
"//toggle the id",
"//write request message",
"//read response message",
"//4. deal with exceptions",
"//execute",
"//assertExecuteable",
"//checkValidity"
] | [
{
"param": "ModbusTransaction",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ModbusTransaction",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54e3f429ce8f8aae8b2b35657a3c2051e5f72372 | natpenguin/neo4j-ogm | neo4j-ogm-tests/neo4j-ogm-integration-tests/src/test/java/org/neo4j/ogm/domain/gh851/Flight.java | [
"ECL-2.0",
"Apache-2.0"
] | Java | Flight | /**
* @author Michael J. Simons
*/ | @author Michael J. Simons | [
"@author",
"Michael",
"J",
".",
"Simons"
] | @NodeEntity
public class Flight {
@Id
@GeneratedValue
Long id;
String name;
@Relationship(type = "DEPARTS")
Airport departure;
@Relationship(type = "ARRIVES")
Airport arrival;
public Flight() {
}
public Flight(String name, Airport departure, Airport arrival) {
this.name = name;
this.departure = departure;
this.arrival = arrival;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Airport getDeparture() {
return departure;
}
public void setDeparture(Airport departure) {
this.departure = departure;
}
public Airport getArrival() {
return arrival;
}
public void setArrival(Airport arrival) {
this.arrival = arrival;
}
} | [
"@",
"NodeEntity",
"public",
"class",
"Flight",
"{",
"@",
"Id",
"@",
"GeneratedValue",
"Long",
"id",
";",
"String",
"name",
";",
"@",
"Relationship",
"(",
"type",
"=",
"\"",
"DEPARTS",
"\"",
")",
"Airport",
"departure",
";",
"@",
"Relationship",
"(",
"type",
"=",
"\"",
"ARRIVES",
"\"",
")",
"Airport",
"arrival",
";",
"public",
"Flight",
"(",
")",
"{",
"}",
"public",
"Flight",
"(",
"String",
"name",
",",
"Airport",
"departure",
",",
"Airport",
"arrival",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"departure",
"=",
"departure",
";",
"this",
".",
"arrival",
"=",
"arrival",
";",
"}",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"public",
"Airport",
"getDeparture",
"(",
")",
"{",
"return",
"departure",
";",
"}",
"public",
"void",
"setDeparture",
"(",
"Airport",
"departure",
")",
"{",
"this",
".",
"departure",
"=",
"departure",
";",
"}",
"public",
"Airport",
"getArrival",
"(",
")",
"{",
"return",
"arrival",
";",
"}",
"public",
"void",
"setArrival",
"(",
"Airport",
"arrival",
")",
"{",
"this",
".",
"arrival",
"=",
"arrival",
";",
"}",
"}"
] | @author Michael J. Simons | [
"@author",
"Michael",
"J",
".",
"Simons"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54e631f11cf51367d558d74427246ea451b9e67a | longkehuawei/cai | app/src/main/java/com/C.java | [
"Apache-2.0"
] | Java | C | /**
* Created by baixiaokang on 16/4/23.
*/ | Created by baixiaokang on 16/4/23. | [
"Created",
"by",
"baixiaokang",
"on",
"16",
"/",
"4",
"/",
"23",
"."
] | public class C {
//==================API============//
public static final String X_LC_Id = "i7j2k7bm26g7csk7uuegxlvfyw79gkk4p200geei8jmaevmx";
public static final String X_LC_Key = "n6elpebcs84yjeaj5ht7x0eii9z83iea8bec9szerejj7zy3";
public static final String BASE_URL = "http://119.23.27.154:8088/cqssc/";
public static final String ADMIN_ID = "53d9076ce4b0ef69707fc78c";
public static final String ADMIN_FACE = "https://avatars0.githubusercontent.com/u/7598555?v=3&s=460";
//==================Base============//
public static final int PAGE_COUNT = 10;
public static final int FLAG_MULTI_VH = 0x000001;
public static final String OPEN_TYPE = "公开";
//==================intent============//
public static final String TRANSLATE_VIEW = "share_img";
public static final String TYPE = "type";
public static final String HEAD_DATA = "data";
public static final String VH_CLASS = "vh";
public static final int IMAGE_REQUEST_CODE = 100;
//==================API============//
public static final String _CREATED_AT = "-createdAt";
public static final String INCLUDE = "include";
public static final String CREATER = "creater";
public static final String UID = "uId";
public static final String PAGE = "page";
//==================Router============//
public static final String HOME = "home";
public static final String TAB = "tab";
public static final String ARTICLE = "article";
public static final String LOGIN = "login";
public static final String REGISTERT = "register";
public static final String ADVISE = "advise";
public static final String SETTING = "setting";
public static final String USER_INFO = "userInfo";
public static final String USER_RELEASE = "release";
public static final String OBJECT_ID = "objectId";
//==================static============//
public static MessageInfo getAdminMsg() {
MessageInfo mMessageInfo = new MessageInfo();
mMessageInfo.message = "您好,我是本应用的开发者North,如果您有什么好的建议和反馈,可以在这里和我直接对话,谢谢你的支持哦";
_User admin = new _User();
admin.username = "North";
admin.objectId = C.ADMIN_ID;
admin.face = ADMIN_FACE;
mMessageInfo.creater = admin;
return mMessageInfo;
}
public static String[] HOME_TABS = {"公开", "民谣", "摇滚", "电子", "流行", "爵士", "独立", "故事", "新世纪", "精品推荐", "原声"};
} | [
"public",
"class",
"C",
"{",
"public",
"static",
"final",
"String",
"X_LC_Id",
"=",
"\"",
"i7j2k7bm26g7csk7uuegxlvfyw79gkk4p200geei8jmaevmx",
"\"",
";",
"public",
"static",
"final",
"String",
"X_LC_Key",
"=",
"\"",
"n6elpebcs84yjeaj5ht7x0eii9z83iea8bec9szerejj7zy3",
"\"",
";",
"public",
"static",
"final",
"String",
"BASE_URL",
"=",
"\"",
"http://119.23.27.154:8088/cqssc/",
"\"",
";",
"public",
"static",
"final",
"String",
"ADMIN_ID",
"=",
"\"",
"53d9076ce4b0ef69707fc78c",
"\"",
";",
"public",
"static",
"final",
"String",
"ADMIN_FACE",
"=",
"\"",
"https://avatars0.githubusercontent.com/u/7598555?v=3&s=460",
"\"",
";",
"public",
"static",
"final",
"int",
"PAGE_COUNT",
"=",
"10",
";",
"public",
"static",
"final",
"int",
"FLAG_MULTI_VH",
"=",
"0x000001",
";",
"public",
"static",
"final",
"String",
"OPEN_TYPE",
"=",
"\"",
"公开\";",
"",
"",
"public",
"static",
"final",
"String",
"TRANSLATE_VIEW",
"=",
"\"",
"share_img",
"\"",
";",
"public",
"static",
"final",
"String",
"TYPE",
"=",
"\"",
"type",
"\"",
";",
"public",
"static",
"final",
"String",
"HEAD_DATA",
"=",
"\"",
"data",
"\"",
";",
"public",
"static",
"final",
"String",
"VH_CLASS",
"=",
"\"",
"vh",
"\"",
";",
"public",
"static",
"final",
"int",
"IMAGE_REQUEST_CODE",
"=",
"100",
";",
"public",
"static",
"final",
"String",
"_CREATED_AT",
"=",
"\"",
"-createdAt",
"\"",
";",
"public",
"static",
"final",
"String",
"INCLUDE",
"=",
"\"",
"include",
"\"",
";",
"public",
"static",
"final",
"String",
"CREATER",
"=",
"\"",
"creater",
"\"",
";",
"public",
"static",
"final",
"String",
"UID",
"=",
"\"",
"uId",
"\"",
";",
"public",
"static",
"final",
"String",
"PAGE",
"=",
"\"",
"page",
"\"",
";",
"public",
"static",
"final",
"String",
"HOME",
"=",
"\"",
"home",
"\"",
";",
"public",
"static",
"final",
"String",
"TAB",
"=",
"\"",
"tab",
"\"",
";",
"public",
"static",
"final",
"String",
"ARTICLE",
"=",
"\"",
"article",
"\"",
";",
"public",
"static",
"final",
"String",
"LOGIN",
"=",
"\"",
"login",
"\"",
";",
"public",
"static",
"final",
"String",
"REGISTERT",
"=",
"\"",
"register",
"\"",
";",
"public",
"static",
"final",
"String",
"ADVISE",
"=",
"\"",
"advise",
"\"",
";",
"public",
"static",
"final",
"String",
"SETTING",
"=",
"\"",
"setting",
"\"",
";",
"public",
"static",
"final",
"String",
"USER_INFO",
"=",
"\"",
"userInfo",
"\"",
";",
"public",
"static",
"final",
"String",
"USER_RELEASE",
"=",
"\"",
"release",
"\"",
";",
"public",
"static",
"final",
"String",
"OBJECT_ID",
"=",
"\"",
"objectId",
"\"",
";",
"public",
"static",
"MessageInfo",
"getAdminMsg",
"(",
")",
"{",
"MessageInfo",
"mMessageInfo",
"=",
"new",
"MessageInfo",
"(",
")",
";",
"mMessageInfo",
".",
"message",
"=",
"\"",
"您好,我是本应用的开发者North,如果您有什么好的建议和反馈,可以在这里和我直接对话,谢谢你的支持哦\";",
"",
"",
"_User",
"admin",
"=",
"new",
"_User",
"(",
")",
";",
"admin",
".",
"username",
"=",
"\"",
"North",
"\"",
";",
"admin",
".",
"objectId",
"=",
"C",
".",
"ADMIN_ID",
";",
"admin",
".",
"face",
"=",
"ADMIN_FACE",
";",
"mMessageInfo",
".",
"creater",
"=",
"admin",
";",
"return",
"mMessageInfo",
";",
"}",
"public",
"static",
"String",
"[",
"]",
"HOME_TABS",
"=",
"{",
"\"",
"公开\", \"",
"民",
"谣",
",",
" \"摇滚\",",
" ",
"\"",
"子",
"\", \"流行",
"\"",
",",
"\"",
"爵士\", \"",
"独",
"立",
",",
" \"故事\",",
" ",
"\"",
"世",
"纪\", \"精",
"品",
"推",
"\"",
", \"原声\"",
"}",
";",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"}"
] | Created by baixiaokang on 16/4/23. | [
"Created",
"by",
"baixiaokang",
"on",
"16",
"/",
"4",
"/",
"23",
"."
] | [
"//==================API============//",
"//==================Base============//",
"//==================intent============//",
"//==================API============//",
"//==================Router============//",
"//==================static============//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54e6a8199c0e88161a7503536cb67c4e0e063d5e | smolakalaLoginsoft/spring-boot-react-blog | blog-backend/src/main/java/me/ktkim/blog/service/CommentService.java | [
"Apache-2.0"
] | Java | CommentService | /**
* @author Kim Keumtae
*/ | @author Kim Keumtae | [
"@author",
"Kim",
"Keumtae"
] | @Service
@Transactional(noRollbackFor = {NullPointerException.class})
public class CommentService {
@Autowired
private CommentRepository commentRepository;
@Autowired
private PostRepository postRepository;
@PersistenceContext
protected EntityManager entityManager;
public Optional<Comment> findForId(Long id) {
return commentRepository.findById(id);
}
public Optional<Post> findPostForId(Long id) {
return postRepository.findById(id);
}
public Optional<List<Comment>> findCommentsByPostId(Long id) {
return commentRepository.findByPostId(id);
}
public CommentDto registerComment(CommentDto commentDto, CustomUserDetails customUserDetails) {
Optional<Post> postForId = this.findPostForId(commentDto.getPostId());
if (postForId.isPresent()) {
Comment newComment = new Comment();
newComment.setBody(commentDto.getBody());
newComment.setPost(postForId.get());
newComment.setUser(new User(customUserDetails.getId(), customUserDetails.getName()));
registerComment(newComment);
return new CommentDto(newComment);
} else {
throw new BadRequestException("Not exist post.");
}
}
public void registerComment(Comment comment) {
String sql2 = "INSERT INTO COMMENT(COMMENT_ID, BODY, CREATED_DATE, LAST_MODIFIED_DATE, POST_ID, USER_ID) VALUES(null, '" + comment.getBody() + "', '" + comment.getCreatedDate() + "', '" + comment.getLastModifiedDate() + "', " + comment.getPost().getId() + ", " + comment.getUser().getId() + ");";
Query query = entityManager.createNativeQuery(sql2);
query.executeUpdate();
}
public Optional<CommentDto> editPost(CommentDto editCommentDto) {
return this.findForId(editCommentDto.getId())
.map(comment -> {
comment.setBody(editCommentDto.getBody());
return comment;
})
.map(CommentDto::new);
}
public void deletePost(Long id) {
commentRepository.findById(id).ifPresent(comment -> {
commentRepository.delete(comment);
});
}
} | [
"@",
"Service",
"@",
"Transactional",
"(",
"noRollbackFor",
"=",
"{",
"NullPointerException",
".",
"class",
"}",
")",
"public",
"class",
"CommentService",
"{",
"@",
"Autowired",
"private",
"CommentRepository",
"commentRepository",
";",
"@",
"Autowired",
"private",
"PostRepository",
"postRepository",
";",
"@",
"PersistenceContext",
"protected",
"EntityManager",
"entityManager",
";",
"public",
"Optional",
"<",
"Comment",
">",
"findForId",
"(",
"Long",
"id",
")",
"{",
"return",
"commentRepository",
".",
"findById",
"(",
"id",
")",
";",
"}",
"public",
"Optional",
"<",
"Post",
">",
"findPostForId",
"(",
"Long",
"id",
")",
"{",
"return",
"postRepository",
".",
"findById",
"(",
"id",
")",
";",
"}",
"public",
"Optional",
"<",
"List",
"<",
"Comment",
">",
">",
"findCommentsByPostId",
"(",
"Long",
"id",
")",
"{",
"return",
"commentRepository",
".",
"findByPostId",
"(",
"id",
")",
";",
"}",
"public",
"CommentDto",
"registerComment",
"(",
"CommentDto",
"commentDto",
",",
"CustomUserDetails",
"customUserDetails",
")",
"{",
"Optional",
"<",
"Post",
">",
"postForId",
"=",
"this",
".",
"findPostForId",
"(",
"commentDto",
".",
"getPostId",
"(",
")",
")",
";",
"if",
"(",
"postForId",
".",
"isPresent",
"(",
")",
")",
"{",
"Comment",
"newComment",
"=",
"new",
"Comment",
"(",
")",
";",
"newComment",
".",
"setBody",
"(",
"commentDto",
".",
"getBody",
"(",
")",
")",
";",
"newComment",
".",
"setPost",
"(",
"postForId",
".",
"get",
"(",
")",
")",
";",
"newComment",
".",
"setUser",
"(",
"new",
"User",
"(",
"customUserDetails",
".",
"getId",
"(",
")",
",",
"customUserDetails",
".",
"getName",
"(",
")",
")",
")",
";",
"registerComment",
"(",
"newComment",
")",
";",
"return",
"new",
"CommentDto",
"(",
"newComment",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"",
"Not exist post.",
"\"",
")",
";",
"}",
"}",
"public",
"void",
"registerComment",
"(",
"Comment",
"comment",
")",
"{",
"String",
"sql2",
"=",
"\"",
"INSERT INTO COMMENT(COMMENT_ID, BODY, CREATED_DATE, LAST_MODIFIED_DATE, POST_ID, USER_ID) VALUES(null, '",
"\"",
"+",
"comment",
".",
"getBody",
"(",
")",
"+",
"\"",
"', '",
"\"",
"+",
"comment",
".",
"getCreatedDate",
"(",
")",
"+",
"\"",
"', '",
"\"",
"+",
"comment",
".",
"getLastModifiedDate",
"(",
")",
"+",
"\"",
"', ",
"\"",
"+",
"comment",
".",
"getPost",
"(",
")",
".",
"getId",
"(",
")",
"+",
"\"",
", ",
"\"",
"+",
"comment",
".",
"getUser",
"(",
")",
".",
"getId",
"(",
")",
"+",
"\"",
");",
"\"",
";",
"Query",
"query",
"=",
"entityManager",
".",
"createNativeQuery",
"(",
"sql2",
")",
";",
"query",
".",
"executeUpdate",
"(",
")",
";",
"}",
"public",
"Optional",
"<",
"CommentDto",
">",
"editPost",
"(",
"CommentDto",
"editCommentDto",
")",
"{",
"return",
"this",
".",
"findForId",
"(",
"editCommentDto",
".",
"getId",
"(",
")",
")",
".",
"map",
"(",
"comment",
"->",
"{",
"comment",
".",
"setBody",
"(",
"editCommentDto",
".",
"getBody",
"(",
")",
")",
";",
"return",
"comment",
";",
"}",
")",
".",
"map",
"(",
"CommentDto",
"::",
"new",
")",
";",
"}",
"public",
"void",
"deletePost",
"(",
"Long",
"id",
")",
"{",
"commentRepository",
".",
"findById",
"(",
"id",
")",
".",
"ifPresent",
"(",
"comment",
"->",
"{",
"commentRepository",
".",
"delete",
"(",
"comment",
")",
";",
"}",
")",
";",
"}",
"}"
] | @author Kim Keumtae | [
"@author",
"Kim",
"Keumtae"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54e854e9ead199cd8f577e646008e6f2a77d0e67 | adrenalinee/cinnamon | cinnamon-core-web/src/main/java/org/cinnamon/core/web/restController/UserGroupRestController.java | [
"MIT"
] | Java | UserGroupRestController | /**
*
* @author shindongseong
* @since 2015. 12. 25.
*/ | @author shindongseong
@since 2015. 12. 25. | [
"@author",
"shindongseong",
"@since",
"2015",
".",
"12",
".",
"25",
"."
] | @RestController
@RequestMapping("/rest/configuration/userGroups")
public class UserGroupRestController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private UserGroupService<UserBase> userGroupService;
/**
*
* @param userGroupVo
* @param builder
* @return
*/
@RequestMapping(value="", method=RequestMethod.POST)
ResponseEntity<Void> postUserGroups(@RequestBody @Valid UserGroupVo userGroupVo, UriComponentsBuilder builder) {
logger.info("String");
UserGroup userGroup = userGroupService.save(userGroupVo);
URI location = MvcUriComponentsBuilder
.fromMethodName(
builder,
UserGroupRestController.class,
"getUserGroup",
userGroup.getUserGroupId())
.build()
.toUri();
return ResponseEntity
.created(location)
.build();
}
/**
*
* @param userGroupSearch
* @param pageable
* @return
*/
@RequestMapping(value="", method=RequestMethod.GET)
Page<UserGroup> getUserGroups(UserGroupSearch userGroupSearch, Pageable pageable) {
logger.info("String");
return userGroupService.getList(userGroupSearch, pageable);
}
/**
*
* @param userGroupId
* @return
*/
@RequestMapping(value="{userGroupId}", method=RequestMethod.GET)
UserGroup getUserGroup(@PathVariable Long userGroupId) {
logger.info("String");
return userGroupService.get(userGroupId);
}
/**
*
* @param userGroupId
* @param userGroupVo
*/
@RequestMapping(value="{userGroupId}", method=RequestMethod.PUT)
void putUserGroup(@PathVariable Long userGroupId, @RequestBody @Valid UserGroupVo userGroupVo) {
logger.info("String");
userGroupService.modify(userGroupId, userGroupVo);
}
/**
*
* @param userGroupId
* @param permissionId
*/
@RequestMapping(value="{userGroupId}/permission/{permissionId}")
void submitUserPermission(@PathVariable Long userGroupId, @PathVariable Long permissionId) {
logger.info("start");
userGroupService.submitUserGroupToPermission(userGroupId, permissionId);
}
} | [
"@",
"RestController",
"@",
"RequestMapping",
"(",
"\"",
"/rest/configuration/userGroups",
"\"",
")",
"public",
"class",
"UserGroupRestController",
"{",
"private",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"getClass",
"(",
")",
")",
";",
"@",
"Autowired",
"private",
"UserGroupService",
"<",
"UserBase",
">",
"userGroupService",
";",
"/**\n\t * \n\t * @param userGroupVo\n\t * @param builder\n\t * @return\n\t */",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"",
"\"",
",",
"method",
"=",
"RequestMethod",
".",
"POST",
")",
"ResponseEntity",
"<",
"Void",
">",
"postUserGroups",
"(",
"@",
"RequestBody",
"@",
"Valid",
"UserGroupVo",
"userGroupVo",
",",
"UriComponentsBuilder",
"builder",
")",
"{",
"logger",
".",
"info",
"(",
"\"",
"String",
"\"",
")",
";",
"UserGroup",
"userGroup",
"=",
"userGroupService",
".",
"save",
"(",
"userGroupVo",
")",
";",
"URI",
"location",
"=",
"MvcUriComponentsBuilder",
".",
"fromMethodName",
"(",
"builder",
",",
"UserGroupRestController",
".",
"class",
",",
"\"",
"getUserGroup",
"\"",
",",
"userGroup",
".",
"getUserGroupId",
"(",
")",
")",
".",
"build",
"(",
")",
".",
"toUri",
"(",
")",
";",
"return",
"ResponseEntity",
".",
"created",
"(",
"location",
")",
".",
"build",
"(",
")",
";",
"}",
"/**\n\t * \n\t * @param userGroupSearch\n\t * @param pageable\n\t * @return\n\t */",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"",
"\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"Page",
"<",
"UserGroup",
">",
"getUserGroups",
"(",
"UserGroupSearch",
"userGroupSearch",
",",
"Pageable",
"pageable",
")",
"{",
"logger",
".",
"info",
"(",
"\"",
"String",
"\"",
")",
";",
"return",
"userGroupService",
".",
"getList",
"(",
"userGroupSearch",
",",
"pageable",
")",
";",
"}",
"/**\n\t * \n\t * @param userGroupId\n\t * @return\n\t */",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"",
"{userGroupId}",
"\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"UserGroup",
"getUserGroup",
"(",
"@",
"PathVariable",
"Long",
"userGroupId",
")",
"{",
"logger",
".",
"info",
"(",
"\"",
"String",
"\"",
")",
";",
"return",
"userGroupService",
".",
"get",
"(",
"userGroupId",
")",
";",
"}",
"/**\n\t * \n\t * @param userGroupId\n\t * @param userGroupVo\n\t */",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"",
"{userGroupId}",
"\"",
",",
"method",
"=",
"RequestMethod",
".",
"PUT",
")",
"void",
"putUserGroup",
"(",
"@",
"PathVariable",
"Long",
"userGroupId",
",",
"@",
"RequestBody",
"@",
"Valid",
"UserGroupVo",
"userGroupVo",
")",
"{",
"logger",
".",
"info",
"(",
"\"",
"String",
"\"",
")",
";",
"userGroupService",
".",
"modify",
"(",
"userGroupId",
",",
"userGroupVo",
")",
";",
"}",
"/**\n\t * \n\t * @param userGroupId\n\t * @param permissionId\n\t */",
"@",
"RequestMapping",
"(",
"value",
"=",
"\"",
"{userGroupId}/permission/{permissionId}",
"\"",
")",
"void",
"submitUserPermission",
"(",
"@",
"PathVariable",
"Long",
"userGroupId",
",",
"@",
"PathVariable",
"Long",
"permissionId",
")",
"{",
"logger",
".",
"info",
"(",
"\"",
"start",
"\"",
")",
";",
"userGroupService",
".",
"submitUserGroupToPermission",
"(",
"userGroupId",
",",
"permissionId",
")",
";",
"}",
"}"
] | @author shindongseong
@since 2015. | [
"@author",
"shindongseong",
"@since",
"2015",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54e91372d5bcc78cc55355637118b68ec580f860 | milexm/aws-client-ec2 | src/main/java/com/acloudysky/ec2/Main.java | [
"BSD-2-Clause"
] | Java | Main | /**
* Instantiates the authenticated EC2 service client, initializes the operations and the UI classes.
* Before running the code, you need to set up your AWS security credentials. You can do this by creating a
* file named "credentials" at ~/.aws/ (C:\Users\USER_NAME\.aws\ for Windows users) and saving the following lines in
* the file:
*<pre>
*[default]
* aws_access_key_id = your access key id
* aws_secret_access_key = your secret key
*</pre>
*<p>
* For more information, see <a href="http://docs.aws.amazon.com/AWSSdkDocsJava/latest/DeveloperGuide/credentials.html" target="_blank">Providing AWS Credentials in the AWS SDK for Java</a>
* and <a href="https://console.aws.amazon.com/iam/home?#security_credential" target="_blank">Welcome to Identity and Access Management</a>.
* </p>
* <b>WARNING</b>: To avoid accidental leakage of your credentials, DO NOT keep the credentials file in your source directory.
* @author Michael Miele
*/ | Instantiates the authenticated EC2 service client, initializes the operations and the UI classes.
Before running the code, you need to set up your AWS security credentials. You can do this by creating a
file named "credentials" at ~/.aws/ (C:\Users\USER_NAME\.aws\ for Windows users) and saving the following lines in
the file:
[default]
aws_access_key_id = your access key id
aws_secret_access_key = your secret key
For more information, see Providing AWS Credentials in the AWS SDK for Java
and Welcome to Identity and Access Management.
WARNING: To avoid accidental leakage of your credentials, DO NOT keep the credentials file in your source directory.
@author Michael Miele | [
"Instantiates",
"the",
"authenticated",
"EC2",
"service",
"client",
"initializes",
"the",
"operations",
"and",
"the",
"UI",
"classes",
".",
"Before",
"running",
"the",
"code",
"you",
"need",
"to",
"set",
"up",
"your",
"AWS",
"security",
"credentials",
".",
"You",
"can",
"do",
"this",
"by",
"creating",
"a",
"file",
"named",
"\"",
"credentials",
"\"",
"at",
"~",
"/",
".",
"aws",
"/",
"(",
"C",
":",
"\\",
"Users",
"\\",
"USER_NAME",
"\\",
".",
"aws",
"\\",
"for",
"Windows",
"users",
")",
"and",
"saving",
"the",
"following",
"lines",
"in",
"the",
"file",
":",
"[",
"default",
"]",
"aws_access_key_id",
"=",
"your",
"access",
"key",
"id",
"aws_secret_access_key",
"=",
"your",
"secret",
"key",
"For",
"more",
"information",
"see",
"Providing",
"AWS",
"Credentials",
"in",
"the",
"AWS",
"SDK",
"for",
"Java",
"and",
"Welcome",
"to",
"Identity",
"and",
"Access",
"Management",
".",
"WARNING",
":",
"To",
"avoid",
"accidental",
"leakage",
"of",
"your",
"credentials",
"DO",
"NOT",
"keep",
"the",
"credentials",
"file",
"in",
"your",
"source",
"directory",
".",
"@author",
"Michael",
"Miele"
] | public class Main {
// Debug flag to use for testing purposes.
public static boolean DEBUG = false;
private static SimpleUI sui;
// Authenticated EC2 client.
private static AmazonEC2 ec2Client = null;
// Selected region. String value such as "us-west-2".
private static String region = null;
// Selected EC2 region. Enumerated value.
private static Regions currentRegion;
/**
* Instantiates the EC2 client and initializes the operation class.
* Instantiates the SimpleUI class to display the selection menu and process the user's input.
* @see SimpleUI#SimpleUI(AmazonEC2)
* @see EC2Operations#InitEC2Operations(AmazonEC2)
* @param args;
* args[0] = The EC2 region, for instance "us-west-2". Notice only US regions are allowed.
*
*/
public static void main(String[] args) {
// Display application menu.
Utility.displayWelcomeMessage("AWS EC2");
// Read input parameters.
try {
region = args[0];
// System.out.println(region);
}
catch (Exception e) {
System.out.println("IO error trying to read application input! Assigning default values.");
// Assign default values if none are passed.
if (args.length==0) {
region = "us-west-2";
}
else {
System.out.println("IO error trying to read application input!");
System.exit(1);
}
}
try {
// Instantiate the AuthenticateAwsServiceClient class.
AuthenticateAwsServiceClient authClient = new AuthenticateAwsServiceClient();
// Get the region enum value.
currentRegion = Utility.getRegion(region);
// Get the authenticated client.
if (currentRegion != null)
ec2Client = authClient.getAuthenticatedEC2Client(currentRegion);
}
catch (AmazonServiceException ase) {
StringBuffer err = new StringBuffer();
err.append(("Caught an AmazonServiceException, which means your request made it "
+ "to Amazon EC2, but was rejected with an error response for some reason."));
err.append(String.format("%n Error Message: %s %n", ase.getMessage()));
err.append(String.format(" HTTP Status Code: %s %n", ase.getStatusCode()));
err.append(String.format(" AWS Error Code: %s %n", ase.getErrorCode()));
err.append(String.format(" Error Type: %s %n", ase.getErrorType()));
err.append(String.format(" Request ID: %s %n", ase.getRequestId()));
System.out.println(err.toString());
}
catch (AmazonClientException ace) {
System.out.println("Caught an AmazonClientException, which means the client encountered "
+ "a serious internal problem while trying to communicate with EC2 , "
+ "such as not being able to access the network.");
System.out.println("Error Message: " + ace.getMessage());
}
if (ec2Client != null) {
// Initialize the EC2Operations class to handle EC2 REST API calls.
EC2Operations.InitEC2Operations(ec2Client);
if (DEBUG)
System.out.println("Main: Ec2 client " + ec2Client.toString());
// Instantiate SmpleUI class.
sui = new SimpleUI(ec2Client);
// Process user's input.
sui.processUserInput();
}
else
String.format("Error %s", "Main: authorized EC2 client object is null.");
Utility.displayGoodbyeMessage("AWS EC2");
}
} | [
"public",
"class",
"Main",
"{",
"public",
"static",
"boolean",
"DEBUG",
"=",
"false",
";",
"private",
"static",
"SimpleUI",
"sui",
";",
"private",
"static",
"AmazonEC2",
"ec2Client",
"=",
"null",
";",
"private",
"static",
"String",
"region",
"=",
"null",
";",
"private",
"static",
"Regions",
"currentRegion",
";",
"/**\r\n\t * Instantiates the EC2 client and initializes the operation class. \r\n\t * Instantiates the SimpleUI class to display the selection menu and process the user's input. \r\n\t * @see SimpleUI#SimpleUI(AmazonEC2) \r\n\t * @see EC2Operations#InitEC2Operations(AmazonEC2)\r\n\t * @param args; \r\n\t * \t\targs[0] = The EC2 region, for instance \"us-west-2\". Notice only US regions are allowed. \r\n\t * \r\n\t */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"Utility",
".",
"displayWelcomeMessage",
"(",
"\"",
"AWS EC2",
"\"",
")",
";",
"try",
"{",
"region",
"=",
"args",
"[",
"0",
"]",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"IO error trying to read application input! Assigning default values.",
"\"",
")",
";",
"if",
"(",
"args",
".",
"length",
"==",
"0",
")",
"{",
"region",
"=",
"\"",
"us-west-2",
"\"",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"IO error trying to read application input!",
"\"",
")",
";",
"System",
".",
"exit",
"(",
"1",
")",
";",
"}",
"}",
"try",
"{",
"AuthenticateAwsServiceClient",
"authClient",
"=",
"new",
"AuthenticateAwsServiceClient",
"(",
")",
";",
"currentRegion",
"=",
"Utility",
".",
"getRegion",
"(",
"region",
")",
";",
"if",
"(",
"currentRegion",
"!=",
"null",
")",
"ec2Client",
"=",
"authClient",
".",
"getAuthenticatedEC2Client",
"(",
"currentRegion",
")",
";",
"}",
"catch",
"(",
"AmazonServiceException",
"ase",
")",
"{",
"StringBuffer",
"err",
"=",
"new",
"StringBuffer",
"(",
")",
";",
"err",
".",
"append",
"(",
"(",
"\"",
"Caught an AmazonServiceException, which means your request made it ",
"\"",
"+",
"\"",
"to Amazon EC2, but was rejected with an error response for some reason.",
"\"",
")",
")",
";",
"err",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"",
"%n Error Message: %s %n",
"\"",
",",
"ase",
".",
"getMessage",
"(",
")",
")",
")",
";",
"err",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"",
" HTTP Status Code: %s %n",
"\"",
",",
"ase",
".",
"getStatusCode",
"(",
")",
")",
")",
";",
"err",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"",
" AWS Error Code: %s %n",
"\"",
",",
"ase",
".",
"getErrorCode",
"(",
")",
")",
")",
";",
"err",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"",
" Error Type: %s %n",
"\"",
",",
"ase",
".",
"getErrorType",
"(",
")",
")",
")",
";",
"err",
".",
"append",
"(",
"String",
".",
"format",
"(",
"\"",
" Request ID: %s %n",
"\"",
",",
"ase",
".",
"getRequestId",
"(",
")",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"err",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"AmazonClientException",
"ace",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Caught an AmazonClientException, which means the client encountered ",
"\"",
"+",
"\"",
"a serious internal problem while trying to communicate with EC2 , ",
"\"",
"+",
"\"",
"such as not being able to access the network.",
"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error Message: ",
"\"",
"+",
"ace",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"ec2Client",
"!=",
"null",
")",
"{",
"EC2Operations",
".",
"InitEC2Operations",
"(",
"ec2Client",
")",
";",
"if",
"(",
"DEBUG",
")",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Main: Ec2 client ",
"\"",
"+",
"ec2Client",
".",
"toString",
"(",
")",
")",
";",
"sui",
"=",
"new",
"SimpleUI",
"(",
"ec2Client",
")",
";",
"sui",
".",
"processUserInput",
"(",
")",
";",
"}",
"else",
"String",
".",
"format",
"(",
"\"",
"Error %s",
"\"",
",",
"\"",
"Main: authorized EC2 client object is null.",
"\"",
")",
";",
"Utility",
".",
"displayGoodbyeMessage",
"(",
"\"",
"AWS EC2",
"\"",
")",
";",
"}",
"}"
] | Instantiates the authenticated EC2 service client, initializes the operations and the UI classes. | [
"Instantiates",
"the",
"authenticated",
"EC2",
"service",
"client",
"initializes",
"the",
"operations",
"and",
"the",
"UI",
"classes",
"."
] | [
"// Debug flag to use for testing purposes.\r",
"// Authenticated EC2 client.\r",
"// Selected region. String value such as \"us-west-2\".\r",
"// Selected EC2 region. Enumerated value.\r",
"// Display application menu.\r",
"// Read input parameters.\r",
"// System.out.println(region);\r",
"// Assign default values if none are passed.\r",
"// Instantiate the AuthenticateAwsServiceClient class. \r",
"// Get the region enum value. \r",
"// Get the authenticated client. \r",
"// Initialize the EC2Operations class to handle EC2 REST API calls.\r",
"// Instantiate SmpleUI class.\r",
"// Process user's input.\r"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54e9a5b121a8d5a1e3864ed7ee549ae5bf69a8fd | mikeluxue/hibernate-validator | engine/src/main/java/org/hibernate/validator/internal/cfg/context/ParameterConstraintMappingContextImpl.java | [
"Apache-2.0"
] | Java | ParameterConstraintMappingContextImpl | /**
* Constraint mapping creational context which allows to configure the constraints for one method parameter.
*
* @author Hardy Ferentschik
* @author Gunnar Morling
* @author Kevin Pollet <[email protected]> (C) 2011 SERLI
*/ | Constraint mapping creational context which allows to configure the constraints for one method parameter.
@author Hardy Ferentschik
@author Gunnar Morling
@author Kevin Pollet <[email protected]> (C) 2011 SERLI | [
"Constraint",
"mapping",
"creational",
"context",
"which",
"allows",
"to",
"configure",
"the",
"constraints",
"for",
"one",
"method",
"parameter",
".",
"@author",
"Hardy",
"Ferentschik",
"@author",
"Gunnar",
"Morling",
"@author",
"Kevin",
"Pollet",
"<kevin",
".",
"pollet@serli",
".",
"com",
">",
"(",
"C",
")",
"2011",
"SERLI"
] | final class ParameterConstraintMappingContextImpl
extends CascadableConstraintMappingContextImplBase<ParameterConstraintMappingContext>
implements ParameterConstraintMappingContext {
private final ExecutableConstraintMappingContextImpl executableContext;
private final int parameterIndex;
ParameterConstraintMappingContextImpl(ExecutableConstraintMappingContextImpl executableContext, int parameterIndex) {
super( executableContext.getTypeContext().getConstraintMapping() );
this.executableContext = executableContext;
this.parameterIndex = parameterIndex;
}
@Override
protected ParameterConstraintMappingContext getThis() {
return this;
}
@Override
public ParameterConstraintMappingContext constraint(ConstraintDef<?, ?> definition) {
super.addConstraint(
ConfiguredConstraint.forParameter(
definition,
executableContext.getExecutable(),
parameterIndex
)
);
return this;
}
@Override
public ParameterConstraintMappingContext parameter(int index) {
return executableContext.parameter( index );
}
@Override
public CrossParameterConstraintMappingContext crossParameter() {
return executableContext.crossParameter();
}
@Override
public ReturnValueConstraintMappingContext returnValue() {
return executableContext.returnValue();
}
@Override
public ConstructorConstraintMappingContext constructor(Class<?>... parameterTypes) {
return executableContext.getTypeContext().constructor( parameterTypes );
}
@Override
public MethodConstraintMappingContext method(String name, Class<?>... parameterTypes) {
return executableContext.getTypeContext().method( name, parameterTypes );
}
public ConstrainedParameter build(ConstraintHelper constraintHelper, ParameterNameProvider parameterNameProvider) {
return new ConstrainedParameter(
ConfigurationSource.API,
ConstraintLocation.forParameter( executableContext.getExecutable(), parameterIndex ),
ReflectionHelper.typeOf( executableContext.getExecutable(), parameterIndex ),
parameterIndex,
executableContext.getExecutable().getParameterNames( parameterNameProvider ).get( parameterIndex ),
getConstraints( constraintHelper ),
groupConversions,
isCascading,
isUnwrapValidatedValue()
);
}
@Override
protected ConstraintType getConstraintType() {
return ConstraintType.GENERIC;
}
} | [
"final",
"class",
"ParameterConstraintMappingContextImpl",
"extends",
"CascadableConstraintMappingContextImplBase",
"<",
"ParameterConstraintMappingContext",
">",
"implements",
"ParameterConstraintMappingContext",
"{",
"private",
"final",
"ExecutableConstraintMappingContextImpl",
"executableContext",
";",
"private",
"final",
"int",
"parameterIndex",
";",
"ParameterConstraintMappingContextImpl",
"(",
"ExecutableConstraintMappingContextImpl",
"executableContext",
",",
"int",
"parameterIndex",
")",
"{",
"super",
"(",
"executableContext",
".",
"getTypeContext",
"(",
")",
".",
"getConstraintMapping",
"(",
")",
")",
";",
"this",
".",
"executableContext",
"=",
"executableContext",
";",
"this",
".",
"parameterIndex",
"=",
"parameterIndex",
";",
"}",
"@",
"Override",
"protected",
"ParameterConstraintMappingContext",
"getThis",
"(",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"ParameterConstraintMappingContext",
"constraint",
"(",
"ConstraintDef",
"<",
"?",
",",
"?",
">",
"definition",
")",
"{",
"super",
".",
"addConstraint",
"(",
"ConfiguredConstraint",
".",
"forParameter",
"(",
"definition",
",",
"executableContext",
".",
"getExecutable",
"(",
")",
",",
"parameterIndex",
")",
")",
";",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"ParameterConstraintMappingContext",
"parameter",
"(",
"int",
"index",
")",
"{",
"return",
"executableContext",
".",
"parameter",
"(",
"index",
")",
";",
"}",
"@",
"Override",
"public",
"CrossParameterConstraintMappingContext",
"crossParameter",
"(",
")",
"{",
"return",
"executableContext",
".",
"crossParameter",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"ReturnValueConstraintMappingContext",
"returnValue",
"(",
")",
"{",
"return",
"executableContext",
".",
"returnValue",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"ConstructorConstraintMappingContext",
"constructor",
"(",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"{",
"return",
"executableContext",
".",
"getTypeContext",
"(",
")",
".",
"constructor",
"(",
"parameterTypes",
")",
";",
"}",
"@",
"Override",
"public",
"MethodConstraintMappingContext",
"method",
"(",
"String",
"name",
",",
"Class",
"<",
"?",
">",
"...",
"parameterTypes",
")",
"{",
"return",
"executableContext",
".",
"getTypeContext",
"(",
")",
".",
"method",
"(",
"name",
",",
"parameterTypes",
")",
";",
"}",
"public",
"ConstrainedParameter",
"build",
"(",
"ConstraintHelper",
"constraintHelper",
",",
"ParameterNameProvider",
"parameterNameProvider",
")",
"{",
"return",
"new",
"ConstrainedParameter",
"(",
"ConfigurationSource",
".",
"API",
",",
"ConstraintLocation",
".",
"forParameter",
"(",
"executableContext",
".",
"getExecutable",
"(",
")",
",",
"parameterIndex",
")",
",",
"ReflectionHelper",
".",
"typeOf",
"(",
"executableContext",
".",
"getExecutable",
"(",
")",
",",
"parameterIndex",
")",
",",
"parameterIndex",
",",
"executableContext",
".",
"getExecutable",
"(",
")",
".",
"getParameterNames",
"(",
"parameterNameProvider",
")",
".",
"get",
"(",
"parameterIndex",
")",
",",
"getConstraints",
"(",
"constraintHelper",
")",
",",
"groupConversions",
",",
"isCascading",
",",
"isUnwrapValidatedValue",
"(",
")",
")",
";",
"}",
"@",
"Override",
"protected",
"ConstraintType",
"getConstraintType",
"(",
")",
"{",
"return",
"ConstraintType",
".",
"GENERIC",
";",
"}",
"}"
] | Constraint mapping creational context which allows to configure the constraints for one method parameter. | [
"Constraint",
"mapping",
"creational",
"context",
"which",
"allows",
"to",
"configure",
"the",
"constraints",
"for",
"one",
"method",
"parameter",
"."
] | [] | [
{
"param": "ParameterConstraintMappingContext",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ParameterConstraintMappingContext",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54ea1db19911b89f4eb2651d196df335176922a3 | erkreddy/androidsensor | SensorSimulator/src/org/openintents/tools/simulator/controller/StateControllerSmall.java | [
"Apache-2.0"
] | Java | StateControllerSmall | /**
* Controller of a state from the scenario grid.
* @author ilarele
*
*/ | Controller of a state from the scenario grid.
@author ilarele | [
"Controller",
"of",
"a",
"state",
"from",
"the",
"scenario",
"grid",
".",
"@author",
"ilarele"
] | public class StateControllerSmall {
private StateViewSmall mView;
private StateModel mModel;
private SensorsScenarioView mSensorScenarioView;
private SensorsScenarioModel mSensorScenarioModel;
private SensorsScenarioController mSensorScenarioController;
public StateControllerSmall(
SensorsScenarioController sensorsScenarioController,
StateModel stateModel, StateViewSmall stateView) {
mModel = stateModel;
mView = stateView;
mSensorScenarioController = sensorsScenarioController;
mSensorScenarioView = sensorsScenarioController.getView();
mSensorScenarioModel = sensorsScenarioController.getModel();
initListeners();
}
private void initListeners() {
JButton deleteBtn = mView.getDeleteBtn();
deleteBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
mSensorScenarioModel.remove(mModel);
mSensorScenarioView.removeView(mView);
}
});
JButton editBtn = mView.getEditBtn();
editBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
// open big view
mSensorScenarioView.showBigView(mModel, mView);
}
});
JButton addBtn = mView.getAddBtn();
addBtn.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
StateModel newModel = new StateModel(mModel);
int position = mSensorScenarioView.indexOfView(mView);
position++;
mSensorScenarioModel.add(position, newModel);
mSensorScenarioModel.setCurrentPosition(position);
StateViewSmall stateView = new StateViewSmall(newModel,
mSensorScenarioView);
new StateControllerSmall(mSensorScenarioController, newModel,
stateView);
mSensorScenarioController.setJustAdded();
mSensorScenarioView.addView(position, stateView);
}
});
}
} | [
"public",
"class",
"StateControllerSmall",
"{",
"private",
"StateViewSmall",
"mView",
";",
"private",
"StateModel",
"mModel",
";",
"private",
"SensorsScenarioView",
"mSensorScenarioView",
";",
"private",
"SensorsScenarioModel",
"mSensorScenarioModel",
";",
"private",
"SensorsScenarioController",
"mSensorScenarioController",
";",
"public",
"StateControllerSmall",
"(",
"SensorsScenarioController",
"sensorsScenarioController",
",",
"StateModel",
"stateModel",
",",
"StateViewSmall",
"stateView",
")",
"{",
"mModel",
"=",
"stateModel",
";",
"mView",
"=",
"stateView",
";",
"mSensorScenarioController",
"=",
"sensorsScenarioController",
";",
"mSensorScenarioView",
"=",
"sensorsScenarioController",
".",
"getView",
"(",
")",
";",
"mSensorScenarioModel",
"=",
"sensorsScenarioController",
".",
"getModel",
"(",
")",
";",
"initListeners",
"(",
")",
";",
"}",
"private",
"void",
"initListeners",
"(",
")",
"{",
"JButton",
"deleteBtn",
"=",
"mView",
".",
"getDeleteBtn",
"(",
")",
";",
"deleteBtn",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"mSensorScenarioModel",
".",
"remove",
"(",
"mModel",
")",
";",
"mSensorScenarioView",
".",
"removeView",
"(",
"mView",
")",
";",
"}",
"}",
")",
";",
"JButton",
"editBtn",
"=",
"mView",
".",
"getEditBtn",
"(",
")",
";",
"editBtn",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"mSensorScenarioView",
".",
"showBigView",
"(",
"mModel",
",",
"mView",
")",
";",
"}",
"}",
")",
";",
"JButton",
"addBtn",
"=",
"mView",
".",
"getAddBtn",
"(",
")",
";",
"addBtn",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"e",
")",
"{",
"StateModel",
"newModel",
"=",
"new",
"StateModel",
"(",
"mModel",
")",
";",
"int",
"position",
"=",
"mSensorScenarioView",
".",
"indexOfView",
"(",
"mView",
")",
";",
"position",
"++",
";",
"mSensorScenarioModel",
".",
"add",
"(",
"position",
",",
"newModel",
")",
";",
"mSensorScenarioModel",
".",
"setCurrentPosition",
"(",
"position",
")",
";",
"StateViewSmall",
"stateView",
"=",
"new",
"StateViewSmall",
"(",
"newModel",
",",
"mSensorScenarioView",
")",
";",
"new",
"StateControllerSmall",
"(",
"mSensorScenarioController",
",",
"newModel",
",",
"stateView",
")",
";",
"mSensorScenarioController",
".",
"setJustAdded",
"(",
")",
";",
"mSensorScenarioView",
".",
"addView",
"(",
"position",
",",
"stateView",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Controller of a state from the scenario grid. | [
"Controller",
"of",
"a",
"state",
"from",
"the",
"scenario",
"grid",
"."
] | [
"// open big view"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54ee104db06bb0d62c6499b61e609c674fa686b9 | shisheng-1/riposte | riposte-core/src/main/java/com/nike/riposte/util/ErrorContractSerializerHelper.java | [
"Apache-2.0"
] | Java | ErrorContractSerializerHelper | /**
* Helper class for error contract serializers.
*/ | Helper class for error contract serializers. | [
"Helper",
"class",
"for",
"error",
"contract",
"serializers",
"."
] | @SuppressWarnings("WeakerAccess")
public class ErrorContractSerializerHelper {
public static final ObjectMapper SMART_ERROR_MAPPER = generateErrorContractObjectMapper(true, true);
public static final ErrorResponseBodySerializer SMART_ERROR_SERIALIZER =
asErrorResponseBodySerializer(SMART_ERROR_MAPPER);
public static ObjectMapper generateErrorContractObjectMapper(boolean excludeEmptyMetadataFromJson,
boolean serializeErrorCodeFieldAsIntegerIfPossible) {
return JsonUtilWithDefaultErrorContractDTOSupport.generateErrorContractObjectMapper(
excludeEmptyMetadataFromJson, serializeErrorCodeFieldAsIntegerIfPossible
);
}
@SuppressWarnings("unused")
public static ErrorResponseBodySerializer generateErrorContractSerializer(
boolean excludeEmptyMetadataFromJson, boolean serializeErrorCodeFieldAsIntegerIfPossible
) {
return asErrorResponseBodySerializer(
generateErrorContractObjectMapper(excludeEmptyMetadataFromJson, serializeErrorCodeFieldAsIntegerIfPossible)
);
}
public static ErrorResponseBodySerializer asErrorResponseBodySerializer(ObjectMapper objectMapper) {
return errorResponseBody -> {
try {
Object bodyToSerialize = (errorResponseBody == null) ? null : errorResponseBody.bodyToSerialize();
if (bodyToSerialize == null) {
// errorResponseBody itself is null, or errorResponseBody.bodyToSerialize() is null. Either case
// indicates empty response body payload, so we should return null.
return null;
}
if(bodyToSerialize instanceof CharSequence) {
return bodyToSerialize.toString();
} else {
return objectMapper.writeValueAsString(bodyToSerialize);
}
}
catch (JsonProcessingException e) {
throw new RuntimeException("An error occurred while serializing an ErrorResponseBody to a string", e);
}
};
}
} | [
"@",
"SuppressWarnings",
"(",
"\"",
"WeakerAccess",
"\"",
")",
"public",
"class",
"ErrorContractSerializerHelper",
"{",
"public",
"static",
"final",
"ObjectMapper",
"SMART_ERROR_MAPPER",
"=",
"generateErrorContractObjectMapper",
"(",
"true",
",",
"true",
")",
";",
"public",
"static",
"final",
"ErrorResponseBodySerializer",
"SMART_ERROR_SERIALIZER",
"=",
"asErrorResponseBodySerializer",
"(",
"SMART_ERROR_MAPPER",
")",
";",
"public",
"static",
"ObjectMapper",
"generateErrorContractObjectMapper",
"(",
"boolean",
"excludeEmptyMetadataFromJson",
",",
"boolean",
"serializeErrorCodeFieldAsIntegerIfPossible",
")",
"{",
"return",
"JsonUtilWithDefaultErrorContractDTOSupport",
".",
"generateErrorContractObjectMapper",
"(",
"excludeEmptyMetadataFromJson",
",",
"serializeErrorCodeFieldAsIntegerIfPossible",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unused",
"\"",
")",
"public",
"static",
"ErrorResponseBodySerializer",
"generateErrorContractSerializer",
"(",
"boolean",
"excludeEmptyMetadataFromJson",
",",
"boolean",
"serializeErrorCodeFieldAsIntegerIfPossible",
")",
"{",
"return",
"asErrorResponseBodySerializer",
"(",
"generateErrorContractObjectMapper",
"(",
"excludeEmptyMetadataFromJson",
",",
"serializeErrorCodeFieldAsIntegerIfPossible",
")",
")",
";",
"}",
"public",
"static",
"ErrorResponseBodySerializer",
"asErrorResponseBodySerializer",
"(",
"ObjectMapper",
"objectMapper",
")",
"{",
"return",
"errorResponseBody",
"->",
"{",
"try",
"{",
"Object",
"bodyToSerialize",
"=",
"(",
"errorResponseBody",
"==",
"null",
")",
"?",
"null",
":",
"errorResponseBody",
".",
"bodyToSerialize",
"(",
")",
";",
"if",
"(",
"bodyToSerialize",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"bodyToSerialize",
"instanceof",
"CharSequence",
")",
"{",
"return",
"bodyToSerialize",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"return",
"objectMapper",
".",
"writeValueAsString",
"(",
"bodyToSerialize",
")",
";",
"}",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"",
"An error occurred while serializing an ErrorResponseBody to a string",
"\"",
",",
"e",
")",
";",
"}",
"}",
";",
"}",
"}"
] | Helper class for error contract serializers. | [
"Helper",
"class",
"for",
"error",
"contract",
"serializers",
"."
] | [
"// errorResponseBody itself is null, or errorResponseBody.bodyToSerialize() is null. Either case",
"// indicates empty response body payload, so we should return null."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54f01e10e8c0b8c460f373db8281ea21ba31a432 | UniKnow/jsoar | jsoar-core/src/main/java/org/jsoar/kernel/Production.java | [
"BSD-3-Clause"
] | Java | Production | /**
* Represents a production rule in Soar. Each production has three required components: a name, a
* set of conditions (also called the left-hand side, or LHS), and a set of actions (also called the
* right-hand side, or RHS). There are also two optional components: a documentation string and a
* type.
*
* @author ray
*/ | Represents a production rule in Soar. Each production has three required components: a name, a
set of conditions (also called the left-hand side, or LHS), and a set of actions (also called the
right-hand side, or RHS). There are also two optional components: a documentation string and a
type.
@author ray | [
"Represents",
"a",
"production",
"rule",
"in",
"Soar",
".",
"Each",
"production",
"has",
"three",
"required",
"components",
":",
"a",
"name",
"a",
"set",
"of",
"conditions",
"(",
"also",
"called",
"the",
"left",
"-",
"hand",
"side",
"or",
"LHS",
")",
"and",
"a",
"set",
"of",
"actions",
"(",
"also",
"called",
"the",
"right",
"-",
"hand",
"side",
"or",
"RHS",
")",
".",
"There",
"are",
"also",
"two",
"optional",
"components",
":",
"a",
"documentation",
"string",
"and",
"a",
"type",
".",
"@author",
"ray"
] | public class Production {
private static final List<Variable> EMPTY_RHS_UNBOUND_VARS_LIST = Collections.emptyList();
/**
* Enumerations for possible declared production support types
*
* <p>production.h:66:_SUPPORT
*
* @see Production#getDeclaredSupport()
*/
public enum Support {
/**
* The production has no declared support, i.e. it's support will be determined by Soar.
*
* <p>production.h:66:UNDECLARED_SUPPORT
*/
UNDECLARED,
/**
* The production has been declared with {@code o-support} (operator support). Operator
* productions do not retract their actions, even if they no longer match working memory.
*
* <p>NOTE: WMEs with {@code o-support} are maintained throughout the existence of the state in
* which the operator is applied, unless explicitly removed (or if they become unlinked).
*
* <p>{@code production.h:66:DECLARED_O_SUPPORT}
*/
DECLARED_O_SUPPORT,
/**
* The production has been declared with {@code i-support} (instantiation support).
*
* <p>NOTE: WMEs with {@code i-support} disappear as soon as the production that created them
* retract
*
* <p>{@code production.h:66:DECLARED_I_SUPPORT}
*/
DECLARED_I_SUPPORT
}
/** Builder class used to construct productions. */
public static class Builder {
private ProductionType type;
private SourceLocation location = DefaultSourceLocation.UNKNOWN;
private String name;
private String documentation = "";
private Condition topCondition;
private Condition bottomCondition;
private Action actions;
private Support support = Support.UNDECLARED;
private boolean interrupt = false;
public Builder type(ProductionType type) {
this.type = type;
return this;
}
public Builder location(SourceLocation v) {
this.location = v;
return this;
}
public Builder name(String v) {
this.name = v;
return this;
}
public Builder documentation(String v) {
this.documentation = v;
return this;
}
public Builder conditions(Condition top, Condition bottom) {
this.topCondition = top;
this.bottomCondition = bottom;
return this;
}
public Builder actions(Action v) {
this.actions = v;
return this;
}
public Builder support(Support v) {
this.support = v;
return this;
}
public Builder interrupt(boolean v) {
this.interrupt = v;
return this;
}
public Production build() {
return new Production(
type,
location,
name,
documentation,
topCondition,
bottomCondition,
actions,
support,
interrupt);
}
}
public static Builder newBuilder() {
return new Builder();
}
@Getter private final ProductionType type;
@Getter private final SourceLocation location;
@Getter private final String name;
/** The documentation string of this production */
@Getter @Setter @NonNull private String documentation;
/** Contains whether the actions of this Production is instantiation or operator support. */
@Getter private final Support declaredSupport;
private final boolean interrupt;
private Condition condition_list;
private Condition bottomOfConditionList;
private Action action_list;
/** production.h:interrupt */
private final AtomicBoolean breakpointEnabled = new AtomicBoolean();
private final AtomicLong firingCount = new AtomicLong(0);
private final AtomicBoolean traceFirings = new AtomicBoolean();
private Rete rete;
/** Production's rete node */
@Getter private ReteNode reteNode;
/**
* List of instantiations of this production. Use {@link Instantiation#nextInProdList} to iterate.
*
* @see Instantiation#insertAtHeadOfProdList(Instantiation)
* @see Instantiation#removeFromProdList(Instantiation)
*/
public Instantiation instantiations;
private List<Variable> rhs_unbound_variables = null;
private boolean reordered = false;
/**
* If non-null, is a Soar-RL rule.
*
* <p>production.h:rl_rule
*/
public RLRuleInfo rlRuleInfo = null;
/**
* Container for RL template-specific info. Only initialized if type is TEMPLATE, i.e. ":template"
* flag is given.
*/
public final RLTemplateInfo rlTemplateInfo;
/**
* Function introduced while trying to tease apart production construction
*
* <p>production.cpp:1507:make_production
*
* @see Builder#build()
*/
private Production(
@NonNull ProductionType type,
@NonNull SourceLocation location,
@NonNull String name,
String documentation,
Condition lhs_top_in,
Condition lhs_bottom_in,
Action rhs_top_in,
Support support,
boolean interrupt) {
// Arguments.checkNotNull(lhs_top_in, "lhs_top_in");
// Arguments.checkNotNull(lhs_bottom_in, "lhs_bottom_in");
this.type = type;
this.location = location;
this.name = name;
this.documentation = documentation == null ? "" : documentation;
this.condition_list = lhs_top_in;
this.bottomOfConditionList = lhs_bottom_in;
this.action_list = rhs_top_in;
this.declaredSupport = support;
this.interrupt = interrupt;
rlTemplateInfo = type == ProductionType.TEMPLATE ? new RLTemplateInfo() : null;
}
/**
* Returns the first condition in the production. Use {@link Condition#next} to iterate.
*
* @return the first condition in the production
*/
public Condition getFirstCondition() {
return condition_list;
}
/**
* Returns the first action in the production. Use {@link Action#next} to iterate.
*
* @return the first action in the production
*/
public Action getFirstAction() {
return action_list;
}
/** @return the current firing count of this production */
public long getFiringCount() {
return firingCount.get();
}
/** Reset the production's firing count to {@code 0}. */
public void resetFiringCount() {
this.firingCount.set(0);
}
/**
* Increment the production's firing count and return the new count.
*
* @return the new firing count
*/
public long incrementFiringCount() {
return this.firingCount.incrementAndGet();
}
/**
* Returns true if this production will interrupt the agent when it matches. This could be either
* because of the <code>:interrupt</code> flag explicitly on the rule or because {@link
* #setBreakpointEnabled(boolean)} was called.
*
* @return true if this production will interrupt the agent when it matches
*/
public boolean isBreakpointEnabled() {
return interrupt || breakpointEnabled.get();
}
/**
* If set to true, the production will interrupt the agent when it matches. Note that if the
* production has the <code>:interrupt</code> flag set, this method has no affect.
*
* @param v the new breakpoint setting
*/
public void setBreakpointEnabled(boolean v) {
breakpointEnabled.set(v);
}
/** @return true if firings of this rule should be traced */
public boolean isTraceFirings() {
return traceFirings.get();
}
/**
* Set whether firings of this rule should be traced.
*
* @param value new value
*/
public void setTraceFirings(boolean value) {
traceFirings.set(value);
}
/**
* Print partial match information for this production to the given printer Does not show betanode
* ids
*
* @param printer The printer to print to
* @param wtt The WME trace level
*/
public void printPartialMatches(Printer printer, WmeTraceType wtt) {
printPartialMatches(printer, wtt, false);
}
/**
* Print partial match information for this production to the given printer
*
* @param printer The printer to print to
* @param wtt The WME trace level
* @param showNodeIds Whether to show the betanode ids (useful to see what nodes are being shared
* in the rete)
*/
public void printPartialMatches(Printer printer, WmeTraceType wtt, boolean showNodeIds) {
if (rete == null) {
return;
}
rete.print_partial_match_information(printer, reteNode, wtt, showNodeIds);
}
/**
* Returns a structured partial matches for this rule
*
* @return partial matches
*/
public PartialMatches getPartialMatches() {
if (rete == null) {
return new PartialMatches(Collections.emptyList());
}
return rete.getPartialMatches(reteNode);
}
/**
* Returns a count of the number of tokens currently in use for this production. The count does
* not include:
*
* <ul>
* <li>tokens in the p_node (i.e., tokens representing complete matches)
* <li>local join result tokens on (real) tokens in negative/NCC nodes
* </ul>
*
* <p>Note that this method is not fast for large match sets
*
* @return token count, or 0 if not in rete
*/
public int getReteTokenCount() {
return rete != null ? rete.countTokensProduction(reteNode) : 0;
}
/**
* Performs reordering of the LHS and RHS of the production using the given reorderer objects.
* This will modify the conditions and actions of the production.
*
* <p>Function introduced while trying to tease apart production construction
*
* <p>production.cpp:1507:make_production
*
* @param varGen A variable generator
* @param cr A condition reorderer
* @param ar An action reorderer
* @param reorder_nccs True if NCCs should be reordered.
* @throws ReordererException
* @throws IllegalStateException if the production has already been reordered
*/
public void reorder(
VariableGenerator varGen, ConditionReorderer cr, ActionReorderer ar, boolean reorder_nccs)
throws ReordererException {
if (reordered) {
throw new IllegalStateException("Production '" + name + "' already reordered");
}
if (type != ProductionType.JUSTIFICATION) {
final ByRef<Condition> lhs_top = ByRef.create(condition_list);
final ByRef<Condition> lhs_bottom = ByRef.create(bottomOfConditionList);
final ByRef<Action> rhs_top = ByRef.create(action_list);
// ??? thisAgent->name_of_production_being_reordered =
// name->sc.name;
varGen.reset(lhs_top.value, rhs_top.value);
Marker tc = DefaultMarker.create();
Condition.addBoundVariables(lhs_top.value, tc, null);
ar.reorder_action_list(rhs_top, tc);
cr.reorder_lhs(lhs_top, lhs_bottom, reorder_nccs);
// TODO: Is this necessary since this is the default value?
for (Action a = rhs_top.value; a != null; a = a.next) {
a.support = ActionSupport.UNKNOWN_SUPPORT;
}
this.condition_list = lhs_top.value;
this.bottomOfConditionList = lhs_bottom.value;
this.action_list = rhs_top.value;
} else {
/* --- for justifications --- */
/* force run-time o-support (it'll only be done once) */
// TODO: Is this necessary since this is the default value?
for (var a = action_list; a != null; a = a.next) {
a.support = ActionSupport.UNKNOWN_SUPPORT;
}
}
reordered = true;
}
public List<Variable> getRhsUnboundVariables() {
return rhs_unbound_variables != null ? rhs_unbound_variables : EMPTY_RHS_UNBOUND_VARS_LIST;
}
public void clearRhsUnboundVariables() {
rhs_unbound_variables = null;
}
/**
* Set the RHS unbound variables of the production. This method takes ownership of the passed in
* list rather than copying it!
*
* @param unboundVars List of unbound vars
*/
public void setRhsUnboundVariables(List<Variable> unboundVars) {
rhs_unbound_variables = unboundVars;
}
/**
* Set this productions rete node. This should only be called by the rete.
*
* @param rete
* @param p_node
*/
public void setReteNode(Rete rete, ReteNode p_node) {
if ((this.rete != null || this.reteNode != null) && (rete != null || p_node != null)) {
throw new IllegalStateException("Production " + this + " is already in rete");
}
this.rete = rete;
this.reteNode = p_node;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return name + " (" + type + ") " + firingCount;
}
/**
* This prints a production. The "internal" parameter, if TRUE, indicates that the LHS and RHS
* should be printed in internal format.
*
* <p>print.cpp:762:print_production
*
* @param printer The printer to print to
* @param internal true for internal representation, false otherwise
*/
public void print(Printer printer, boolean internal) {
if (rete == null || reteNode == null) {
printer.print("%s has been excised", this.name);
return;
}
// print "sp" and production name
printer.print("sp {%s\n", this.name);
// print optional documentation string
if (documentation.length() > 0) {
printer.print(" %s\n", StringTools.string_to_escaped_string(documentation, '"'));
}
// print any flags
switch (type) {
case DEFAULT:
printer.print(" :default\n");
break;
case USER:
break;
case CHUNK:
printer.print(" :chunk\n");
break;
case JUSTIFICATION:
printer.print(" :justification ;# not reloadable\n");
break;
case TEMPLATE:
printer.print(" :template\n");
break;
}
switch (declaredSupport) {
case DECLARED_O_SUPPORT:
printer.print(" :o-support\n");
break;
case DECLARED_I_SUPPORT:
printer.print(" :i-support\n");
break;
default: /* do nothing */
break;
}
if (interrupt) {
printer.print(" :interrupt\n");
}
// print the LHS and RHS
ConditionsAndNots cns = rete.p_node_to_conditions_and_nots(reteNode, null, null, true);
printer.print(" ");
Conditions.print_condition_list(printer, cns.top, 3, internal);
printer.print("\n -->\n ");
printer.print(" ");
Action.print_action_list(printer, cns.actions, 4, internal);
printer.print("\n}\n").flush();
}
} | [
"public",
"class",
"Production",
"{",
"private",
"static",
"final",
"List",
"<",
"Variable",
">",
"EMPTY_RHS_UNBOUND_VARS_LIST",
"=",
"Collections",
".",
"emptyList",
"(",
")",
";",
"/**\n * Enumerations for possible declared production support types\n *\n * <p>production.h:66:_SUPPORT\n *\n * @see Production#getDeclaredSupport()\n */",
"public",
"enum",
"Support",
"{",
"/**\n * The production has no declared support, i.e. it's support will be determined by Soar.\n *\n * <p>production.h:66:UNDECLARED_SUPPORT\n */",
"UNDECLARED",
",",
"/**\n * The production has been declared with {@code o-support} (operator support). Operator\n * productions do not retract their actions, even if they no longer match working memory.\n *\n * <p>NOTE: WMEs with {@code o-support} are maintained throughout the existence of the state in\n * which the operator is applied, unless explicitly removed (or if they become unlinked).\n *\n * <p>{@code production.h:66:DECLARED_O_SUPPORT}\n */",
"DECLARED_O_SUPPORT",
",",
"/**\n * The production has been declared with {@code i-support} (instantiation support).\n *\n * <p>NOTE: WMEs with {@code i-support} disappear as soon as the production that created them\n * retract\n *\n * <p>{@code production.h:66:DECLARED_I_SUPPORT}\n */",
"DECLARED_I_SUPPORT",
"}",
"/** Builder class used to construct productions. */",
"public",
"static",
"class",
"Builder",
"{",
"private",
"ProductionType",
"type",
";",
"private",
"SourceLocation",
"location",
"=",
"DefaultSourceLocation",
".",
"UNKNOWN",
";",
"private",
"String",
"name",
";",
"private",
"String",
"documentation",
"=",
"\"",
"\"",
";",
"private",
"Condition",
"topCondition",
";",
"private",
"Condition",
"bottomCondition",
";",
"private",
"Action",
"actions",
";",
"private",
"Support",
"support",
"=",
"Support",
".",
"UNDECLARED",
";",
"private",
"boolean",
"interrupt",
"=",
"false",
";",
"public",
"Builder",
"type",
"(",
"ProductionType",
"type",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"location",
"(",
"SourceLocation",
"v",
")",
"{",
"this",
".",
"location",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"name",
"(",
"String",
"v",
")",
"{",
"this",
".",
"name",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"documentation",
"(",
"String",
"v",
")",
"{",
"this",
".",
"documentation",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"conditions",
"(",
"Condition",
"top",
",",
"Condition",
"bottom",
")",
"{",
"this",
".",
"topCondition",
"=",
"top",
";",
"this",
".",
"bottomCondition",
"=",
"bottom",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"actions",
"(",
"Action",
"v",
")",
"{",
"this",
".",
"actions",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"support",
"(",
"Support",
"v",
")",
"{",
"this",
".",
"support",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"interrupt",
"(",
"boolean",
"v",
")",
"{",
"this",
".",
"interrupt",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Production",
"build",
"(",
")",
"{",
"return",
"new",
"Production",
"(",
"type",
",",
"location",
",",
"name",
",",
"documentation",
",",
"topCondition",
",",
"bottomCondition",
",",
"actions",
",",
"support",
",",
"interrupt",
")",
";",
"}",
"}",
"public",
"static",
"Builder",
"newBuilder",
"(",
")",
"{",
"return",
"new",
"Builder",
"(",
")",
";",
"}",
"@",
"Getter",
"private",
"final",
"ProductionType",
"type",
";",
"@",
"Getter",
"private",
"final",
"SourceLocation",
"location",
";",
"@",
"Getter",
"private",
"final",
"String",
"name",
";",
"/** The documentation string of this production */",
"@",
"Getter",
"@",
"Setter",
"@",
"NonNull",
"private",
"String",
"documentation",
";",
"/** Contains whether the actions of this Production is instantiation or operator support. */",
"@",
"Getter",
"private",
"final",
"Support",
"declaredSupport",
";",
"private",
"final",
"boolean",
"interrupt",
";",
"private",
"Condition",
"condition_list",
";",
"private",
"Condition",
"bottomOfConditionList",
";",
"private",
"Action",
"action_list",
";",
"/** production.h:interrupt */",
"private",
"final",
"AtomicBoolean",
"breakpointEnabled",
"=",
"new",
"AtomicBoolean",
"(",
")",
";",
"private",
"final",
"AtomicLong",
"firingCount",
"=",
"new",
"AtomicLong",
"(",
"0",
")",
";",
"private",
"final",
"AtomicBoolean",
"traceFirings",
"=",
"new",
"AtomicBoolean",
"(",
")",
";",
"private",
"Rete",
"rete",
";",
"/** Production's rete node */",
"@",
"Getter",
"private",
"ReteNode",
"reteNode",
";",
"/**\n * List of instantiations of this production. Use {@link Instantiation#nextInProdList} to iterate.\n *\n * @see Instantiation#insertAtHeadOfProdList(Instantiation)\n * @see Instantiation#removeFromProdList(Instantiation)\n */",
"public",
"Instantiation",
"instantiations",
";",
"private",
"List",
"<",
"Variable",
">",
"rhs_unbound_variables",
"=",
"null",
";",
"private",
"boolean",
"reordered",
"=",
"false",
";",
"/**\n * If non-null, is a Soar-RL rule.\n *\n * <p>production.h:rl_rule\n */",
"public",
"RLRuleInfo",
"rlRuleInfo",
"=",
"null",
";",
"/**\n * Container for RL template-specific info. Only initialized if type is TEMPLATE, i.e. \":template\"\n * flag is given.\n */",
"public",
"final",
"RLTemplateInfo",
"rlTemplateInfo",
";",
"/**\n * Function introduced while trying to tease apart production construction\n *\n * <p>production.cpp:1507:make_production\n *\n * @see Builder#build()\n */",
"private",
"Production",
"(",
"@",
"NonNull",
"ProductionType",
"type",
",",
"@",
"NonNull",
"SourceLocation",
"location",
",",
"@",
"NonNull",
"String",
"name",
",",
"String",
"documentation",
",",
"Condition",
"lhs_top_in",
",",
"Condition",
"lhs_bottom_in",
",",
"Action",
"rhs_top_in",
",",
"Support",
"support",
",",
"boolean",
"interrupt",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"location",
"=",
"location",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"documentation",
"=",
"documentation",
"==",
"null",
"?",
"\"",
"\"",
":",
"documentation",
";",
"this",
".",
"condition_list",
"=",
"lhs_top_in",
";",
"this",
".",
"bottomOfConditionList",
"=",
"lhs_bottom_in",
";",
"this",
".",
"action_list",
"=",
"rhs_top_in",
";",
"this",
".",
"declaredSupport",
"=",
"support",
";",
"this",
".",
"interrupt",
"=",
"interrupt",
";",
"rlTemplateInfo",
"=",
"type",
"==",
"ProductionType",
".",
"TEMPLATE",
"?",
"new",
"RLTemplateInfo",
"(",
")",
":",
"null",
";",
"}",
"/**\n * Returns the first condition in the production. Use {@link Condition#next} to iterate.\n *\n * @return the first condition in the production\n */",
"public",
"Condition",
"getFirstCondition",
"(",
")",
"{",
"return",
"condition_list",
";",
"}",
"/**\n * Returns the first action in the production. Use {@link Action#next} to iterate.\n *\n * @return the first action in the production\n */",
"public",
"Action",
"getFirstAction",
"(",
")",
"{",
"return",
"action_list",
";",
"}",
"/** @return the current firing count of this production */",
"public",
"long",
"getFiringCount",
"(",
")",
"{",
"return",
"firingCount",
".",
"get",
"(",
")",
";",
"}",
"/** Reset the production's firing count to {@code 0}. */",
"public",
"void",
"resetFiringCount",
"(",
")",
"{",
"this",
".",
"firingCount",
".",
"set",
"(",
"0",
")",
";",
"}",
"/**\n * Increment the production's firing count and return the new count.\n *\n * @return the new firing count\n */",
"public",
"long",
"incrementFiringCount",
"(",
")",
"{",
"return",
"this",
".",
"firingCount",
".",
"incrementAndGet",
"(",
")",
";",
"}",
"/**\n * Returns true if this production will interrupt the agent when it matches. This could be either\n * because of the <code>:interrupt</code> flag explicitly on the rule or because {@link\n * #setBreakpointEnabled(boolean)} was called.\n *\n * @return true if this production will interrupt the agent when it matches\n */",
"public",
"boolean",
"isBreakpointEnabled",
"(",
")",
"{",
"return",
"interrupt",
"||",
"breakpointEnabled",
".",
"get",
"(",
")",
";",
"}",
"/**\n * If set to true, the production will interrupt the agent when it matches. Note that if the\n * production has the <code>:interrupt</code> flag set, this method has no affect.\n *\n * @param v the new breakpoint setting\n */",
"public",
"void",
"setBreakpointEnabled",
"(",
"boolean",
"v",
")",
"{",
"breakpointEnabled",
".",
"set",
"(",
"v",
")",
";",
"}",
"/** @return true if firings of this rule should be traced */",
"public",
"boolean",
"isTraceFirings",
"(",
")",
"{",
"return",
"traceFirings",
".",
"get",
"(",
")",
";",
"}",
"/**\n * Set whether firings of this rule should be traced.\n *\n * @param value new value\n */",
"public",
"void",
"setTraceFirings",
"(",
"boolean",
"value",
")",
"{",
"traceFirings",
".",
"set",
"(",
"value",
")",
";",
"}",
"/**\n * Print partial match information for this production to the given printer Does not show betanode\n * ids\n *\n * @param printer The printer to print to\n * @param wtt The WME trace level\n */",
"public",
"void",
"printPartialMatches",
"(",
"Printer",
"printer",
",",
"WmeTraceType",
"wtt",
")",
"{",
"printPartialMatches",
"(",
"printer",
",",
"wtt",
",",
"false",
")",
";",
"}",
"/**\n * Print partial match information for this production to the given printer\n *\n * @param printer The printer to print to\n * @param wtt The WME trace level\n * @param showNodeIds Whether to show the betanode ids (useful to see what nodes are being shared\n * in the rete)\n */",
"public",
"void",
"printPartialMatches",
"(",
"Printer",
"printer",
",",
"WmeTraceType",
"wtt",
",",
"boolean",
"showNodeIds",
")",
"{",
"if",
"(",
"rete",
"==",
"null",
")",
"{",
"return",
";",
"}",
"rete",
".",
"print_partial_match_information",
"(",
"printer",
",",
"reteNode",
",",
"wtt",
",",
"showNodeIds",
")",
";",
"}",
"/**\n * Returns a structured partial matches for this rule\n *\n * @return partial matches\n */",
"public",
"PartialMatches",
"getPartialMatches",
"(",
")",
"{",
"if",
"(",
"rete",
"==",
"null",
")",
"{",
"return",
"new",
"PartialMatches",
"(",
"Collections",
".",
"emptyList",
"(",
")",
")",
";",
"}",
"return",
"rete",
".",
"getPartialMatches",
"(",
"reteNode",
")",
";",
"}",
"/**\n * Returns a count of the number of tokens currently in use for this production. The count does\n * not include:\n *\n * <ul>\n * <li>tokens in the p_node (i.e., tokens representing complete matches)\n * <li>local join result tokens on (real) tokens in negative/NCC nodes\n * </ul>\n *\n * <p>Note that this method is not fast for large match sets\n *\n * @return token count, or 0 if not in rete\n */",
"public",
"int",
"getReteTokenCount",
"(",
")",
"{",
"return",
"rete",
"!=",
"null",
"?",
"rete",
".",
"countTokensProduction",
"(",
"reteNode",
")",
":",
"0",
";",
"}",
"/**\n * Performs reordering of the LHS and RHS of the production using the given reorderer objects.\n * This will modify the conditions and actions of the production.\n *\n * <p>Function introduced while trying to tease apart production construction\n *\n * <p>production.cpp:1507:make_production\n *\n * @param varGen A variable generator\n * @param cr A condition reorderer\n * @param ar An action reorderer\n * @param reorder_nccs True if NCCs should be reordered.\n * @throws ReordererException\n * @throws IllegalStateException if the production has already been reordered\n */",
"public",
"void",
"reorder",
"(",
"VariableGenerator",
"varGen",
",",
"ConditionReorderer",
"cr",
",",
"ActionReorderer",
"ar",
",",
"boolean",
"reorder_nccs",
")",
"throws",
"ReordererException",
"{",
"if",
"(",
"reordered",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"Production '",
"\"",
"+",
"name",
"+",
"\"",
"' already reordered",
"\"",
")",
";",
"}",
"if",
"(",
"type",
"!=",
"ProductionType",
".",
"JUSTIFICATION",
")",
"{",
"final",
"ByRef",
"<",
"Condition",
">",
"lhs_top",
"=",
"ByRef",
".",
"create",
"(",
"condition_list",
")",
";",
"final",
"ByRef",
"<",
"Condition",
">",
"lhs_bottom",
"=",
"ByRef",
".",
"create",
"(",
"bottomOfConditionList",
")",
";",
"final",
"ByRef",
"<",
"Action",
">",
"rhs_top",
"=",
"ByRef",
".",
"create",
"(",
"action_list",
")",
";",
"varGen",
".",
"reset",
"(",
"lhs_top",
".",
"value",
",",
"rhs_top",
".",
"value",
")",
";",
"Marker",
"tc",
"=",
"DefaultMarker",
".",
"create",
"(",
")",
";",
"Condition",
".",
"addBoundVariables",
"(",
"lhs_top",
".",
"value",
",",
"tc",
",",
"null",
")",
";",
"ar",
".",
"reorder_action_list",
"(",
"rhs_top",
",",
"tc",
")",
";",
"cr",
".",
"reorder_lhs",
"(",
"lhs_top",
",",
"lhs_bottom",
",",
"reorder_nccs",
")",
";",
"for",
"(",
"Action",
"a",
"=",
"rhs_top",
".",
"value",
";",
"a",
"!=",
"null",
";",
"a",
"=",
"a",
".",
"next",
")",
"{",
"a",
".",
"support",
"=",
"ActionSupport",
".",
"UNKNOWN_SUPPORT",
";",
"}",
"this",
".",
"condition_list",
"=",
"lhs_top",
".",
"value",
";",
"this",
".",
"bottomOfConditionList",
"=",
"lhs_bottom",
".",
"value",
";",
"this",
".",
"action_list",
"=",
"rhs_top",
".",
"value",
";",
"}",
"else",
"{",
"/* --- for justifications --- */",
"/* force run-time o-support (it'll only be done once) */",
"for",
"(",
"var",
"a",
"=",
"action_list",
";",
"a",
"!=",
"null",
";",
"a",
"=",
"a",
".",
"next",
")",
"{",
"a",
".",
"support",
"=",
"ActionSupport",
".",
"UNKNOWN_SUPPORT",
";",
"}",
"}",
"reordered",
"=",
"true",
";",
"}",
"public",
"List",
"<",
"Variable",
">",
"getRhsUnboundVariables",
"(",
")",
"{",
"return",
"rhs_unbound_variables",
"!=",
"null",
"?",
"rhs_unbound_variables",
":",
"EMPTY_RHS_UNBOUND_VARS_LIST",
";",
"}",
"public",
"void",
"clearRhsUnboundVariables",
"(",
")",
"{",
"rhs_unbound_variables",
"=",
"null",
";",
"}",
"/**\n * Set the RHS unbound variables of the production. This method takes ownership of the passed in\n * list rather than copying it!\n *\n * @param unboundVars List of unbound vars\n */",
"public",
"void",
"setRhsUnboundVariables",
"(",
"List",
"<",
"Variable",
">",
"unboundVars",
")",
"{",
"rhs_unbound_variables",
"=",
"unboundVars",
";",
"}",
"/**\n * Set this productions rete node. This should only be called by the rete.\n *\n * @param rete\n * @param p_node\n */",
"public",
"void",
"setReteNode",
"(",
"Rete",
"rete",
",",
"ReteNode",
"p_node",
")",
"{",
"if",
"(",
"(",
"this",
".",
"rete",
"!=",
"null",
"||",
"this",
".",
"reteNode",
"!=",
"null",
")",
"&&",
"(",
"rete",
"!=",
"null",
"||",
"p_node",
"!=",
"null",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"Production ",
"\"",
"+",
"this",
"+",
"\"",
" is already in rete",
"\"",
")",
";",
"}",
"this",
".",
"rete",
"=",
"rete",
";",
"this",
".",
"reteNode",
"=",
"p_node",
";",
"}",
"/* (non-Javadoc)\n * @see java.lang.Object#toString()\n */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"name",
"+",
"\"",
" (",
"\"",
"+",
"type",
"+",
"\"",
") ",
"\"",
"+",
"firingCount",
";",
"}",
"/**\n * This prints a production. The \"internal\" parameter, if TRUE, indicates that the LHS and RHS\n * should be printed in internal format.\n *\n * <p>print.cpp:762:print_production\n *\n * @param printer The printer to print to\n * @param internal true for internal representation, false otherwise\n */",
"public",
"void",
"print",
"(",
"Printer",
"printer",
",",
"boolean",
"internal",
")",
"{",
"if",
"(",
"rete",
"==",
"null",
"||",
"reteNode",
"==",
"null",
")",
"{",
"printer",
".",
"print",
"(",
"\"",
"%s has been excised",
"\"",
",",
"this",
".",
"name",
")",
";",
"return",
";",
"}",
"printer",
".",
"print",
"(",
"\"",
"sp {%s",
"\\n",
"\"",
",",
"this",
".",
"name",
")",
";",
"if",
"(",
"documentation",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"printer",
".",
"print",
"(",
"\"",
" %s",
"\\n",
"\"",
",",
"StringTools",
".",
"string_to_escaped_string",
"(",
"documentation",
",",
"'\"'",
")",
")",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"DEFAULT",
":",
"printer",
".",
"print",
"(",
"\"",
" :default",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"USER",
":",
"break",
";",
"case",
"CHUNK",
":",
"printer",
".",
"print",
"(",
"\"",
" :chunk",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"JUSTIFICATION",
":",
"printer",
".",
"print",
"(",
"\"",
" :justification ;# not reloadable",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"TEMPLATE",
":",
"printer",
".",
"print",
"(",
"\"",
" :template",
"\\n",
"\"",
")",
";",
"break",
";",
"}",
"switch",
"(",
"declaredSupport",
")",
"{",
"case",
"DECLARED_O_SUPPORT",
":",
"printer",
".",
"print",
"(",
"\"",
" :o-support",
"\\n",
"\"",
")",
";",
"break",
";",
"case",
"DECLARED_I_SUPPORT",
":",
"printer",
".",
"print",
"(",
"\"",
" :i-support",
"\\n",
"\"",
")",
";",
"break",
";",
"default",
":",
"/* do nothing */",
"break",
";",
"}",
"if",
"(",
"interrupt",
")",
"{",
"printer",
".",
"print",
"(",
"\"",
" :interrupt",
"\\n",
"\"",
")",
";",
"}",
"ConditionsAndNots",
"cns",
"=",
"rete",
".",
"p_node_to_conditions_and_nots",
"(",
"reteNode",
",",
"null",
",",
"null",
",",
"true",
")",
";",
"printer",
".",
"print",
"(",
"\"",
" ",
"\"",
")",
";",
"Conditions",
".",
"print_condition_list",
"(",
"printer",
",",
"cns",
".",
"top",
",",
"3",
",",
"internal",
")",
";",
"printer",
".",
"print",
"(",
"\"",
"\\n",
" -->",
"\\n",
" ",
"\"",
")",
";",
"printer",
".",
"print",
"(",
"\"",
" ",
"\"",
")",
";",
"Action",
".",
"print_action_list",
"(",
"printer",
",",
"cns",
".",
"actions",
",",
"4",
",",
"internal",
")",
";",
"printer",
".",
"print",
"(",
"\"",
"\\n",
"}",
"\\n",
"\"",
")",
".",
"flush",
"(",
")",
";",
"}",
"}"
] | Represents a production rule in Soar. | [
"Represents",
"a",
"production",
"rule",
"in",
"Soar",
"."
] | [
"// Arguments.checkNotNull(lhs_top_in, \"lhs_top_in\");",
"// Arguments.checkNotNull(lhs_bottom_in, \"lhs_bottom_in\");",
"// ??? thisAgent->name_of_production_being_reordered =",
"// name->sc.name;",
"// TODO: Is this necessary since this is the default value?",
"// TODO: Is this necessary since this is the default value?",
"// print \"sp\" and production name",
"// print optional documentation string",
"// print any flags",
"// print the LHS and RHS"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54f01e10e8c0b8c460f373db8281ea21ba31a432 | UniKnow/jsoar | jsoar-core/src/main/java/org/jsoar/kernel/Production.java | [
"BSD-3-Clause"
] | Java | Builder | /** Builder class used to construct productions. */ | Builder class used to construct productions. | [
"Builder",
"class",
"used",
"to",
"construct",
"productions",
"."
] | public static class Builder {
private ProductionType type;
private SourceLocation location = DefaultSourceLocation.UNKNOWN;
private String name;
private String documentation = "";
private Condition topCondition;
private Condition bottomCondition;
private Action actions;
private Support support = Support.UNDECLARED;
private boolean interrupt = false;
public Builder type(ProductionType type) {
this.type = type;
return this;
}
public Builder location(SourceLocation v) {
this.location = v;
return this;
}
public Builder name(String v) {
this.name = v;
return this;
}
public Builder documentation(String v) {
this.documentation = v;
return this;
}
public Builder conditions(Condition top, Condition bottom) {
this.topCondition = top;
this.bottomCondition = bottom;
return this;
}
public Builder actions(Action v) {
this.actions = v;
return this;
}
public Builder support(Support v) {
this.support = v;
return this;
}
public Builder interrupt(boolean v) {
this.interrupt = v;
return this;
}
public Production build() {
return new Production(
type,
location,
name,
documentation,
topCondition,
bottomCondition,
actions,
support,
interrupt);
}
} | [
"public",
"static",
"class",
"Builder",
"{",
"private",
"ProductionType",
"type",
";",
"private",
"SourceLocation",
"location",
"=",
"DefaultSourceLocation",
".",
"UNKNOWN",
";",
"private",
"String",
"name",
";",
"private",
"String",
"documentation",
"=",
"\"",
"\"",
";",
"private",
"Condition",
"topCondition",
";",
"private",
"Condition",
"bottomCondition",
";",
"private",
"Action",
"actions",
";",
"private",
"Support",
"support",
"=",
"Support",
".",
"UNDECLARED",
";",
"private",
"boolean",
"interrupt",
"=",
"false",
";",
"public",
"Builder",
"type",
"(",
"ProductionType",
"type",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"location",
"(",
"SourceLocation",
"v",
")",
"{",
"this",
".",
"location",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"name",
"(",
"String",
"v",
")",
"{",
"this",
".",
"name",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"documentation",
"(",
"String",
"v",
")",
"{",
"this",
".",
"documentation",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"conditions",
"(",
"Condition",
"top",
",",
"Condition",
"bottom",
")",
"{",
"this",
".",
"topCondition",
"=",
"top",
";",
"this",
".",
"bottomCondition",
"=",
"bottom",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"actions",
"(",
"Action",
"v",
")",
"{",
"this",
".",
"actions",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"support",
"(",
"Support",
"v",
")",
"{",
"this",
".",
"support",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Builder",
"interrupt",
"(",
"boolean",
"v",
")",
"{",
"this",
".",
"interrupt",
"=",
"v",
";",
"return",
"this",
";",
"}",
"public",
"Production",
"build",
"(",
")",
"{",
"return",
"new",
"Production",
"(",
"type",
",",
"location",
",",
"name",
",",
"documentation",
",",
"topCondition",
",",
"bottomCondition",
",",
"actions",
",",
"support",
",",
"interrupt",
")",
";",
"}",
"}"
] | Builder class used to construct productions. | [
"Builder",
"class",
"used",
"to",
"construct",
"productions",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54f47eb12a7b4e252d0fd34e46113f7b92861814 | prajwalmr62/LearningJava | src/swingPro/DrawAppletSwing.java | [
"MIT"
] | Java | MyMouse | //Motion adapters classes from here.
| Motion adapters classes from here. | [
"Motion",
"adapters",
"classes",
"from",
"here",
"."
] | class MyMouse extends MouseMotionAdapter{
DrawAppletSwing drawapplet;
public MyMouse(DrawAppletSwing drawapplet){
this.drawapplet = drawapplet;
}
public void mouseMoved(MouseEvent me){
int i = drawapplet.i;
if(i==1000) i=0;
drawapplet.x[i]=me.getX();
drawapplet.y[i++]=me.getY();
drawapplet.showStatus("Cursor at x: "+me.getX()+" y: "+me.getY());
drawapplet.i = i;
drawapplet.repaint();
}
} | [
"class",
"MyMouse",
"extends",
"MouseMotionAdapter",
"{",
"DrawAppletSwing",
"drawapplet",
";",
"public",
"MyMouse",
"(",
"DrawAppletSwing",
"drawapplet",
")",
"{",
"this",
".",
"drawapplet",
"=",
"drawapplet",
";",
"}",
"public",
"void",
"mouseMoved",
"(",
"MouseEvent",
"me",
")",
"{",
"int",
"i",
"=",
"drawapplet",
".",
"i",
";",
"if",
"(",
"i",
"==",
"1000",
")",
"i",
"=",
"0",
";",
"drawapplet",
".",
"x",
"[",
"i",
"]",
"=",
"me",
".",
"getX",
"(",
")",
";",
"drawapplet",
".",
"y",
"[",
"i",
"++",
"]",
"=",
"me",
".",
"getY",
"(",
")",
";",
"drawapplet",
".",
"showStatus",
"(",
"\"",
"Cursor at x: ",
"\"",
"+",
"me",
".",
"getX",
"(",
")",
"+",
"\"",
" y: ",
"\"",
"+",
"me",
".",
"getY",
"(",
")",
")",
";",
"drawapplet",
".",
"i",
"=",
"i",
";",
"drawapplet",
".",
"repaint",
"(",
")",
";",
"}",
"}"
] | Motion adapters classes from here. | [
"Motion",
"adapters",
"classes",
"from",
"here",
"."
] | [] | [
{
"param": "MouseMotionAdapter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "MouseMotionAdapter",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54fb663a19015a95c5d55ef9d56295e65d39e079 | Franklin-garcia/lab5_franklin_garcia_progra2 | lab5_franklin_garcia_progra2/src/lab5_franklin_garcia_progra2/principal.java | [
"MIT"
] | Java | principal | /**
*
* @author Franklin Garcia
*/ | @author Franklin Garcia | [
"@author",
"Franklin",
"Garcia"
] | public class principal extends javax.swing.JFrame {
/**
* Creates new form principal
*/
public principal() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jd_agregar = new javax.swing.JDialog();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
tf_nombre = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
ta_direccion = new javax.swing.JTextArea();
jLabel4 = new javax.swing.JLabel();
tf_seguridad = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
cb_entrada = new javax.swing.JComboBox<>();
jLabel6 = new javax.swing.JLabel();
cb_salida = new javax.swing.JComboBox<>();
tab_tipo_lugar = new javax.swing.JTabbedPane();
jPanel2 = new javax.swing.JPanel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
cb_estado = new javax.swing.JComboBox<>();
cb_categoria_canchas = new javax.swing.JComboBox<>();
jPanel3 = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel();
Categoria = new javax.swing.JLabel();
cb_categoria_restaurante = new javax.swing.JComboBox<>();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
cb_calificacion = new javax.swing.JComboBox<>();
boton_guardar = new javax.swing.JButton();
jd_carreteras = new javax.swing.JDialog();
jLabel11 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
tf_numero = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
tf_distancia = new javax.swing.JTextField();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
boton_guardar1 = new javax.swing.JButton();
cb_inicio = new javax.swing.JComboBox<>();
cb_lsalida = new javax.swing.JComboBox<>();
jd_tabla = new javax.swing.JDialog();
jLabel16 = new javax.swing.JLabel();
jLabel17 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox<>();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jd_arbol = new javax.swing.JDialog();
jLabel18 = new javax.swing.JLabel();
jScrollPane3 = new javax.swing.JScrollPane();
jt_lugar = new javax.swing.JTree();
jScrollPane4 = new javax.swing.JScrollPane();
jl_lugar = new javax.swing.JList<>();
listar_tree = new javax.swing.JComboBox<>();
menu_contenedor = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
mi_menu = new javax.swing.JMenu();
jm_agregar = new javax.swing.JMenu();
jm_lugar = new javax.swing.JMenuItem();
jm_carretera = new javax.swing.JMenuItem();
jm_listar = new javax.swing.JMenu();
jm_tabla = new javax.swing.JMenuItem();
jm_arbol = new javax.swing.JMenuItem();
jd_agregar.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
jd_agregarWindowActivated(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jLabel1.setText("Lugar");
jLabel2.setText("Nombre");
jLabel3.setText("Direccion");
tf_nombre.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tf_nombreActionPerformed(evt);
}
});
ta_direccion.setColumns(20);
ta_direccion.setRows(5);
jScrollPane1.setViewportView(ta_direccion);
jLabel4.setText("Seguridad");
jLabel5.setText("Carreteras de entrada");
cb_entrada.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
cb_entradaItemStateChanged(evt);
}
});
jLabel6.setText("Carretera de salida");
cb_salida.setMaximumRowCount(0);
jLabel9.setText("Estado");
jLabel10.setText("Categoria");
cb_estado.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "ocupado", "libre" }));
cb_categoria_canchas.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "football", "básquet", "tenis", "volley" }));
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(31, 31, 31)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel10))
.addGap(47, 47, 47)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cb_estado, 0, 110, Short.MAX_VALUE)
.addComponent(cb_categoria_canchas, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(136, Short.MAX_VALUE))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(41, 41, 41)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(cb_estado, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(77, 77, 77)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(cb_categoria_canchas, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(190, Short.MAX_VALUE))
);
tab_tipo_lugar.addTab("Canchas", jPanel2);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 371, Short.MAX_VALUE)
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 378, Short.MAX_VALUE)
);
tab_tipo_lugar.addTab("casa", jPanel3);
Categoria.setText("Categoria");
cb_categoria_restaurante.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "chino", "mexicano", "italiano", "comida rápida" }));
jLabel8.setText("Calificacion");
cb_calificacion.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "1", "2", "3", "4", "5" }));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Categoria)
.addComponent(jLabel8))
.addGap(42, 42, 42)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cb_categoria_restaurante, 0, 130, Short.MAX_VALUE)
.addComponent(cb_calificacion, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addContainerGap(111, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(27, 27, 27)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(Categoria)
.addComponent(cb_categoria_restaurante, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(46, 46, 46)
.addComponent(jLabel7)
.addGap(26, 26, 26)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(cb_calificacion, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(186, Short.MAX_VALUE))
);
tab_tipo_lugar.addTab("Restaurante", jPanel1);
boton_guardar.setText("Guardar");
boton_guardar.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
boton_guardarMouseClicked(evt);
}
});
javax.swing.GroupLayout jd_agregarLayout = new javax.swing.GroupLayout(jd_agregar.getContentPane());
jd_agregar.getContentPane().setLayout(jd_agregarLayout);
jd_agregarLayout.setHorizontalGroup(
jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGap(401, 401, 401)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGap(49, 49, 49)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cb_entrada, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cb_salida, 0, 157, Short.MAX_VALUE)))
.addGroup(jd_agregarLayout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addComponent(tf_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 165, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tf_seguridad))
.addGroup(jd_agregarLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 119, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_agregarLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(boton_guardar, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(57, 57, 57)))
.addComponent(tab_tipo_lugar, javax.swing.GroupLayout.PREFERRED_SIZE, 376, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(47, 47, 47))
);
jd_agregarLayout.setVerticalGroup(
jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGap(35, 35, 35)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(tf_nombre, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(22, 22, 22)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(tf_seguridad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jd_agregarLayout.createSequentialGroup()
.addComponent(cb_entrada)
.addGap(8, 8, 8)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jd_agregarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(cb_salida, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(42, 42, 42)
.addComponent(boton_guardar, javax.swing.GroupLayout.PREFERRED_SIZE, 49, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jd_agregarLayout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(tab_tipo_lugar, javax.swing.GroupLayout.PREFERRED_SIZE, 406, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(30, Short.MAX_VALUE))
);
jLabel11.setText("Carreteras");
jLabel12.setText("Numero");
jLabel13.setText("Distancia en KM");
jLabel14.setText("Lugar de inicio");
jLabel15.setText("Lugar de finalizacion");
boton_guardar1.setText("Guardar");
boton_guardar1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
boton_guardar1MouseClicked(evt);
}
});
cb_inicio.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Comayagua", "Tegucigalpa", "Juticalpa", " " }));
cb_lsalida.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "San Pedro Sula", "La Ceiba", "La Paz", " " }));
javax.swing.GroupLayout jd_carreterasLayout = new javax.swing.GroupLayout(jd_carreteras.getContentPane());
jd_carreteras.getContentPane().setLayout(jd_carreterasLayout);
jd_carreterasLayout.setHorizontalGroup(
jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(315, 315, 315)
.addComponent(jLabel11))
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(37, 37, 37)
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(jLabel14)
.addComponent(jLabel15)
.addComponent(jLabel12))
.addGap(18, 18, 18)
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tf_distancia, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cb_inicio, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cb_lsalida, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(265, 265, 265)
.addComponent(boton_guardar1, javax.swing.GroupLayout.PREFERRED_SIZE, 133, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(289, Short.MAX_VALUE))
);
jd_carreterasLayout.setVerticalGroup(
jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(41, 41, 41)
.addComponent(jLabel11)
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(26, 26, 26)
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(tf_numero, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(33, 33, 33)
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel13)
.addComponent(tf_distancia, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jd_carreterasLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(50, 50, 50)
.addComponent(jLabel14))
.addGroup(jd_carreterasLayout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(cb_inicio, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(40, 40, 40)
.addComponent(jLabel15))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_carreterasLayout.createSequentialGroup()
.addGap(18, 18, 18)
.addComponent(cb_lsalida, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(71, 71, 71)
.addComponent(boton_guardar1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(68, Short.MAX_VALUE))
);
jLabel16.setText("Lista");
jLabel17.setText("Personas");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null},
{null, null, null, null},
{null, null, null, null},
{null, null, null, null}
},
new String [] {
"Title 1", "Title 2", "Title 3", "Title 4"
}
));
jScrollPane2.setViewportView(jTable1);
javax.swing.GroupLayout jd_tablaLayout = new javax.swing.GroupLayout(jd_tabla.getContentPane());
jd_tabla.getContentPane().setLayout(jd_tablaLayout);
jd_tablaLayout.setHorizontalGroup(
jd_tablaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_tablaLayout.createSequentialGroup()
.addGroup(jd_tablaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_tablaLayout.createSequentialGroup()
.addGap(265, 265, 265)
.addComponent(jLabel16))
.addGroup(jd_tablaLayout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jLabel17)
.addGap(18, 18, 18)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_tablaLayout.createSequentialGroup()
.addGap(0, 98, Short.MAX_VALUE)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 463, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(81, 81, 81))
);
jd_tablaLayout.setVerticalGroup(
jd_tablaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_tablaLayout.createSequentialGroup()
.addGap(39, 39, 39)
.addComponent(jLabel16)
.addGap(18, 18, 18)
.addGroup(jd_tablaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel17)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(97, 97, 97)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(197, Short.MAX_VALUE))
);
jLabel18.setText("Listar");
javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Lugares");
jt_lugar.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
jScrollPane3.setViewportView(jt_lugar);
jl_lugar.setModel(new javax.swing.AbstractListModel<String>() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public String getElementAt(int i) { return strings[i]; }
});
jScrollPane4.setViewportView(jl_lugar);
listar_tree.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "restaurantes", "canchas" }));
listar_tree.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
listar_treeItemStateChanged(evt);
}
});
javax.swing.GroupLayout jd_arbolLayout = new javax.swing.GroupLayout(jd_arbol.getContentPane());
jd_arbol.getContentPane().setLayout(jd_arbolLayout);
jd_arbolLayout.setHorizontalGroup(
jd_arbolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jd_arbolLayout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 183, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 237, Short.MAX_VALUE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(48, 48, 48))
.addGroup(jd_arbolLayout.createSequentialGroup()
.addGroup(jd_arbolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_arbolLayout.createSequentialGroup()
.addGap(331, 331, 331)
.addComponent(jLabel18))
.addGroup(jd_arbolLayout.createSequentialGroup()
.addGap(296, 296, 296)
.addComponent(listar_tree, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jd_arbolLayout.setVerticalGroup(
jd_arbolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jd_arbolLayout.createSequentialGroup()
.addGap(46, 46, 46)
.addComponent(jLabel18)
.addGap(45, 45, 45)
.addComponent(listar_tree, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(11, 11, 11)
.addGroup(jd_arbolLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 241, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(82, Short.MAX_VALUE))
);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
menu_contenedor.add(jMenu1);
menu_contenedor.add(jMenu2);
mi_menu.setText("Mi menu");
mi_menu.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
mi_menuActionPerformed(evt);
}
});
jm_agregar.setText("Agregar");
jm_lugar.setText("Lugar");
jm_lugar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jm_lugarActionPerformed(evt);
}
});
jm_agregar.add(jm_lugar);
jm_carretera.setText("Carretera");
jm_carretera.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jm_carreteraActionPerformed(evt);
}
});
jm_agregar.add(jm_carretera);
mi_menu.add(jm_agregar);
jm_listar.setText("Listar");
jm_tabla.setText("tabla");
jm_listar.add(jm_tabla);
jm_arbol.setText("Arbol");
jm_arbol.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jm_arbolActionPerformed(evt);
}
});
jm_listar.add(jm_arbol);
mi_menu.add(jm_listar);
menu_contenedor.add(mi_menu);
setJMenuBar(menu_contenedor);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 686, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 467, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void tf_nombreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tf_nombreActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_tf_nombreActionPerformed
private void mi_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mi_menuActionPerformed
}//GEN-LAST:event_mi_menuActionPerformed
private void jm_lugarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_lugarActionPerformed
jd_agregar.setModal(true);
jd_agregar.pack(); //acoplar el tamaño de la ventan a los objetos que estan incluidos en ella
jd_agregar.setLocationRelativeTo(this);
jd_agregar.setVisible(true);
}//GEN-LAST:event_jm_lugarActionPerformed
private void boton_guardarMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boton_guardarMouseClicked
String nombre, direccion, entradas, salida;
int seguridad;
String categoria1, categoria2, estado;
String calificacion;
//
nombre = tf_nombre.getText();
direccion = ta_direccion.getText();
entradas = cb_entrada.getSelectedItem().toString();
salida = cb_salida.getSelectedItem().toString();
seguridad = Integer.parseInt(tf_seguridad.getText());
categoria1 = cb_categoria_restaurante.getSelectedItem().toString();
categoria2 = cb_categoria_canchas.getSelectedItem().toString();
estado = cb_estado.getSelectedItem().toString();
calificacion = cb_calificacion.getSelectedItem().toString();
if (tab_tipo_lugar.getSelectedIndex() == 0) {
lista.add(new canchas(categoria2, estado, nombre, direccion, entradas, salida, seguridad));
} else if (tab_tipo_lugar.getSelectedIndex() == 1) {
lista.add(new casa(nombre, direccion, entradas, salida, seguridad));
} else if (tab_tipo_lugar.getSelectedIndex() == 2) {
lista.add(new restaurantes(categoria1, calificacion, nombre, direccion, entradas, salida, seguridad));
}
//
JOptionPane.showMessageDialog(this, "Se agrego exitosamente");
}//GEN-LAST:event_boton_guardarMouseClicked
private void boton_guardar1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_boton_guardar1MouseClicked
int numero, distancia;
String inicio, c_final;
numero = Integer.parseInt(tf_numero.getText());
distancia = Integer.parseInt(tf_distancia.getText());
inicio = cb_inicio.getSelectedItem().toString();
c_final = cb_lsalida.getSelectedItem().toString();
lista2.add(new carreteras(numero, distancia, inicio, c_final));
JOptionPane.showMessageDialog(this, "Agrego carretera");
}//GEN-LAST:event_boton_guardar1MouseClicked
private void jm_carreteraActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_carreteraActionPerformed
jd_carreteras.setModal(true);
jd_carreteras.pack(); //acoplar el tamaño de la ventan a los objetos que estan incluidos en ella
jd_carreteras.setLocationRelativeTo(this);
jd_carreteras.setVisible(true);
}//GEN-LAST:event_jm_carreteraActionPerformed
private void cb_entradaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cb_entradaItemStateChanged
}//GEN-LAST:event_cb_entradaItemStateChanged
private void jd_agregarWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_jd_agregarWindowActivated
if (jd_agregar.isActive()) {
DefaultComboBoxModel modelo
= new DefaultComboBoxModel();
for (carreteras t : lista2) {
modelo.addElement(t);
cb_salida.setModel(modelo);
}
cb_entrada.setModel(modelo);
}
}//GEN-LAST:event_jd_agregarWindowActivated
private void listar_treeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_listar_treeItemStateChanged
String nombre, direccion, entradas, salida;
int seguridad;
String categoria1, categoria2, estado;
String calificacion;
//
nombre = tf_nombre.getText();
direccion = ta_direccion.getText();
entradas = cb_entrada.getSelectedItem().toString();
salida = cb_salida.getSelectedItem().toString();
seguridad = Integer.parseInt(tf_seguridad.getText());
categoria1 = cb_categoria_restaurante.getSelectedItem().toString();
categoria2 = cb_categoria_canchas.getSelectedItem().toString();
estado = cb_estado.getSelectedItem().toString();
calificacion = cb_calificacion.getSelectedItem().toString();
if (listar_tree.getSelectedIndex() == 2) {
DefaultTreeModel y = (DefaultTreeModel) jt_lugar.getModel();
DefaultMutableTreeNode raiz = (DefaultMutableTreeNode) y.getRoot();
DefaultMutableTreeNode nodo_canchas;
nodo_canchas = new DefaultMutableTreeNode(new canchas(categoria2, estado, nombre, direccion, entradas, salida, seguridad));
DefaultMutableTreeNode categoria;
DefaultMutableTreeNode nombre1;
categoria = new DefaultMutableTreeNode(categoria2 = cb_categoria_canchas.getSelectedItem().toString());
nombre1 = new DefaultMutableTreeNode(tf_nombre.getText());
categoria.add(nombre1);
nodo_canchas.add(categoria);
nodo_canchas.add(nombre1);
raiz.add(nodo_canchas);
y.reload();
nodo_canchas.add(nombre1);
raiz.add(nodo_canchas);
y.reload();
} else if (listar_tree.getSelectedIndex() == 3) {
DefaultTreeModel m = (DefaultTreeModel) jt_lugar.getModel();
DefaultMutableTreeNode raiz = (DefaultMutableTreeNode) m.getRoot();
DefaultMutableTreeNode nodo_restaurantes;
nodo_restaurantes = new DefaultMutableTreeNode(new restaurantes(categoria1, calificacion, nombre, direccion, entradas, salida, seguridad));
DefaultMutableTreeNode categoriaa;
DefaultMutableTreeNode nombre2;
categoriaa = new DefaultMutableTreeNode(categoria1 = cb_categoria_restaurante.getSelectedItem().toString());
nombre2 = new DefaultMutableTreeNode(tf_nombre.getText());
categoriaa.add(nombre2);
nodo_restaurantes.add(categoriaa);
nodo_restaurantes.add(nombre2);
raiz.add(nodo_restaurantes);
m.reload();
nodo_restaurantes.add(nombre2);
raiz.add(nodo_restaurantes);
m.reload();
}
}//GEN-LAST:event_listar_treeItemStateChanged
private void jm_arbolActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jm_arbolActionPerformed
jd_arbol.setModal(true);
jd_arbol.pack(); //acoplar el tamaño de la ventan a los objetos que estan incluidos en ella
jd_arbol.setLocationRelativeTo(this);
jd_arbol.setVisible(true);
}//GEN-LAST:event_jm_arbolActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new principal().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel Categoria;
private javax.swing.JButton boton_guardar;
private javax.swing.JButton boton_guardar1;
private javax.swing.JComboBox<String> cb_calificacion;
private javax.swing.JComboBox<String> cb_categoria_canchas;
private javax.swing.JComboBox<String> cb_categoria_restaurante;
private javax.swing.JComboBox<String> cb_entrada;
private javax.swing.JComboBox<String> cb_estado;
private javax.swing.JComboBox<String> cb_inicio;
private javax.swing.JComboBox<String> cb_lsalida;
private javax.swing.JComboBox<String> cb_salida;
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JTable jTable1;
private javax.swing.JDialog jd_agregar;
private javax.swing.JDialog jd_arbol;
private javax.swing.JDialog jd_carreteras;
private javax.swing.JDialog jd_tabla;
private javax.swing.JList<String> jl_lugar;
private javax.swing.JMenu jm_agregar;
private javax.swing.JMenuItem jm_arbol;
private javax.swing.JMenuItem jm_carretera;
private javax.swing.JMenu jm_listar;
private javax.swing.JMenuItem jm_lugar;
private javax.swing.JMenuItem jm_tabla;
private javax.swing.JTree jt_lugar;
private javax.swing.JComboBox<String> listar_tree;
private javax.swing.JMenuBar menu_contenedor;
private javax.swing.JMenu mi_menu;
private javax.swing.JTextArea ta_direccion;
private javax.swing.JTabbedPane tab_tipo_lugar;
private javax.swing.JTextField tf_distancia;
private javax.swing.JTextField tf_nombre;
private javax.swing.JTextField tf_numero;
private javax.swing.JTextField tf_seguridad;
// End of variables declaration//GEN-END:variables
ArrayList<lugar> lista = new ArrayList();
ArrayList<carreteras> lista2 = new ArrayList();
DefaultMutableTreeNode nodo_seleccionado;
lugar lugar_seleccionada;
} | [
"public",
"class",
"principal",
"extends",
"javax",
".",
"swing",
".",
"JFrame",
"{",
"/**\n * Creates new form principal\n */",
"public",
"principal",
"(",
")",
"{",
"initComponents",
"(",
")",
";",
"}",
"/**\n * This method is called from within the constructor to initialize the form.\n * WARNING: Do NOT modify this code. The content of this method is always\n * regenerated by the Form Editor.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"private",
"void",
"initComponents",
"(",
")",
"{",
"jd_agregar",
"=",
"new",
"javax",
".",
"swing",
".",
"JDialog",
"(",
")",
";",
"jLabel1",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel2",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel3",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"tf_nombre",
"=",
"new",
"javax",
".",
"swing",
".",
"JTextField",
"(",
")",
";",
"jScrollPane1",
"=",
"new",
"javax",
".",
"swing",
".",
"JScrollPane",
"(",
")",
";",
"ta_direccion",
"=",
"new",
"javax",
".",
"swing",
".",
"JTextArea",
"(",
")",
";",
"jLabel4",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"tf_seguridad",
"=",
"new",
"javax",
".",
"swing",
".",
"JTextField",
"(",
")",
";",
"jLabel5",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"cb_entrada",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"jLabel6",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"cb_salida",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"tab_tipo_lugar",
"=",
"new",
"javax",
".",
"swing",
".",
"JTabbedPane",
"(",
")",
";",
"jPanel2",
"=",
"new",
"javax",
".",
"swing",
".",
"JPanel",
"(",
")",
";",
"jLabel9",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel10",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"cb_estado",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"cb_categoria_canchas",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"jPanel3",
"=",
"new",
"javax",
".",
"swing",
".",
"JPanel",
"(",
")",
";",
"jPanel1",
"=",
"new",
"javax",
".",
"swing",
".",
"JPanel",
"(",
")",
";",
"Categoria",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"cb_categoria_restaurante",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"jLabel7",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel8",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"cb_calificacion",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"boton_guardar",
"=",
"new",
"javax",
".",
"swing",
".",
"JButton",
"(",
")",
";",
"jd_carreteras",
"=",
"new",
"javax",
".",
"swing",
".",
"JDialog",
"(",
")",
";",
"jLabel11",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel12",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"tf_numero",
"=",
"new",
"javax",
".",
"swing",
".",
"JTextField",
"(",
")",
";",
"jLabel13",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"tf_distancia",
"=",
"new",
"javax",
".",
"swing",
".",
"JTextField",
"(",
")",
";",
"jLabel14",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel15",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"boton_guardar1",
"=",
"new",
"javax",
".",
"swing",
".",
"JButton",
"(",
")",
";",
"cb_inicio",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"cb_lsalida",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"jd_tabla",
"=",
"new",
"javax",
".",
"swing",
".",
"JDialog",
"(",
")",
";",
"jLabel16",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jLabel17",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jComboBox1",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"jScrollPane2",
"=",
"new",
"javax",
".",
"swing",
".",
"JScrollPane",
"(",
")",
";",
"jTable1",
"=",
"new",
"javax",
".",
"swing",
".",
"JTable",
"(",
")",
";",
"jd_arbol",
"=",
"new",
"javax",
".",
"swing",
".",
"JDialog",
"(",
")",
";",
"jLabel18",
"=",
"new",
"javax",
".",
"swing",
".",
"JLabel",
"(",
")",
";",
"jScrollPane3",
"=",
"new",
"javax",
".",
"swing",
".",
"JScrollPane",
"(",
")",
";",
"jt_lugar",
"=",
"new",
"javax",
".",
"swing",
".",
"JTree",
"(",
")",
";",
"jScrollPane4",
"=",
"new",
"javax",
".",
"swing",
".",
"JScrollPane",
"(",
")",
";",
"jl_lugar",
"=",
"new",
"javax",
".",
"swing",
".",
"JList",
"<",
">",
"(",
")",
";",
"listar_tree",
"=",
"new",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
">",
"(",
")",
";",
"menu_contenedor",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenuBar",
"(",
")",
";",
"jMenu1",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenu",
"(",
")",
";",
"jMenu2",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenu",
"(",
")",
";",
"mi_menu",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenu",
"(",
")",
";",
"jm_agregar",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenu",
"(",
")",
";",
"jm_lugar",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenuItem",
"(",
")",
";",
"jm_carretera",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenuItem",
"(",
")",
";",
"jm_listar",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenu",
"(",
")",
";",
"jm_tabla",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenuItem",
"(",
")",
";",
"jm_arbol",
"=",
"new",
"javax",
".",
"swing",
".",
"JMenuItem",
"(",
")",
";",
"jd_agregar",
".",
"addWindowListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"WindowAdapter",
"(",
")",
"{",
"public",
"void",
"windowActivated",
"(",
"java",
".",
"awt",
".",
"event",
".",
"WindowEvent",
"evt",
")",
"{",
"jd_agregarWindowActivated",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jLabel1",
".",
"setFont",
"(",
"new",
"java",
".",
"awt",
".",
"Font",
"(",
"\"",
"Tahoma",
"\"",
",",
"0",
",",
"18",
")",
")",
";",
"jLabel1",
".",
"setText",
"(",
"\"",
"Lugar",
"\"",
")",
";",
"jLabel2",
".",
"setText",
"(",
"\"",
"Nombre",
"\"",
")",
";",
"jLabel3",
".",
"setText",
"(",
"\"",
"Direccion",
"\"",
")",
";",
"tf_nombre",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"tf_nombreActionPerformed",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"ta_direccion",
".",
"setColumns",
"(",
"20",
")",
";",
"ta_direccion",
".",
"setRows",
"(",
"5",
")",
";",
"jScrollPane1",
".",
"setViewportView",
"(",
"ta_direccion",
")",
";",
"jLabel4",
".",
"setText",
"(",
"\"",
"Seguridad",
"\"",
")",
";",
"jLabel5",
".",
"setText",
"(",
"\"",
"Carreteras de entrada",
"\"",
")",
";",
"cb_entrada",
".",
"addItemListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ItemListener",
"(",
")",
"{",
"public",
"void",
"itemStateChanged",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ItemEvent",
"evt",
")",
"{",
"cb_entradaItemStateChanged",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jLabel6",
".",
"setText",
"(",
"\"",
"Carretera de salida",
"\"",
")",
";",
"cb_salida",
".",
"setMaximumRowCount",
"(",
"0",
")",
";",
"jLabel9",
".",
"setText",
"(",
"\"",
"Estado",
"\"",
")",
";",
"jLabel10",
".",
"setText",
"(",
"\"",
"Categoria",
"\"",
")",
";",
"cb_estado",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"ocupado",
"\"",
",",
"\"",
"libre",
"\"",
"}",
")",
")",
";",
"cb_categoria_canchas",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"football",
"\"",
",",
"\"",
"básquet\"",
",",
" ",
"t",
"enis\"",
",",
" ",
"v",
"olley\"",
" ",
")",
")",
";",
"",
"javax",
".",
"swing",
".",
"GroupLayout",
"jPanel2Layout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jPanel2",
")",
";",
"jPanel2",
".",
"setLayout",
"(",
"jPanel2Layout",
")",
";",
"jPanel2Layout",
".",
"setHorizontalGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"31",
",",
"31",
",",
"31",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel9",
")",
".",
"addComponent",
"(",
"jLabel10",
")",
")",
".",
"addGap",
"(",
"47",
",",
"47",
",",
"47",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
",",
"false",
")",
".",
"addComponent",
"(",
"cb_estado",
",",
"0",
",",
"110",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"cb_categoria_canchas",
",",
"0",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
".",
"addContainerGap",
"(",
"136",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jPanel2Layout",
".",
"setVerticalGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"41",
",",
"41",
",",
"41",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel9",
")",
".",
"addComponent",
"(",
"cb_estado",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"32",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"77",
",",
"77",
",",
"77",
")",
".",
"addGroup",
"(",
"jPanel2Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel10",
")",
".",
"addComponent",
"(",
"cb_categoria_canchas",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"38",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addContainerGap",
"(",
"190",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"tab_tipo_lugar",
".",
"addTab",
"(",
"\"",
"Canchas",
"\"",
",",
"jPanel2",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jPanel3Layout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jPanel3",
")",
";",
"jPanel3",
".",
"setLayout",
"(",
"jPanel3Layout",
")",
";",
"jPanel3Layout",
".",
"setHorizontalGroup",
"(",
"jPanel3Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGap",
"(",
"0",
",",
"371",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
";",
"jPanel3Layout",
".",
"setVerticalGroup",
"(",
"jPanel3Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGap",
"(",
"0",
",",
"378",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
";",
"tab_tipo_lugar",
".",
"addTab",
"(",
"\"",
"casa",
"\"",
",",
"jPanel3",
")",
";",
"Categoria",
".",
"setText",
"(",
"\"",
"Categoria",
"\"",
")",
";",
"cb_categoria_restaurante",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"chino",
"\"",
",",
"\"",
"mexicano",
"\"",
",",
"\"",
"italiano",
"\"",
",",
"\"",
"comida rápida\"",
" ",
")",
")",
";",
"",
"jLabel8",
".",
"setText",
"(",
"\"",
"Calificacion",
"\"",
")",
";",
"cb_calificacion",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"1",
"\"",
",",
"\"",
"2",
"\"",
",",
"\"",
"3",
"\"",
",",
"\"",
"4",
"\"",
",",
"\"",
"5",
"\"",
"}",
")",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jPanel1Layout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jPanel1",
")",
";",
"jPanel1",
".",
"setLayout",
"(",
"jPanel1Layout",
")",
";",
"jPanel1Layout",
".",
"setHorizontalGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"35",
",",
"35",
",",
"35",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel7",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"Categoria",
")",
".",
"addComponent",
"(",
"jLabel8",
")",
")",
".",
"addGap",
"(",
"42",
",",
"42",
",",
"42",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
",",
"false",
")",
".",
"addComponent",
"(",
"cb_categoria_restaurante",
",",
"0",
",",
"130",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"cb_calificacion",
",",
"0",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
")",
".",
"addContainerGap",
"(",
"111",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jPanel1Layout",
".",
"setVerticalGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"27",
",",
"27",
",",
"27",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"Categoria",
")",
".",
"addComponent",
"(",
"cb_categoria_restaurante",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"43",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"46",
",",
"46",
",",
"46",
")",
".",
"addComponent",
"(",
"jLabel7",
")",
".",
"addGap",
"(",
"26",
",",
"26",
",",
"26",
")",
".",
"addGroup",
"(",
"jPanel1Layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel8",
")",
".",
"addComponent",
"(",
"cb_calificacion",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"50",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addContainerGap",
"(",
"186",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"tab_tipo_lugar",
".",
"addTab",
"(",
"\"",
"Restaurante",
"\"",
",",
"jPanel1",
")",
";",
"boton_guardar",
".",
"setText",
"(",
"\"",
"Guardar",
"\"",
")",
";",
"boton_guardar",
".",
"addMouseListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"MouseAdapter",
"(",
")",
"{",
"public",
"void",
"mouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"boton_guardarMouseClicked",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jd_agregarLayout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jd_agregar",
".",
"getContentPane",
"(",
")",
")",
";",
"jd_agregar",
".",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"jd_agregarLayout",
")",
";",
"jd_agregarLayout",
".",
"setHorizontalGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"401",
",",
"401",
",",
"401",
")",
".",
"addComponent",
"(",
"jLabel1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"54",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addContainerGap",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"49",
",",
"49",
",",
"49",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel5",
")",
".",
"addComponent",
"(",
"jLabel6",
")",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"UNRELATED",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
",",
"false",
")",
".",
"addComponent",
"(",
"cb_entrada",
",",
"0",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"cb_salida",
",",
"0",
",",
"157",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addComponent",
"(",
"jLabel2",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addComponent",
"(",
"tf_nombre",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"165",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"TRAILING",
",",
"false",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addComponent",
"(",
"jLabel4",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"RELATED",
")",
".",
"addComponent",
"(",
"tf_seguridad",
")",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addComponent",
"(",
"jLabel3",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"UNRELATED",
")",
".",
"addComponent",
"(",
"jScrollPane1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"RELATED",
",",
"119",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
".",
"addGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"TRAILING",
",",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addContainerGap",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"boton_guardar",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"112",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGap",
"(",
"57",
",",
"57",
",",
"57",
")",
")",
")",
".",
"addComponent",
"(",
"tab_tipo_lugar",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"376",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGap",
"(",
"47",
",",
"47",
",",
"47",
")",
")",
")",
";",
"jd_agregarLayout",
".",
"setVerticalGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"19",
",",
"19",
",",
"19",
")",
".",
"addComponent",
"(",
"jLabel1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"24",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"35",
",",
"35",
",",
"35",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel2",
")",
".",
"addComponent",
"(",
"tf_nombre",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"29",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel3",
")",
".",
"addComponent",
"(",
"jScrollPane1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"22",
",",
"22",
",",
"22",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel4",
")",
".",
"addComponent",
"(",
"tf_seguridad",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
",",
"false",
")",
".",
"addComponent",
"(",
"jLabel5",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"44",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addComponent",
"(",
"cb_entrada",
")",
".",
"addGap",
"(",
"8",
",",
"8",
",",
"8",
")",
")",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"RELATED",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel6",
")",
".",
"addComponent",
"(",
"cb_salida",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"34",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"42",
",",
"42",
",",
"42",
")",
".",
"addComponent",
"(",
"boton_guardar",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"49",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGroup",
"(",
"jd_agregarLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addComponent",
"(",
"tab_tipo_lugar",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"406",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addContainerGap",
"(",
"30",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jLabel11",
".",
"setText",
"(",
"\"",
"Carreteras",
"\"",
")",
";",
"jLabel12",
".",
"setText",
"(",
"\"",
"Numero",
"\"",
")",
";",
"jLabel13",
".",
"setText",
"(",
"\"",
"Distancia en KM",
"\"",
")",
";",
"jLabel14",
".",
"setText",
"(",
"\"",
"Lugar de inicio",
"\"",
")",
";",
"jLabel15",
".",
"setText",
"(",
"\"",
"Lugar de finalizacion",
"\"",
")",
";",
"boton_guardar1",
".",
"setText",
"(",
"\"",
"Guardar",
"\"",
")",
";",
"boton_guardar1",
".",
"addMouseListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"MouseAdapter",
"(",
")",
"{",
"public",
"void",
"mouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"boton_guardar1MouseClicked",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"cb_inicio",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"Comayagua",
"\"",
",",
"\"",
"Tegucigalpa",
"\"",
",",
"\"",
"Juticalpa",
"\"",
",",
"\"",
" ",
"\"",
"}",
")",
")",
";",
"cb_lsalida",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"San Pedro Sula",
"\"",
",",
"\"",
"La Ceiba",
"\"",
",",
"\"",
"La Paz",
"\"",
",",
"\"",
" ",
"\"",
"}",
")",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jd_carreterasLayout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jd_carreteras",
".",
"getContentPane",
"(",
")",
")",
";",
"jd_carreteras",
".",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"jd_carreterasLayout",
")",
";",
"jd_carreterasLayout",
".",
"setHorizontalGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"315",
",",
"315",
",",
"315",
")",
".",
"addComponent",
"(",
"jLabel11",
")",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"37",
",",
"37",
",",
"37",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel13",
")",
".",
"addComponent",
"(",
"jLabel14",
")",
".",
"addComponent",
"(",
"jLabel15",
")",
".",
"addComponent",
"(",
"jLabel12",
")",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"tf_numero",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"125",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addComponent",
"(",
"tf_distancia",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"115",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addComponent",
"(",
"cb_inicio",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"106",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addComponent",
"(",
"cb_lsalida",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"106",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"265",
",",
"265",
",",
"265",
")",
".",
"addComponent",
"(",
"boton_guardar1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"133",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addContainerGap",
"(",
"289",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jd_carreterasLayout",
".",
"setVerticalGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"41",
",",
"41",
",",
"41",
")",
".",
"addComponent",
"(",
"jLabel11",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"26",
",",
"26",
",",
"26",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel12",
")",
".",
"addComponent",
"(",
"tf_numero",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"43",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"33",
",",
"33",
",",
"33",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jLabel13",
")",
".",
"addComponent",
"(",
"tf_distancia",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"36",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"50",
",",
"50",
",",
"50",
")",
".",
"addComponent",
"(",
"jLabel14",
")",
")",
".",
"addGroup",
"(",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"36",
",",
"36",
",",
"36",
")",
".",
"addComponent",
"(",
"cb_inicio",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"39",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addGap",
"(",
"40",
",",
"40",
",",
"40",
")",
".",
"addComponent",
"(",
"jLabel15",
")",
")",
".",
"addGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"TRAILING",
",",
"jd_carreterasLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addComponent",
"(",
"cb_lsalida",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"36",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addGap",
"(",
"71",
",",
"71",
",",
"71",
")",
".",
"addComponent",
"(",
"boton_guardar1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"68",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addContainerGap",
"(",
"68",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jLabel16",
".",
"setText",
"(",
"\"",
"Lista",
"\"",
")",
";",
"jLabel17",
".",
"setText",
"(",
"\"",
"Personas",
"\"",
")",
";",
"jTable1",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"table",
".",
"DefaultTableModel",
"(",
"new",
"Object",
"[",
"]",
"[",
"]",
"{",
"{",
"null",
",",
"null",
",",
"null",
",",
"null",
"}",
",",
"{",
"null",
",",
"null",
",",
"null",
",",
"null",
"}",
",",
"{",
"null",
",",
"null",
",",
"null",
",",
"null",
"}",
",",
"{",
"null",
",",
"null",
",",
"null",
",",
"null",
"}",
"}",
",",
"new",
"String",
"[",
"]",
"{",
"\"",
"Title 1",
"\"",
",",
"\"",
"Title 2",
"\"",
",",
"\"",
"Title 3",
"\"",
",",
"\"",
"Title 4",
"\"",
"}",
")",
")",
";",
"jScrollPane2",
".",
"setViewportView",
"(",
"jTable1",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jd_tablaLayout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jd_tabla",
".",
"getContentPane",
"(",
")",
")",
";",
"jd_tabla",
".",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"jd_tablaLayout",
")",
";",
"jd_tablaLayout",
".",
"setHorizontalGroup",
"(",
"jd_tablaLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"265",
",",
"265",
",",
"265",
")",
".",
"addComponent",
"(",
"jLabel16",
")",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"21",
",",
"21",
",",
"21",
")",
".",
"addComponent",
"(",
"jLabel17",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addComponent",
"(",
"jComboBox1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"93",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addContainerGap",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
".",
"addGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"TRAILING",
",",
"jd_tablaLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"0",
",",
"98",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"jScrollPane2",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"463",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGap",
"(",
"81",
",",
"81",
",",
"81",
")",
")",
")",
";",
"jd_tablaLayout",
".",
"setVerticalGroup",
"(",
"jd_tablaLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"39",
",",
"39",
",",
"39",
")",
".",
"addComponent",
"(",
"jLabel16",
")",
".",
"addGap",
"(",
"18",
",",
"18",
",",
"18",
")",
".",
"addGroup",
"(",
"jd_tablaLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"BASELINE",
")",
".",
"addComponent",
"(",
"jLabel17",
")",
".",
"addComponent",
"(",
"jComboBox1",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"42",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addGap",
"(",
"97",
",",
"97",
",",
"97",
")",
".",
"addComponent",
"(",
"jScrollPane2",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"162",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addContainerGap",
"(",
"197",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jLabel18",
".",
"setText",
"(",
"\"",
"Listar",
"\"",
")",
";",
"javax",
".",
"swing",
".",
"tree",
".",
"DefaultMutableTreeNode",
"treeNode1",
"=",
"new",
"javax",
".",
"swing",
".",
"tree",
".",
"DefaultMutableTreeNode",
"(",
"\"",
"Lugares",
"\"",
")",
";",
"jt_lugar",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"tree",
".",
"DefaultTreeModel",
"(",
"treeNode1",
")",
")",
";",
"jScrollPane3",
".",
"setViewportView",
"(",
"jt_lugar",
")",
";",
"jl_lugar",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"AbstractListModel",
"<",
"String",
">",
"(",
")",
"{",
"String",
"[",
"]",
"strings",
"=",
"{",
"\"",
"Item 1",
"\"",
",",
"\"",
"Item 2",
"\"",
",",
"\"",
"Item 3",
"\"",
",",
"\"",
"Item 4",
"\"",
",",
"\"",
"Item 5",
"\"",
"}",
";",
"public",
"int",
"getSize",
"(",
")",
"{",
"return",
"strings",
".",
"length",
";",
"}",
"public",
"String",
"getElementAt",
"(",
"int",
"i",
")",
"{",
"return",
"strings",
"[",
"i",
"]",
";",
"}",
"}",
")",
";",
"jScrollPane4",
".",
"setViewportView",
"(",
"jl_lugar",
")",
";",
"listar_tree",
".",
"setModel",
"(",
"new",
"javax",
".",
"swing",
".",
"DefaultComboBoxModel",
"<",
">",
"(",
"new",
"String",
"[",
"]",
"{",
"\"",
"restaurantes",
"\"",
",",
"\"",
"canchas",
"\"",
"}",
")",
")",
";",
"listar_tree",
".",
"addItemListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ItemListener",
"(",
")",
"{",
"public",
"void",
"itemStateChanged",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ItemEvent",
"evt",
")",
"{",
"listar_treeItemStateChanged",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"jd_arbolLayout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"jd_arbol",
".",
"getContentPane",
"(",
")",
")",
";",
"jd_arbol",
".",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"jd_arbolLayout",
")",
";",
"jd_arbolLayout",
".",
"setHorizontalGroup",
"(",
"jd_arbolLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"TRAILING",
",",
"jd_arbolLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"42",
",",
"42",
",",
"42",
")",
".",
"addComponent",
"(",
"jScrollPane4",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"183",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addPreferredGap",
"(",
"javax",
".",
"swing",
".",
"LayoutStyle",
".",
"ComponentPlacement",
".",
"RELATED",
",",
"237",
",",
"Short",
".",
"MAX_VALUE",
")",
".",
"addComponent",
"(",
"jScrollPane3",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"208",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGap",
"(",
"48",
",",
"48",
",",
"48",
")",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"331",
",",
"331",
",",
"331",
")",
".",
"addComponent",
"(",
"jLabel18",
")",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"296",
",",
"296",
",",
"296",
")",
".",
"addComponent",
"(",
"listar_tree",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"110",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
")",
".",
"addContainerGap",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"DEFAULT_SIZE",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"jd_arbolLayout",
".",
"setVerticalGroup",
"(",
"jd_arbolLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createSequentialGroup",
"(",
")",
".",
"addGap",
"(",
"46",
",",
"46",
",",
"46",
")",
".",
"addComponent",
"(",
"jLabel18",
")",
".",
"addGap",
"(",
"45",
",",
"45",
",",
"45",
")",
".",
"addComponent",
"(",
"listar_tree",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"54",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addGap",
"(",
"11",
",",
"11",
",",
"11",
")",
".",
"addGroup",
"(",
"jd_arbolLayout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addComponent",
"(",
"jScrollPane3",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"260",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
".",
"addComponent",
"(",
"jScrollPane4",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
",",
"241",
",",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"PREFERRED_SIZE",
")",
")",
".",
"addContainerGap",
"(",
"82",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
")",
";",
"setDefaultCloseOperation",
"(",
"javax",
".",
"swing",
".",
"WindowConstants",
".",
"EXIT_ON_CLOSE",
")",
";",
"menu_contenedor",
".",
"add",
"(",
"jMenu1",
")",
";",
"menu_contenedor",
".",
"add",
"(",
"jMenu2",
")",
";",
"mi_menu",
".",
"setText",
"(",
"\"",
"Mi menu",
"\"",
")",
";",
"mi_menu",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"mi_menuActionPerformed",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jm_agregar",
".",
"setText",
"(",
"\"",
"Agregar",
"\"",
")",
";",
"jm_lugar",
".",
"setText",
"(",
"\"",
"Lugar",
"\"",
")",
";",
"jm_lugar",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jm_lugarActionPerformed",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jm_agregar",
".",
"add",
"(",
"jm_lugar",
")",
";",
"jm_carretera",
".",
"setText",
"(",
"\"",
"Carretera",
"\"",
")",
";",
"jm_carretera",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jm_carreteraActionPerformed",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jm_agregar",
".",
"add",
"(",
"jm_carretera",
")",
";",
"mi_menu",
".",
"add",
"(",
"jm_agregar",
")",
";",
"jm_listar",
".",
"setText",
"(",
"\"",
"Listar",
"\"",
")",
";",
"jm_tabla",
".",
"setText",
"(",
"\"",
"tabla",
"\"",
")",
";",
"jm_listar",
".",
"add",
"(",
"jm_tabla",
")",
";",
"jm_arbol",
".",
"setText",
"(",
"\"",
"Arbol",
"\"",
")",
";",
"jm_arbol",
".",
"addActionListener",
"(",
"new",
"java",
".",
"awt",
".",
"event",
".",
"ActionListener",
"(",
")",
"{",
"public",
"void",
"actionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jm_arbolActionPerformed",
"(",
"evt",
")",
";",
"}",
"}",
")",
";",
"jm_listar",
".",
"add",
"(",
"jm_arbol",
")",
";",
"mi_menu",
".",
"add",
"(",
"jm_listar",
")",
";",
"menu_contenedor",
".",
"add",
"(",
"mi_menu",
")",
";",
"setJMenuBar",
"(",
"menu_contenedor",
")",
";",
"javax",
".",
"swing",
".",
"GroupLayout",
"layout",
"=",
"new",
"javax",
".",
"swing",
".",
"GroupLayout",
"(",
"getContentPane",
"(",
")",
")",
";",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"layout",
")",
";",
"layout",
".",
"setHorizontalGroup",
"(",
"layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGap",
"(",
"0",
",",
"686",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
";",
"layout",
".",
"setVerticalGroup",
"(",
"layout",
".",
"createParallelGroup",
"(",
"javax",
".",
"swing",
".",
"GroupLayout",
".",
"Alignment",
".",
"LEADING",
")",
".",
"addGap",
"(",
"0",
",",
"467",
",",
"Short",
".",
"MAX_VALUE",
")",
")",
";",
"pack",
"(",
")",
";",
"}",
"private",
"void",
"tf_nombreActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"}",
"private",
"void",
"mi_menuActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"}",
"private",
"void",
"jm_lugarActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jd_agregar",
".",
"setModal",
"(",
"true",
")",
";",
"jd_agregar",
".",
"pack",
"(",
")",
";",
"jd_agregar",
".",
"setLocationRelativeTo",
"(",
"this",
")",
";",
"jd_agregar",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"private",
"void",
"boton_guardarMouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"String",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
";",
"int",
"seguridad",
";",
"String",
"categoria1",
",",
"categoria2",
",",
"estado",
";",
"String",
"calificacion",
";",
"nombre",
"=",
"tf_nombre",
".",
"getText",
"(",
")",
";",
"direccion",
"=",
"ta_direccion",
".",
"getText",
"(",
")",
";",
"entradas",
"=",
"cb_entrada",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"salida",
"=",
"cb_salida",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"seguridad",
"=",
"Integer",
".",
"parseInt",
"(",
"tf_seguridad",
".",
"getText",
"(",
")",
")",
";",
"categoria1",
"=",
"cb_categoria_restaurante",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"categoria2",
"=",
"cb_categoria_canchas",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"estado",
"=",
"cb_estado",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"calificacion",
"=",
"cb_calificacion",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"tab_tipo_lugar",
".",
"getSelectedIndex",
"(",
")",
"==",
"0",
")",
"{",
"lista",
".",
"add",
"(",
"new",
"canchas",
"(",
"categoria2",
",",
"estado",
",",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
",",
"seguridad",
")",
")",
";",
"}",
"else",
"if",
"(",
"tab_tipo_lugar",
".",
"getSelectedIndex",
"(",
")",
"==",
"1",
")",
"{",
"lista",
".",
"add",
"(",
"new",
"casa",
"(",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
",",
"seguridad",
")",
")",
";",
"}",
"else",
"if",
"(",
"tab_tipo_lugar",
".",
"getSelectedIndex",
"(",
")",
"==",
"2",
")",
"{",
"lista",
".",
"add",
"(",
"new",
"restaurantes",
"(",
"categoria1",
",",
"calificacion",
",",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
",",
"seguridad",
")",
")",
";",
"}",
"JOptionPane",
".",
"showMessageDialog",
"(",
"this",
",",
"\"",
"Se agrego exitosamente",
"\"",
")",
";",
"}",
"private",
"void",
"boton_guardar1MouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"int",
"numero",
",",
"distancia",
";",
"String",
"inicio",
",",
"c_final",
";",
"numero",
"=",
"Integer",
".",
"parseInt",
"(",
"tf_numero",
".",
"getText",
"(",
")",
")",
";",
"distancia",
"=",
"Integer",
".",
"parseInt",
"(",
"tf_distancia",
".",
"getText",
"(",
")",
")",
";",
"inicio",
"=",
"cb_inicio",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"c_final",
"=",
"cb_lsalida",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"lista2",
".",
"add",
"(",
"new",
"carreteras",
"(",
"numero",
",",
"distancia",
",",
"inicio",
",",
"c_final",
")",
")",
";",
"JOptionPane",
".",
"showMessageDialog",
"(",
"this",
",",
"\"",
"Agrego carretera",
"\"",
")",
";",
"}",
"private",
"void",
"jm_carreteraActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jd_carreteras",
".",
"setModal",
"(",
"true",
")",
";",
"jd_carreteras",
".",
"pack",
"(",
")",
";",
"jd_carreteras",
".",
"setLocationRelativeTo",
"(",
"this",
")",
";",
"jd_carreteras",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"private",
"void",
"cb_entradaItemStateChanged",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ItemEvent",
"evt",
")",
"{",
"}",
"private",
"void",
"jd_agregarWindowActivated",
"(",
"java",
".",
"awt",
".",
"event",
".",
"WindowEvent",
"evt",
")",
"{",
"if",
"(",
"jd_agregar",
".",
"isActive",
"(",
")",
")",
"{",
"DefaultComboBoxModel",
"modelo",
"=",
"new",
"DefaultComboBoxModel",
"(",
")",
";",
"for",
"(",
"carreteras",
"t",
":",
"lista2",
")",
"{",
"modelo",
".",
"addElement",
"(",
"t",
")",
";",
"cb_salida",
".",
"setModel",
"(",
"modelo",
")",
";",
"}",
"cb_entrada",
".",
"setModel",
"(",
"modelo",
")",
";",
"}",
"}",
"private",
"void",
"listar_treeItemStateChanged",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ItemEvent",
"evt",
")",
"{",
"String",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
";",
"int",
"seguridad",
";",
"String",
"categoria1",
",",
"categoria2",
",",
"estado",
";",
"String",
"calificacion",
";",
"nombre",
"=",
"tf_nombre",
".",
"getText",
"(",
")",
";",
"direccion",
"=",
"ta_direccion",
".",
"getText",
"(",
")",
";",
"entradas",
"=",
"cb_entrada",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"salida",
"=",
"cb_salida",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"seguridad",
"=",
"Integer",
".",
"parseInt",
"(",
"tf_seguridad",
".",
"getText",
"(",
")",
")",
";",
"categoria1",
"=",
"cb_categoria_restaurante",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"categoria2",
"=",
"cb_categoria_canchas",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"estado",
"=",
"cb_estado",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"calificacion",
"=",
"cb_calificacion",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
";",
"if",
"(",
"listar_tree",
".",
"getSelectedIndex",
"(",
")",
"==",
"2",
")",
"{",
"DefaultTreeModel",
"y",
"=",
"(",
"DefaultTreeModel",
")",
"jt_lugar",
".",
"getModel",
"(",
")",
";",
"DefaultMutableTreeNode",
"raiz",
"=",
"(",
"DefaultMutableTreeNode",
")",
"y",
".",
"getRoot",
"(",
")",
";",
"DefaultMutableTreeNode",
"nodo_canchas",
";",
"nodo_canchas",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"new",
"canchas",
"(",
"categoria2",
",",
"estado",
",",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
",",
"seguridad",
")",
")",
";",
"DefaultMutableTreeNode",
"categoria",
";",
"DefaultMutableTreeNode",
"nombre1",
";",
"categoria",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"categoria2",
"=",
"cb_categoria_canchas",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"nombre1",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"tf_nombre",
".",
"getText",
"(",
")",
")",
";",
"categoria",
".",
"add",
"(",
"nombre1",
")",
";",
"nodo_canchas",
".",
"add",
"(",
"categoria",
")",
";",
"nodo_canchas",
".",
"add",
"(",
"nombre1",
")",
";",
"raiz",
".",
"add",
"(",
"nodo_canchas",
")",
";",
"y",
".",
"reload",
"(",
")",
";",
"nodo_canchas",
".",
"add",
"(",
"nombre1",
")",
";",
"raiz",
".",
"add",
"(",
"nodo_canchas",
")",
";",
"y",
".",
"reload",
"(",
")",
";",
"}",
"else",
"if",
"(",
"listar_tree",
".",
"getSelectedIndex",
"(",
")",
"==",
"3",
")",
"{",
"DefaultTreeModel",
"m",
"=",
"(",
"DefaultTreeModel",
")",
"jt_lugar",
".",
"getModel",
"(",
")",
";",
"DefaultMutableTreeNode",
"raiz",
"=",
"(",
"DefaultMutableTreeNode",
")",
"m",
".",
"getRoot",
"(",
")",
";",
"DefaultMutableTreeNode",
"nodo_restaurantes",
";",
"nodo_restaurantes",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"new",
"restaurantes",
"(",
"categoria1",
",",
"calificacion",
",",
"nombre",
",",
"direccion",
",",
"entradas",
",",
"salida",
",",
"seguridad",
")",
")",
";",
"DefaultMutableTreeNode",
"categoriaa",
";",
"DefaultMutableTreeNode",
"nombre2",
";",
"categoriaa",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"categoria1",
"=",
"cb_categoria_restaurante",
".",
"getSelectedItem",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"nombre2",
"=",
"new",
"DefaultMutableTreeNode",
"(",
"tf_nombre",
".",
"getText",
"(",
")",
")",
";",
"categoriaa",
".",
"add",
"(",
"nombre2",
")",
";",
"nodo_restaurantes",
".",
"add",
"(",
"categoriaa",
")",
";",
"nodo_restaurantes",
".",
"add",
"(",
"nombre2",
")",
";",
"raiz",
".",
"add",
"(",
"nodo_restaurantes",
")",
";",
"m",
".",
"reload",
"(",
")",
";",
"nodo_restaurantes",
".",
"add",
"(",
"nombre2",
")",
";",
"raiz",
".",
"add",
"(",
"nodo_restaurantes",
")",
";",
"m",
".",
"reload",
"(",
")",
";",
"}",
"}",
"private",
"void",
"jm_arbolActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"jd_arbol",
".",
"setModal",
"(",
"true",
")",
";",
"jd_arbol",
".",
"pack",
"(",
")",
";",
"jd_arbol",
".",
"setLocationRelativeTo",
"(",
"this",
")",
";",
"jd_arbol",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"/**\n * @param args the command line arguments\n */",
"public",
"static",
"void",
"main",
"(",
"String",
"args",
"[",
"]",
")",
"{",
"/* Set the Nimbus look and feel */",
"/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.\n * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html \n */",
"try",
"{",
"for",
"(",
"javax",
".",
"swing",
".",
"UIManager",
".",
"LookAndFeelInfo",
"info",
":",
"javax",
".",
"swing",
".",
"UIManager",
".",
"getInstalledLookAndFeels",
"(",
")",
")",
"{",
"if",
"(",
"\"",
"Nimbus",
"\"",
".",
"equals",
"(",
"info",
".",
"getName",
"(",
")",
")",
")",
"{",
"javax",
".",
"swing",
".",
"UIManager",
".",
"setLookAndFeel",
"(",
"info",
".",
"getClassName",
"(",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"catch",
"(",
"ClassNotFoundException",
"ex",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"principal",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"java",
".",
"util",
".",
"logging",
".",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"InstantiationException",
"ex",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"principal",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"java",
".",
"util",
".",
"logging",
".",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"ex",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"principal",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"java",
".",
"util",
".",
"logging",
".",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"catch",
"(",
"javax",
".",
"swing",
".",
"UnsupportedLookAndFeelException",
"ex",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Logger",
".",
"getLogger",
"(",
"principal",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"java",
".",
"util",
".",
"logging",
".",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"/* Create and display the form */",
"java",
".",
"awt",
".",
"EventQueue",
".",
"invokeLater",
"(",
"new",
"Runnable",
"(",
")",
"{",
"public",
"void",
"run",
"(",
")",
"{",
"new",
"principal",
"(",
")",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"}",
")",
";",
"}",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"Categoria",
";",
"private",
"javax",
".",
"swing",
".",
"JButton",
"boton_guardar",
";",
"private",
"javax",
".",
"swing",
".",
"JButton",
"boton_guardar1",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_calificacion",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_categoria_canchas",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_categoria_restaurante",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_entrada",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_estado",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_inicio",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_lsalida",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"cb_salida",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"jComboBox1",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel1",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel10",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel11",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel12",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel13",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel14",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel15",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel16",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel17",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel18",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel2",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel3",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel4",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel5",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel6",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel7",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel8",
";",
"private",
"javax",
".",
"swing",
".",
"JLabel",
"jLabel9",
";",
"private",
"javax",
".",
"swing",
".",
"JMenu",
"jMenu1",
";",
"private",
"javax",
".",
"swing",
".",
"JMenu",
"jMenu2",
";",
"private",
"javax",
".",
"swing",
".",
"JPanel",
"jPanel1",
";",
"private",
"javax",
".",
"swing",
".",
"JPanel",
"jPanel2",
";",
"private",
"javax",
".",
"swing",
".",
"JPanel",
"jPanel3",
";",
"private",
"javax",
".",
"swing",
".",
"JScrollPane",
"jScrollPane1",
";",
"private",
"javax",
".",
"swing",
".",
"JScrollPane",
"jScrollPane2",
";",
"private",
"javax",
".",
"swing",
".",
"JScrollPane",
"jScrollPane3",
";",
"private",
"javax",
".",
"swing",
".",
"JScrollPane",
"jScrollPane4",
";",
"private",
"javax",
".",
"swing",
".",
"JTable",
"jTable1",
";",
"private",
"javax",
".",
"swing",
".",
"JDialog",
"jd_agregar",
";",
"private",
"javax",
".",
"swing",
".",
"JDialog",
"jd_arbol",
";",
"private",
"javax",
".",
"swing",
".",
"JDialog",
"jd_carreteras",
";",
"private",
"javax",
".",
"swing",
".",
"JDialog",
"jd_tabla",
";",
"private",
"javax",
".",
"swing",
".",
"JList",
"<",
"String",
">",
"jl_lugar",
";",
"private",
"javax",
".",
"swing",
".",
"JMenu",
"jm_agregar",
";",
"private",
"javax",
".",
"swing",
".",
"JMenuItem",
"jm_arbol",
";",
"private",
"javax",
".",
"swing",
".",
"JMenuItem",
"jm_carretera",
";",
"private",
"javax",
".",
"swing",
".",
"JMenu",
"jm_listar",
";",
"private",
"javax",
".",
"swing",
".",
"JMenuItem",
"jm_lugar",
";",
"private",
"javax",
".",
"swing",
".",
"JMenuItem",
"jm_tabla",
";",
"private",
"javax",
".",
"swing",
".",
"JTree",
"jt_lugar",
";",
"private",
"javax",
".",
"swing",
".",
"JComboBox",
"<",
"String",
">",
"listar_tree",
";",
"private",
"javax",
".",
"swing",
".",
"JMenuBar",
"menu_contenedor",
";",
"private",
"javax",
".",
"swing",
".",
"JMenu",
"mi_menu",
";",
"private",
"javax",
".",
"swing",
".",
"JTextArea",
"ta_direccion",
";",
"private",
"javax",
".",
"swing",
".",
"JTabbedPane",
"tab_tipo_lugar",
";",
"private",
"javax",
".",
"swing",
".",
"JTextField",
"tf_distancia",
";",
"private",
"javax",
".",
"swing",
".",
"JTextField",
"tf_nombre",
";",
"private",
"javax",
".",
"swing",
".",
"JTextField",
"tf_numero",
";",
"private",
"javax",
".",
"swing",
".",
"JTextField",
"tf_seguridad",
";",
"ArrayList",
"<",
"lugar",
">",
"lista",
"=",
"new",
"ArrayList",
"(",
")",
";",
"ArrayList",
"<",
"carreteras",
">",
"lista2",
"=",
"new",
"ArrayList",
"(",
")",
";",
"DefaultMutableTreeNode",
"nodo_seleccionado",
";",
"lugar",
"lugar_seleccionada",
";",
"}"
] | @author Franklin Garcia | [
"@author",
"Franklin",
"Garcia"
] | [
"// <editor-fold defaultstate=\"collapsed\" desc=\"Generated Code\">//GEN-BEGIN:initComponents",
"// NOI18N",
"// </editor-fold>//GEN-END:initComponents",
"//GEN-FIRST:event_tf_nombreActionPerformed",
"// TODO add your handling code here:",
"//GEN-LAST:event_tf_nombreActionPerformed",
"//GEN-FIRST:event_mi_menuActionPerformed",
"//GEN-LAST:event_mi_menuActionPerformed",
"//GEN-FIRST:event_jm_lugarActionPerformed",
"//acoplar el tamaño de la ventan a los objetos que estan incluidos en ella",
"//GEN-LAST:event_jm_lugarActionPerformed",
"//GEN-FIRST:event_boton_guardarMouseClicked",
"//",
"//",
"//GEN-LAST:event_boton_guardarMouseClicked",
"//GEN-FIRST:event_boton_guardar1MouseClicked",
"//GEN-LAST:event_boton_guardar1MouseClicked",
"//GEN-FIRST:event_jm_carreteraActionPerformed",
"//acoplar el tamaño de la ventan a los objetos que estan incluidos en ella",
"//GEN-LAST:event_jm_carreteraActionPerformed",
"//GEN-FIRST:event_cb_entradaItemStateChanged",
"//GEN-LAST:event_cb_entradaItemStateChanged",
"//GEN-FIRST:event_jd_agregarWindowActivated",
"//GEN-LAST:event_jd_agregarWindowActivated",
"//GEN-FIRST:event_listar_treeItemStateChanged",
"//",
"//GEN-LAST:event_listar_treeItemStateChanged",
"//GEN-FIRST:event_jm_arbolActionPerformed",
"//acoplar el tamaño de la ventan a los objetos que estan incluidos en ella",
"//GEN-LAST:event_jm_arbolActionPerformed",
"//<editor-fold defaultstate=\"collapsed\" desc=\" Look and feel setting code (optional) \">",
"//</editor-fold>",
"// Variables declaration - do not modify//GEN-BEGIN:variables",
"// End of variables declaration//GEN-END:variables"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54fe21b010c2a562123d075d137dbc594be76c00 | aca062/Repositorio-MDS2 | proyecto/src/main/java/vistas/VistaPaginacion_listas_ajenas.java | [
"Unlicense"
] | Java | VistaPaginacion_listas_ajenas | /**
* A Designer generated component for the vista-paginacion_listas_ajenas template.
*
* Designer will add and remove fields with @Id mappings but
* does not overwrite or otherwise change this file.
*/ | A Designer generated component for the vista-paginacion_listas_ajenas template.
Designer will add and remove fields with @Id mappings but
does not overwrite or otherwise change this file. | [
"A",
"Designer",
"generated",
"component",
"for",
"the",
"vista",
"-",
"paginacion_listas_ajenas",
"template",
".",
"Designer",
"will",
"add",
"and",
"remove",
"fields",
"with",
"@Id",
"mappings",
"but",
"does",
"not",
"overwrite",
"or",
"otherwise",
"change",
"this",
"file",
"."
] | @Tag("vista-paginacion_listas_ajenas")
@JsModule("./src/vistas/vista-paginacion_listas_ajenas.ts")
public class VistaPaginacion_listas_ajenas extends LitTemplate {
@Id("layoutPrincipal")
private Element layoutPrincipal;
@Id("layoutListas")
private HorizontalLayout layoutListas;
@Id("lista1")
private Element lista1;
@Id("lista2")
private Element lista2;
@Id("lista3")
private Element lista3;
@Id("lista4")
private Element lista4;
/**
* Creates a new VistaPaginacion_listas_ajenas.
*/
public VistaPaginacion_listas_ajenas() {
// You can initialise any data required for the connected UI components here.
}
public Element getLayoutPrincipal() {
return layoutPrincipal;
}
public void setLayoutPrincipal(Element layoutPrincipal) {
this.layoutPrincipal = layoutPrincipal;
}
public HorizontalLayout getLayoutListas() {
return layoutListas;
}
public void setLayoutListas(HorizontalLayout layoutListas) {
this.layoutListas = layoutListas;
}
public Element getLista1() {
return lista1;
}
public void setLista1(Element lista1) {
this.lista1 = lista1;
}
public Element getLista2() {
return lista2;
}
public void setLista2(Element lista2) {
this.lista2 = lista2;
}
public Element getLista3() {
return lista3;
}
public void setLista3(Element lista3) {
this.lista3 = lista3;
}
public Element getLista4() {
return lista4;
}
public void setLista4(Element lista4) {
this.lista4 = lista4;
}
} | [
"@",
"Tag",
"(",
"\"",
"vista-paginacion_listas_ajenas",
"\"",
")",
"@",
"JsModule",
"(",
"\"",
"./src/vistas/vista-paginacion_listas_ajenas.ts",
"\"",
")",
"public",
"class",
"VistaPaginacion_listas_ajenas",
"extends",
"LitTemplate",
"{",
"@",
"Id",
"(",
"\"",
"layoutPrincipal",
"\"",
")",
"private",
"Element",
"layoutPrincipal",
";",
"@",
"Id",
"(",
"\"",
"layoutListas",
"\"",
")",
"private",
"HorizontalLayout",
"layoutListas",
";",
"@",
"Id",
"(",
"\"",
"lista1",
"\"",
")",
"private",
"Element",
"lista1",
";",
"@",
"Id",
"(",
"\"",
"lista2",
"\"",
")",
"private",
"Element",
"lista2",
";",
"@",
"Id",
"(",
"\"",
"lista3",
"\"",
")",
"private",
"Element",
"lista3",
";",
"@",
"Id",
"(",
"\"",
"lista4",
"\"",
")",
"private",
"Element",
"lista4",
";",
"/**\n * Creates a new VistaPaginacion_listas_ajenas.\n */",
"public",
"VistaPaginacion_listas_ajenas",
"(",
")",
"{",
"}",
"public",
"Element",
"getLayoutPrincipal",
"(",
")",
"{",
"return",
"layoutPrincipal",
";",
"}",
"public",
"void",
"setLayoutPrincipal",
"(",
"Element",
"layoutPrincipal",
")",
"{",
"this",
".",
"layoutPrincipal",
"=",
"layoutPrincipal",
";",
"}",
"public",
"HorizontalLayout",
"getLayoutListas",
"(",
")",
"{",
"return",
"layoutListas",
";",
"}",
"public",
"void",
"setLayoutListas",
"(",
"HorizontalLayout",
"layoutListas",
")",
"{",
"this",
".",
"layoutListas",
"=",
"layoutListas",
";",
"}",
"public",
"Element",
"getLista1",
"(",
")",
"{",
"return",
"lista1",
";",
"}",
"public",
"void",
"setLista1",
"(",
"Element",
"lista1",
")",
"{",
"this",
".",
"lista1",
"=",
"lista1",
";",
"}",
"public",
"Element",
"getLista2",
"(",
")",
"{",
"return",
"lista2",
";",
"}",
"public",
"void",
"setLista2",
"(",
"Element",
"lista2",
")",
"{",
"this",
".",
"lista2",
"=",
"lista2",
";",
"}",
"public",
"Element",
"getLista3",
"(",
")",
"{",
"return",
"lista3",
";",
"}",
"public",
"void",
"setLista3",
"(",
"Element",
"lista3",
")",
"{",
"this",
".",
"lista3",
"=",
"lista3",
";",
"}",
"public",
"Element",
"getLista4",
"(",
")",
"{",
"return",
"lista4",
";",
"}",
"public",
"void",
"setLista4",
"(",
"Element",
"lista4",
")",
"{",
"this",
".",
"lista4",
"=",
"lista4",
";",
"}",
"}"
] | A Designer generated component for the vista-paginacion_listas_ajenas template. | [
"A",
"Designer",
"generated",
"component",
"for",
"the",
"vista",
"-",
"paginacion_listas_ajenas",
"template",
"."
] | [
"// You can initialise any data required for the connected UI components here."
] | [
{
"param": "LitTemplate",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "LitTemplate",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54fe2a63e3a3ff153ad88b3712321a11ca17c0bd | lauracristinaes/aula-java | hibernate-release-5.3.7.Final/project/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/ParameterContainer.java | [
"Apache-2.0"
] | Java | Helper | /**
* Helper to deal with potential parameter container nodes.
*/ | Helper to deal with potential parameter container nodes. | [
"Helper",
"to",
"deal",
"with",
"potential",
"parameter",
"container",
"nodes",
"."
] | public static class Helper {
public static void possibleParameter(Selection selection, ParameterRegistry registry) {
if ( ParameterContainer.class.isInstance( selection ) ) {
( (ParameterContainer) selection ).registerParameters( registry );
}
}
} | [
"public",
"static",
"class",
"Helper",
"{",
"public",
"static",
"void",
"possibleParameter",
"(",
"Selection",
"selection",
",",
"ParameterRegistry",
"registry",
")",
"{",
"if",
"(",
"ParameterContainer",
".",
"class",
".",
"isInstance",
"(",
"selection",
")",
")",
"{",
"(",
"(",
"ParameterContainer",
")",
"selection",
")",
".",
"registerParameters",
"(",
"registry",
")",
";",
"}",
"}",
"}"
] | Helper to deal with potential parameter container nodes. | [
"Helper",
"to",
"deal",
"with",
"potential",
"parameter",
"container",
"nodes",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
54fe453a888dd05448732671aecf8059e8606638 | conveyal/datatools-server | src/main/java/com/conveyal/datatools/manager/models/FeedVersionSummary.java | [
"MIT"
] | Java | FeedVersionSummary | /**
* Includes summary data (a subset of fields) for a feed version.
*/ | Includes summary data (a subset of fields) for a feed version. | [
"Includes",
"summary",
"data",
"(",
"a",
"subset",
"of",
"fields",
")",
"for",
"a",
"feed",
"version",
"."
] | public class FeedVersionSummary extends Model implements Serializable {
private static final long serialVersionUID = 1L;
public FeedRetrievalMethod retrievalMethod;
public int version;
public String feedSourceId;
public String name;
public String namespace;
public String originNamespace;
public Long fileSize;
public Date updated;
/** Only a subset of the validation results are serialized to JSON via getValidationSummary. */
@JsonIgnore
public ValidationResult validationResult;
private PartialValidationSummary validationSummary;
public PartialValidationSummary getValidationSummary() {
if (validationSummary == null) {
validationSummary = new PartialValidationSummary();
}
return validationSummary;
}
/** Empty constructor for serialization */
public FeedVersionSummary() {
// Do nothing
}
/**
* Holds a subset of fields from {@link:FeedValidationResultSummary} for UI use only.
*/
public class PartialValidationSummary {
/** Copied from FeedVersion */
@JsonSerialize(using = JacksonSerializers.LocalDateIsoSerializer.class)
@JsonDeserialize(using = JacksonSerializers.LocalDateIsoDeserializer.class)
public LocalDate startDate;
/** Copied from FeedVersion */
@JsonSerialize(using = JacksonSerializers.LocalDateIsoSerializer.class)
@JsonDeserialize(using = JacksonSerializers.LocalDateIsoDeserializer.class)
public LocalDate endDate;
PartialValidationSummary() {
this.startDate = validationResult.firstCalendarDate;
this.endDate = validationResult.lastCalendarDate;
}
}
} | [
"public",
"class",
"FeedVersionSummary",
"extends",
"Model",
"implements",
"Serializable",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"FeedRetrievalMethod",
"retrievalMethod",
";",
"public",
"int",
"version",
";",
"public",
"String",
"feedSourceId",
";",
"public",
"String",
"name",
";",
"public",
"String",
"namespace",
";",
"public",
"String",
"originNamespace",
";",
"public",
"Long",
"fileSize",
";",
"public",
"Date",
"updated",
";",
"/** Only a subset of the validation results are serialized to JSON via getValidationSummary. */",
"@",
"JsonIgnore",
"public",
"ValidationResult",
"validationResult",
";",
"private",
"PartialValidationSummary",
"validationSummary",
";",
"public",
"PartialValidationSummary",
"getValidationSummary",
"(",
")",
"{",
"if",
"(",
"validationSummary",
"==",
"null",
")",
"{",
"validationSummary",
"=",
"new",
"PartialValidationSummary",
"(",
")",
";",
"}",
"return",
"validationSummary",
";",
"}",
"/** Empty constructor for serialization */",
"public",
"FeedVersionSummary",
"(",
")",
"{",
"}",
"/**\n * Holds a subset of fields from {@link:FeedValidationResultSummary} for UI use only.\n */",
"public",
"class",
"PartialValidationSummary",
"{",
"/** Copied from FeedVersion */",
"@",
"JsonSerialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoSerializer",
".",
"class",
")",
"@",
"JsonDeserialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoDeserializer",
".",
"class",
")",
"public",
"LocalDate",
"startDate",
";",
"/** Copied from FeedVersion */",
"@",
"JsonSerialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoSerializer",
".",
"class",
")",
"@",
"JsonDeserialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoDeserializer",
".",
"class",
")",
"public",
"LocalDate",
"endDate",
";",
"PartialValidationSummary",
"(",
")",
"{",
"this",
".",
"startDate",
"=",
"validationResult",
".",
"firstCalendarDate",
";",
"this",
".",
"endDate",
"=",
"validationResult",
".",
"lastCalendarDate",
";",
"}",
"}",
"}"
] | Includes summary data (a subset of fields) for a feed version. | [
"Includes",
"summary",
"data",
"(",
"a",
"subset",
"of",
"fields",
")",
"for",
"a",
"feed",
"version",
"."
] | [
"// Do nothing"
] | [
{
"param": "Model",
"type": null
},
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Model",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
54fe453a888dd05448732671aecf8059e8606638 | conveyal/datatools-server | src/main/java/com/conveyal/datatools/manager/models/FeedVersionSummary.java | [
"MIT"
] | Java | PartialValidationSummary | /**
* Holds a subset of fields from {@link:FeedValidationResultSummary} for UI use only.
*/ | Holds a subset of fields from :FeedValidationResultSummary for UI use only. | [
"Holds",
"a",
"subset",
"of",
"fields",
"from",
":",
"FeedValidationResultSummary",
"for",
"UI",
"use",
"only",
"."
] | public class PartialValidationSummary {
/** Copied from FeedVersion */
@JsonSerialize(using = JacksonSerializers.LocalDateIsoSerializer.class)
@JsonDeserialize(using = JacksonSerializers.LocalDateIsoDeserializer.class)
public LocalDate startDate;
/** Copied from FeedVersion */
@JsonSerialize(using = JacksonSerializers.LocalDateIsoSerializer.class)
@JsonDeserialize(using = JacksonSerializers.LocalDateIsoDeserializer.class)
public LocalDate endDate;
PartialValidationSummary() {
this.startDate = validationResult.firstCalendarDate;
this.endDate = validationResult.lastCalendarDate;
}
} | [
"public",
"class",
"PartialValidationSummary",
"{",
"/** Copied from FeedVersion */",
"@",
"JsonSerialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoSerializer",
".",
"class",
")",
"@",
"JsonDeserialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoDeserializer",
".",
"class",
")",
"public",
"LocalDate",
"startDate",
";",
"/** Copied from FeedVersion */",
"@",
"JsonSerialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoSerializer",
".",
"class",
")",
"@",
"JsonDeserialize",
"(",
"using",
"=",
"JacksonSerializers",
".",
"LocalDateIsoDeserializer",
".",
"class",
")",
"public",
"LocalDate",
"endDate",
";",
"PartialValidationSummary",
"(",
")",
"{",
"this",
".",
"startDate",
"=",
"validationResult",
".",
"firstCalendarDate",
";",
"this",
".",
"endDate",
"=",
"validationResult",
".",
"lastCalendarDate",
";",
"}",
"}"
] | Holds a subset of fields from {@link:FeedValidationResultSummary} for UI use only. | [
"Holds",
"a",
"subset",
"of",
"fields",
"from",
"{",
"@link",
":",
"FeedValidationResultSummary",
"}",
"for",
"UI",
"use",
"only",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0700695f52278cc5968ab1cb26c5469097c77642 | ossgang/ossgang-commons | src/main/java/org/ossgang/commons/observables/Observers.java | [
"Apache-2.0"
] | Java | Observers | /**
* Utility class to create {@link Observer} instances.
*/ | Utility class to create Observer instances. | [
"Utility",
"class",
"to",
"create",
"Observer",
"instances",
"."
] | public class Observers {
private Observers() {
throw new UnsupportedOperationException("static only");
}
/**
* Create an {@link Observer} for values and exceptions
*
* @param valueConsumer for values
* @param exceptionConsumer for exceptions
* @param <T> the type of event
* @return the {@link Observer}
*/
public static <T> Observer<T> withErrorHandling(Consumer<T> valueConsumer, Consumer<Throwable> exceptionConsumer) {
return new Observer<T>() {
public void onValue(T value) {
valueConsumer.accept(value);
}
public void onException(Throwable exception) {
exceptionConsumer.accept(exception);
}
};
}
/**
* Create an {@link Observer} for {@link Maybe}s
*
* @param maybeConsumer for maybe
* @param <T> the type of event
* @return the {@link Observer}
*/
public static <T> Observer<T> forMaybes(Consumer<Maybe<T>> maybeConsumer) {
return new Observer<T>() {
public void onValue(T value) {
maybeConsumer.accept(Maybe.ofValue(value));
}
public void onException(Throwable exception) {
maybeConsumer.accept(Maybe.ofException(exception));
}
};
}
/**
* Create an {@link Observer} for exceptions
*
* @param exceptionConsumer for the exceptions
* @param <T> the tupe of event
* @return the {@link Observer}
*/
public static <T> Observer<T> forExceptions(Consumer<Throwable> exceptionConsumer) {
return new Observer<T>() {
public void onValue(T value) {
}
public void onException(Throwable exception) {
exceptionConsumer.accept(exception);
}
};
}
/**
* Create an observer based on a weak reference to an object, and class method references to consumers for values
* (and, optionally, exceptions).
* Release the reference to the subscriber as soon as the (weak-referenced) holder object is GC'd. A common use
* case for this is e.g. working with method references within a particular object:
* <pre>
* class Test {
* public void doSubscribe(Observable<String> obs) {
* obs.subscribe(weak(this, Test::handle));
* }
* private void handle(String update) ...
* }
* </pre>
* This will allow the "Test" instance to be GC'd, terminating the subscription; but for as long as it lives, the
* subscription will be kept alive.
*/
public static <C, T> Observer<T> weak(C holder, BiConsumer<C, T> valueConsumer) {
return new WeakMethodReferenceObserver<>(holder, valueConsumer);
}
/**
* @see #weak(Object, BiConsumer)
*/
public static <C, T> Observer<T> weakWithErrorHandling(C holder, BiConsumer<? super C, T> valueConsumer,
BiConsumer<? super C, Throwable> exceptionConsumer) {
return new WeakMethodReferenceObserver<>(holder, valueConsumer, exceptionConsumer);
}
} | [
"public",
"class",
"Observers",
"{",
"private",
"Observers",
"(",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"",
"static only",
"\"",
")",
";",
"}",
"/**\n * Create an {@link Observer} for values and exceptions\n *\n * @param valueConsumer for values\n * @param exceptionConsumer for exceptions\n * @param <T> the type of event\n * @return the {@link Observer}\n */",
"public",
"static",
"<",
"T",
">",
"Observer",
"<",
"T",
">",
"withErrorHandling",
"(",
"Consumer",
"<",
"T",
">",
"valueConsumer",
",",
"Consumer",
"<",
"Throwable",
">",
"exceptionConsumer",
")",
"{",
"return",
"new",
"Observer",
"<",
"T",
">",
"(",
")",
"{",
"public",
"void",
"onValue",
"(",
"T",
"value",
")",
"{",
"valueConsumer",
".",
"accept",
"(",
"value",
")",
";",
"}",
"public",
"void",
"onException",
"(",
"Throwable",
"exception",
")",
"{",
"exceptionConsumer",
".",
"accept",
"(",
"exception",
")",
";",
"}",
"}",
";",
"}",
"/**\n * Create an {@link Observer} for {@link Maybe}s\n *\n * @param maybeConsumer for maybe\n * @param <T> the type of event\n * @return the {@link Observer}\n */",
"public",
"static",
"<",
"T",
">",
"Observer",
"<",
"T",
">",
"forMaybes",
"(",
"Consumer",
"<",
"Maybe",
"<",
"T",
">",
">",
"maybeConsumer",
")",
"{",
"return",
"new",
"Observer",
"<",
"T",
">",
"(",
")",
"{",
"public",
"void",
"onValue",
"(",
"T",
"value",
")",
"{",
"maybeConsumer",
".",
"accept",
"(",
"Maybe",
".",
"ofValue",
"(",
"value",
")",
")",
";",
"}",
"public",
"void",
"onException",
"(",
"Throwable",
"exception",
")",
"{",
"maybeConsumer",
".",
"accept",
"(",
"Maybe",
".",
"ofException",
"(",
"exception",
")",
")",
";",
"}",
"}",
";",
"}",
"/**\n * Create an {@link Observer} for exceptions\n *\n * @param exceptionConsumer for the exceptions\n * @param <T> the tupe of event\n * @return the {@link Observer}\n */",
"public",
"static",
"<",
"T",
">",
"Observer",
"<",
"T",
">",
"forExceptions",
"(",
"Consumer",
"<",
"Throwable",
">",
"exceptionConsumer",
")",
"{",
"return",
"new",
"Observer",
"<",
"T",
">",
"(",
")",
"{",
"public",
"void",
"onValue",
"(",
"T",
"value",
")",
"{",
"}",
"public",
"void",
"onException",
"(",
"Throwable",
"exception",
")",
"{",
"exceptionConsumer",
".",
"accept",
"(",
"exception",
")",
";",
"}",
"}",
";",
"}",
"/**\n * Create an observer based on a weak reference to an object, and class method references to consumers for values\n * (and, optionally, exceptions).\n * Release the reference to the subscriber as soon as the (weak-referenced) holder object is GC'd. A common use\n * case for this is e.g. working with method references within a particular object:\n * <pre>\n * class Test {\n * public void doSubscribe(Observable<String> obs) {\n * obs.subscribe(weak(this, Test::handle));\n * }\n * private void handle(String update) ...\n * }\n * </pre>\n * This will allow the \"Test\" instance to be GC'd, terminating the subscription; but for as long as it lives, the\n * subscription will be kept alive.\n */",
"public",
"static",
"<",
"C",
",",
"T",
">",
"Observer",
"<",
"T",
">",
"weak",
"(",
"C",
"holder",
",",
"BiConsumer",
"<",
"C",
",",
"T",
">",
"valueConsumer",
")",
"{",
"return",
"new",
"WeakMethodReferenceObserver",
"<",
">",
"(",
"holder",
",",
"valueConsumer",
")",
";",
"}",
"/**\n * @see #weak(Object, BiConsumer)\n */",
"public",
"static",
"<",
"C",
",",
"T",
">",
"Observer",
"<",
"T",
">",
"weakWithErrorHandling",
"(",
"C",
"holder",
",",
"BiConsumer",
"<",
"?",
"super",
"C",
",",
"T",
">",
"valueConsumer",
",",
"BiConsumer",
"<",
"?",
"super",
"C",
",",
"Throwable",
">",
"exceptionConsumer",
")",
"{",
"return",
"new",
"WeakMethodReferenceObserver",
"<",
">",
"(",
"holder",
",",
"valueConsumer",
",",
"exceptionConsumer",
")",
";",
"}",
"}"
] | Utility class to create {@link Observer} instances. | [
"Utility",
"class",
"to",
"create",
"{",
"@link",
"Observer",
"}",
"instances",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
07006b1b51f36df453588c7703faf120bea5c100 | jankuehl/sonar-xanitizer | src/test/resources/webgoat/WEB-INF/classes/org/owasp/webgoat/session/SequentialLessonTracker.java | [
"Apache-2.0"
] | Java | SequentialLessonTracker | /**
* <p>SequentialLessonTracker class.</p>
*
* @version $Id: $Id
* @author dm
*/ | SequentialLessonTracker class.
@version $Id: $Id
@author dm | [
"SequentialLessonTracker",
"class",
".",
"@version",
"$Id",
":",
"$Id",
"@author",
"dm"
] | public class SequentialLessonTracker extends LessonTracker
{
private int currentStage = 1;
/**
* <p>getStage.</p>
*
* @return a int.
*/
public int getStage()
{
return currentStage;
}
/**
* <p>setStage.</p>
*
* @param stage a int.
*/
public void setStage(int stage)
{
currentStage = stage;
}
/** {@inheritDoc} */
protected void setProperties(Properties props, Screen screen)
{
super.setProperties(props, screen);
currentStage = Integer.parseInt(props.getProperty(screen.getTitle() + ".currentStage"));
}
/** {@inheritDoc} */
public void store(WebSession s, Screen screen, String user)
{
lessonProperties.setProperty(screen.getTitle() + ".currentStage", Integer.toString(currentStage));
super.store(s, screen, user);
}
/**
* <p>toString.</p>
*
* @return a {@link java.lang.String} object.
*/
public String toString()
{
return super.toString() + " - currentStage:....... " + currentStage + "\n";
}
} | [
"public",
"class",
"SequentialLessonTracker",
"extends",
"LessonTracker",
"{",
"private",
"int",
"currentStage",
"=",
"1",
";",
"/**\n\t * <p>getStage.</p>\n\t *\n\t * @return a int.\n\t */",
"public",
"int",
"getStage",
"(",
")",
"{",
"return",
"currentStage",
";",
"}",
"/**\n\t * <p>setStage.</p>\n\t *\n\t * @param stage a int.\n\t */",
"public",
"void",
"setStage",
"(",
"int",
"stage",
")",
"{",
"currentStage",
"=",
"stage",
";",
"}",
"/** {@inheritDoc} */",
"protected",
"void",
"setProperties",
"(",
"Properties",
"props",
",",
"Screen",
"screen",
")",
"{",
"super",
".",
"setProperties",
"(",
"props",
",",
"screen",
")",
";",
"currentStage",
"=",
"Integer",
".",
"parseInt",
"(",
"props",
".",
"getProperty",
"(",
"screen",
".",
"getTitle",
"(",
")",
"+",
"\"",
".currentStage",
"\"",
")",
")",
";",
"}",
"/** {@inheritDoc} */",
"public",
"void",
"store",
"(",
"WebSession",
"s",
",",
"Screen",
"screen",
",",
"String",
"user",
")",
"{",
"lessonProperties",
".",
"setProperty",
"(",
"screen",
".",
"getTitle",
"(",
")",
"+",
"\"",
".currentStage",
"\"",
",",
"Integer",
".",
"toString",
"(",
"currentStage",
")",
")",
";",
"super",
".",
"store",
"(",
"s",
",",
"screen",
",",
"user",
")",
";",
"}",
"/**\n\t * <p>toString.</p>\n\t *\n\t * @return a {@link java.lang.String} object.\n\t */",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"super",
".",
"toString",
"(",
")",
"+",
"\"",
" - currentStage:....... ",
"\"",
"+",
"currentStage",
"+",
"\"",
"\\n",
"\"",
";",
"}",
"}"
] | <p>SequentialLessonTracker class.</p>
@version $Id: $Id
@author dm | [
"<p",
">",
"SequentialLessonTracker",
"class",
".",
"<",
"/",
"p",
">",
"@version",
"$Id",
":",
"$Id",
"@author",
"dm"
] | [] | [
{
"param": "LessonTracker",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "LessonTracker",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
070306de5c9a5c7bf022ad1cb0500764dbf62875 | gth1030/PostgresGeneDataLoader | src/main/java/FeatureTuple.java | [
"Unlicense"
] | Java | FeatureTuple | /**
* Created by kitae on 5/13/16.
*/ | Created by kitae on 5/13/16. | [
"Created",
"by",
"kitae",
"on",
"5",
"/",
"13",
"/",
"16",
"."
] | public class FeatureTuple extends TupleInterface {
protected FeatureTuple(String[] token, JsonTuple jTuple) {
int index = Integer.parseInt(jTuple.index);
int start = Integer.parseInt(jTuple.columns.get("START")) - index; // Correct start based on index
int end = Integer.parseInt(jTuple.columns.get("END"));
seqlen = Integer.toString(Integer.parseInt(token[end]) - Integer.parseInt(token[start]));
type_id = BedFileConvertor.dbxrefToCvtermMap.get(jTuple.getTypeID(token));
organism_id = BedFileConvertor.dbxrefToFeatureOrganismMap.get(token[jTuple.getSrcFeatureIndex()]).organism_id;
uniquename = jTuple.generateName(type_id);
if (jTuple.columns.containsKey("RAWSCORE")) {
rawscore = jTuple.columns.get("RAWSCORE");
}
if (jTuple.columns.containsKey("NORMSCORE")) {
normscore = jTuple.columns.get("NORMSCORE");
}
if (jTuple.columns.containsKey("SIGNIFICANCE")) {
significance = jTuple.columns.get("SIGNIFICANCE");
}
if (jTuple.columns.containsKey("IDENTITY")) {
identity = jTuple.columns.get("IDENTITY");
}
if (jTuple.columns.containsKey("PERCENTILE")) {
percentile = jTuple.columns.get("PERCENTILE");
}
if (jTuple.columns.containsKey("RANK")) {
rank = jTuple.columns.get("RANK");
}
if (jTuple.columns.containsKey("ERROR")) {
error = jTuple.columns.get("ERROR");
}
if (jTuple.columns.containsKey("ERROR2")) {
error2 = jTuple.columns.get("ERROR2");
}
if (jTuple.columns.containsKey("FEATURE_DBXREF")) {
featureDbxrefFullAcc = jTuple.columns.get("FEATURE_DBXREF");
}
is_analysis = "true";
}
/** Constructor for condensed type jsonfile. */
FeatureTuple(JsonTuple jTuple, String type_idI) {
seqlen = "";
uniquename = jTuple.generateName(type_idI);
type_id = type_idI;
is_analysis = "true";
/* organism_id is assigned later.*/
organism_id = null;
}
/**
* For all features that are present in json file but not used in data file is removed by checking their
* organism id.
* @param featureQueue
*/
public static void filterUnusedFeature_Condensed(Queue<FeatureTuple> featureQueue) {
for (int i = 0; i < featureQueue.size(); i++) {
FeatureTuple tuple = featureQueue.poll();
if (tuple.organism_id == null) {
continue;
}
featureQueue.add(tuple);
}
}
/**
* Maps column names for analysisfeature table to their values.
* @param columnName Name of column for analysisfeature columns.
* @return value of specific column name for analysisFeature
*/
public String getProperFeatureAnalysisVal(String columnName) {
String value = "";
if (columnName.equals("RAWSCORE")) {
value = (rawscore != null) ? rawscore : value;
} else if (columnName.equals("NORMSCORE")) {
value = (normscore != null) ? normscore : value;
} else if (columnName.equals("SIGNIFICANCE")) {
value = (significance != null) ? significance : value;
} else if (columnName.equals("IDENTITY")) {
value = (identity != null) ? identity : value;
} else if (columnName.equals("PERCENTILE")) {
value = (percentile != null) ? percentile : value;
} else if (columnName.equals("RANK")) {
value = (rank != null) ? rank : value;
} else if (columnName.equals("ERROR")) {
value = (error != null) ? error : value;
} else if (columnName.equals("ERROR2")) {
value = (error2 != null) ? error2 : value;
}
return value;
}
/* Columns for feature table */
String feature_id;
String seqlen;
String uniquename;
String type_id;
String organism_id;
String is_analysis;
String rawscore;
String normscore;
String significance;
String identity;
String percentile;
String rank;
String error;
String error2;
/** if dbxref is present, featuredbxref is added. The format is dbname:dbxrefAcession[:version] (version is optional) **/
String featureDbxrefFullAcc;
/** Mapped later when dbxref is created, and used to upload feature_dbxref.**/
String dbxref_id;
/** Mapped when dbxrefis created, and used to upload feature_dbxref **/
String feature_dbxref_id;
} | [
"public",
"class",
"FeatureTuple",
"extends",
"TupleInterface",
"{",
"protected",
"FeatureTuple",
"(",
"String",
"[",
"]",
"token",
",",
"JsonTuple",
"jTuple",
")",
"{",
"int",
"index",
"=",
"Integer",
".",
"parseInt",
"(",
"jTuple",
".",
"index",
")",
";",
"int",
"start",
"=",
"Integer",
".",
"parseInt",
"(",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"START",
"\"",
")",
")",
"-",
"index",
";",
"int",
"end",
"=",
"Integer",
".",
"parseInt",
"(",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"END",
"\"",
")",
")",
";",
"seqlen",
"=",
"Integer",
".",
"toString",
"(",
"Integer",
".",
"parseInt",
"(",
"token",
"[",
"end",
"]",
")",
"-",
"Integer",
".",
"parseInt",
"(",
"token",
"[",
"start",
"]",
")",
")",
";",
"type_id",
"=",
"BedFileConvertor",
".",
"dbxrefToCvtermMap",
".",
"get",
"(",
"jTuple",
".",
"getTypeID",
"(",
"token",
")",
")",
";",
"organism_id",
"=",
"BedFileConvertor",
".",
"dbxrefToFeatureOrganismMap",
".",
"get",
"(",
"token",
"[",
"jTuple",
".",
"getSrcFeatureIndex",
"(",
")",
"]",
")",
".",
"organism_id",
";",
"uniquename",
"=",
"jTuple",
".",
"generateName",
"(",
"type_id",
")",
";",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"RAWSCORE",
"\"",
")",
")",
"{",
"rawscore",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"RAWSCORE",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"NORMSCORE",
"\"",
")",
")",
"{",
"normscore",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"NORMSCORE",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"SIGNIFICANCE",
"\"",
")",
")",
"{",
"significance",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"SIGNIFICANCE",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"IDENTITY",
"\"",
")",
")",
"{",
"identity",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"IDENTITY",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"PERCENTILE",
"\"",
")",
")",
"{",
"percentile",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"PERCENTILE",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"RANK",
"\"",
")",
")",
"{",
"rank",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"RANK",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"ERROR",
"\"",
")",
")",
"{",
"error",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"ERROR",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"ERROR2",
"\"",
")",
")",
"{",
"error2",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"ERROR2",
"\"",
")",
";",
"}",
"if",
"(",
"jTuple",
".",
"columns",
".",
"containsKey",
"(",
"\"",
"FEATURE_DBXREF",
"\"",
")",
")",
"{",
"featureDbxrefFullAcc",
"=",
"jTuple",
".",
"columns",
".",
"get",
"(",
"\"",
"FEATURE_DBXREF",
"\"",
")",
";",
"}",
"is_analysis",
"=",
"\"",
"true",
"\"",
";",
"}",
"/** Constructor for condensed type jsonfile. */",
"FeatureTuple",
"(",
"JsonTuple",
"jTuple",
",",
"String",
"type_idI",
")",
"{",
"seqlen",
"=",
"\"",
"\"",
";",
"uniquename",
"=",
"jTuple",
".",
"generateName",
"(",
"type_idI",
")",
";",
"type_id",
"=",
"type_idI",
";",
"is_analysis",
"=",
"\"",
"true",
"\"",
";",
"/* organism_id is assigned later.*/",
"organism_id",
"=",
"null",
";",
"}",
"/**\n * For all features that are present in json file but not used in data file is removed by checking their\n * organism id.\n * @param featureQueue\n */",
"public",
"static",
"void",
"filterUnusedFeature_Condensed",
"(",
"Queue",
"<",
"FeatureTuple",
">",
"featureQueue",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"featureQueue",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"FeatureTuple",
"tuple",
"=",
"featureQueue",
".",
"poll",
"(",
")",
";",
"if",
"(",
"tuple",
".",
"organism_id",
"==",
"null",
")",
"{",
"continue",
";",
"}",
"featureQueue",
".",
"add",
"(",
"tuple",
")",
";",
"}",
"}",
"/**\n * Maps column names for analysisfeature table to their values.\n * @param columnName Name of column for analysisfeature columns.\n * @return value of specific column name for analysisFeature\n */",
"public",
"String",
"getProperFeatureAnalysisVal",
"(",
"String",
"columnName",
")",
"{",
"String",
"value",
"=",
"\"",
"\"",
";",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"RAWSCORE",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"rawscore",
"!=",
"null",
")",
"?",
"rawscore",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"NORMSCORE",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"normscore",
"!=",
"null",
")",
"?",
"normscore",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"SIGNIFICANCE",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"significance",
"!=",
"null",
")",
"?",
"significance",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"IDENTITY",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"identity",
"!=",
"null",
")",
"?",
"identity",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"PERCENTILE",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"percentile",
"!=",
"null",
")",
"?",
"percentile",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"RANK",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"rank",
"!=",
"null",
")",
"?",
"rank",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"ERROR",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"error",
"!=",
"null",
")",
"?",
"error",
":",
"value",
";",
"}",
"else",
"if",
"(",
"columnName",
".",
"equals",
"(",
"\"",
"ERROR2",
"\"",
")",
")",
"{",
"value",
"=",
"(",
"error2",
"!=",
"null",
")",
"?",
"error2",
":",
"value",
";",
"}",
"return",
"value",
";",
"}",
"/* Columns for feature table */",
"String",
"feature_id",
";",
"String",
"seqlen",
";",
"String",
"uniquename",
";",
"String",
"type_id",
";",
"String",
"organism_id",
";",
"String",
"is_analysis",
";",
"String",
"rawscore",
";",
"String",
"normscore",
";",
"String",
"significance",
";",
"String",
"identity",
";",
"String",
"percentile",
";",
"String",
"rank",
";",
"String",
"error",
";",
"String",
"error2",
";",
"/** if dbxref is present, featuredbxref is added. The format is dbname:dbxrefAcession[:version] (version is optional) **/",
"String",
"featureDbxrefFullAcc",
";",
"/** Mapped later when dbxref is created, and used to upload feature_dbxref.**/",
"String",
"dbxref_id",
";",
"/** Mapped when dbxrefis created, and used to upload feature_dbxref **/",
"String",
"feature_dbxref_id",
";",
"}"
] | Created by kitae on 5/13/16. | [
"Created",
"by",
"kitae",
"on",
"5",
"/",
"13",
"/",
"16",
"."
] | [
"// Correct start based on index"
] | [
{
"param": "TupleInterface",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "TupleInterface",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
070a193f9700f57790f0a8eb82d964c96a97b217 | zwergziege/tlaplus | toolbox/org.lamport.tla.toolbox.tool.tlc.ui/src/org/lamport/tla/toolbox/tool/tlc/ui/util/ExpandableSpaceReclaimer.java | [
"MIT"
] | Java | ExpandableSpaceReclaimer | /**
* There are a few scenarios in which we want the collapse of a section to force a neighboring component to expand into
* that space. This class begins to address that.
*
* <b>Note</b> this class presently only handles N-child SashForms and is only coded to handle those with vertical
* layout.
*/ | There are a few scenarios in which we want the collapse of a section to force a neighboring component to expand into
that space. This class begins to address that.
Note this class presently only handles N-child SashForms and is only coded to handle those with vertical
layout. | [
"There",
"are",
"a",
"few",
"scenarios",
"in",
"which",
"we",
"want",
"the",
"collapse",
"of",
"a",
"section",
"to",
"force",
"a",
"neighboring",
"component",
"to",
"expand",
"into",
"that",
"space",
".",
"This",
"class",
"begins",
"to",
"address",
"that",
".",
"Note",
"this",
"class",
"presently",
"only",
"handles",
"N",
"-",
"child",
"SashForms",
"and",
"is",
"only",
"coded",
"to",
"handle",
"those",
"with",
"vertical",
"layout",
"."
] | public class ExpandableSpaceReclaimer implements IExpansionListener {
private static final double MINIMUM_SASH_PART_PERCENTAGE = 0.1;
private final Section m_section;
private final SashForm m_sashForm;
private final int m_sectionIndex;
private final int m_otherChildrenCount;
private Point m_lastSectionSizeOnCollapse;
/**
* An instance should be constructed only after all children have been added to the sash form.
*
* @param s the section which we will listen for collapse and expansion on
* @param sf the sash form in which the section sits
* @throws IllegalArgumentException if the section is not one of the sash form's children
*/
public ExpandableSpaceReclaimer(final Section s, final SashForm sf) {
m_section = s;
m_sashForm = sf;
final Control[] children = m_sashForm.getChildren();
int index = -1;
for (int i = 0; i < children.length; i++) {
if (s == children[i]) {
index = i;
break;
}
}
if (index == -1) {
throw new IllegalArgumentException("Section could not be found in the sash form.");
}
m_sectionIndex = index;
m_otherChildrenCount = children.length - 1;
m_section.addExpansionListener(this);
m_lastSectionSizeOnCollapse = null;
}
@Override
public void expansionStateChanging(final ExpansionEvent ee) {
if (!ee.getState()) {
m_lastSectionSizeOnCollapse = m_section.getSize();
}
}
@Override
public void expansionStateChanged(final ExpansionEvent ee) {
final Point sashFormSize = m_sashForm.getSize();
final int totalSashConsumption = m_sashForm.getSashWidth() * m_otherChildrenCount;
if (ee.getState()) { // => now expanded
final Point desiredSize = (m_lastSectionSizeOnCollapse != null)
? m_lastSectionSizeOnCollapse
: m_section.computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
if (m_sashForm.getOrientation() == SWT.VERTICAL) {
final int minimumHeight = (int)(MINIMUM_SASH_PART_PERCENTAGE * (double)sashFormSize.y);
final int totalMinimumHeight = (minimumHeight * m_otherChildrenCount) + totalSashConsumption;
final double usableSashFormHeight = sashFormSize.y - totalSashConsumption;
if (desiredSize.y < (sashFormSize.y - totalMinimumHeight)) {
final double remainingHeight = usableSashFormHeight - desiredSize.y;
final int[] weights = m_sashForm.getWeights();
double sumOfOtherWeights = 0;
for (int i = 0; i < weights.length; i++) {
if (i != m_sectionIndex) {
sumOfOtherWeights += weights[i];
}
}
final double[] newHeights = new double[weights.length];
int heightSum = 0;
for (int i = 0; i < weights.length; i++) {
if (i != m_sectionIndex) {
final double percentage = (double)weights[i] / sumOfOtherWeights;
newHeights[i] = (int)(percentage * remainingHeight);
heightSum += newHeights[i];
}
}
newHeights[m_sectionIndex] = usableSashFormHeight - heightSum;
final int[] newWeights = new int[weights.length];
for (int i = 0; i < weights.length; i++) {
newWeights[i] = (int)(newHeights[i] * 100.0 / usableSashFormHeight);
}
m_sashForm.setWeights(newWeights);
} // else let the user fend for themselves
} else {
final int minimumWidth = (int)(MINIMUM_SASH_PART_PERCENTAGE * (double)sashFormSize.x);
final int totalMinimumWidth = (minimumWidth + m_sashForm.getSashWidth()) * m_otherChildrenCount;
if (desiredSize.x < (sashFormSize.x - totalMinimumWidth)) {
} // else let the user fend for themselves
}
} else {
final Point sectionSize = m_section.getSize();
final Point sectionClientSize = m_section.getClient().getSize();
if (m_sashForm.getOrientation() == SWT.VERTICAL) {
final double titleBarHeight = sectionSize.y - sectionClientSize.y;
final double usableSashFormHeight = sashFormSize.y - (totalSashConsumption + titleBarHeight);
final int[] weights = m_sashForm.getWeights();
double sumOfOtherWeights = 0;
for (int i = 0; i < weights.length; i++) {
if (i != m_sectionIndex) {
sumOfOtherWeights += weights[i];
}
}
final double[] newHeights = new double[weights.length];
for (int i = 0; i < weights.length; i++) {
if (i != m_sectionIndex) {
final double percentage = (double)weights[i] / sumOfOtherWeights;
newHeights[i] = (int)(percentage * usableSashFormHeight);
}
}
newHeights[m_sectionIndex] = (int)titleBarHeight;
final int[] newWeights = new int[weights.length];
for (int i = 0; i < weights.length; i++) {
newWeights[i] = (int)(newHeights[i] * 100.0 / usableSashFormHeight);
}
m_sashForm.setWeights(newWeights);
} else {
}
}
}
} | [
"public",
"class",
"ExpandableSpaceReclaimer",
"implements",
"IExpansionListener",
"{",
"private",
"static",
"final",
"double",
"MINIMUM_SASH_PART_PERCENTAGE",
"=",
"0.1",
";",
"private",
"final",
"Section",
"m_section",
";",
"private",
"final",
"SashForm",
"m_sashForm",
";",
"private",
"final",
"int",
"m_sectionIndex",
";",
"private",
"final",
"int",
"m_otherChildrenCount",
";",
"private",
"Point",
"m_lastSectionSizeOnCollapse",
";",
"/**\n\t * An instance should be constructed only after all children have been added to the sash form.\n\t * \n\t * @param s the section which we will listen for collapse and expansion on\n\t * @param sf the sash form in which the section sits\n\t * @throws IllegalArgumentException if the section is not one of the sash form's children\n\t */",
"public",
"ExpandableSpaceReclaimer",
"(",
"final",
"Section",
"s",
",",
"final",
"SashForm",
"sf",
")",
"{",
"m_section",
"=",
"s",
";",
"m_sashForm",
"=",
"sf",
";",
"final",
"Control",
"[",
"]",
"children",
"=",
"m_sashForm",
".",
"getChildren",
"(",
")",
";",
"int",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"children",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"s",
"==",
"children",
"[",
"i",
"]",
")",
"{",
"index",
"=",
"i",
";",
"break",
";",
"}",
"}",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Section could not be found in the sash form.",
"\"",
")",
";",
"}",
"m_sectionIndex",
"=",
"index",
";",
"m_otherChildrenCount",
"=",
"children",
".",
"length",
"-",
"1",
";",
"m_section",
".",
"addExpansionListener",
"(",
"this",
")",
";",
"m_lastSectionSizeOnCollapse",
"=",
"null",
";",
"}",
"@",
"Override",
"public",
"void",
"expansionStateChanging",
"(",
"final",
"ExpansionEvent",
"ee",
")",
"{",
"if",
"(",
"!",
"ee",
".",
"getState",
"(",
")",
")",
"{",
"m_lastSectionSizeOnCollapse",
"=",
"m_section",
".",
"getSize",
"(",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"expansionStateChanged",
"(",
"final",
"ExpansionEvent",
"ee",
")",
"{",
"final",
"Point",
"sashFormSize",
"=",
"m_sashForm",
".",
"getSize",
"(",
")",
";",
"final",
"int",
"totalSashConsumption",
"=",
"m_sashForm",
".",
"getSashWidth",
"(",
")",
"*",
"m_otherChildrenCount",
";",
"if",
"(",
"ee",
".",
"getState",
"(",
")",
")",
"{",
"final",
"Point",
"desiredSize",
"=",
"(",
"m_lastSectionSizeOnCollapse",
"!=",
"null",
")",
"?",
"m_lastSectionSizeOnCollapse",
":",
"m_section",
".",
"computeSize",
"(",
"SWT",
".",
"DEFAULT",
",",
"SWT",
".",
"DEFAULT",
",",
"false",
")",
";",
"if",
"(",
"m_sashForm",
".",
"getOrientation",
"(",
")",
"==",
"SWT",
".",
"VERTICAL",
")",
"{",
"final",
"int",
"minimumHeight",
"=",
"(",
"int",
")",
"(",
"MINIMUM_SASH_PART_PERCENTAGE",
"*",
"(",
"double",
")",
"sashFormSize",
".",
"y",
")",
";",
"final",
"int",
"totalMinimumHeight",
"=",
"(",
"minimumHeight",
"*",
"m_otherChildrenCount",
")",
"+",
"totalSashConsumption",
";",
"final",
"double",
"usableSashFormHeight",
"=",
"sashFormSize",
".",
"y",
"-",
"totalSashConsumption",
";",
"if",
"(",
"desiredSize",
".",
"y",
"<",
"(",
"sashFormSize",
".",
"y",
"-",
"totalMinimumHeight",
")",
")",
"{",
"final",
"double",
"remainingHeight",
"=",
"usableSashFormHeight",
"-",
"desiredSize",
".",
"y",
";",
"final",
"int",
"[",
"]",
"weights",
"=",
"m_sashForm",
".",
"getWeights",
"(",
")",
";",
"double",
"sumOfOtherWeights",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"m_sectionIndex",
")",
"{",
"sumOfOtherWeights",
"+=",
"weights",
"[",
"i",
"]",
";",
"}",
"}",
"final",
"double",
"[",
"]",
"newHeights",
"=",
"new",
"double",
"[",
"weights",
".",
"length",
"]",
";",
"int",
"heightSum",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"m_sectionIndex",
")",
"{",
"final",
"double",
"percentage",
"=",
"(",
"double",
")",
"weights",
"[",
"i",
"]",
"/",
"sumOfOtherWeights",
";",
"newHeights",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"(",
"percentage",
"*",
"remainingHeight",
")",
";",
"heightSum",
"+=",
"newHeights",
"[",
"i",
"]",
";",
"}",
"}",
"newHeights",
"[",
"m_sectionIndex",
"]",
"=",
"usableSashFormHeight",
"-",
"heightSum",
";",
"final",
"int",
"[",
"]",
"newWeights",
"=",
"new",
"int",
"[",
"weights",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"newWeights",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"(",
"newHeights",
"[",
"i",
"]",
"*",
"100.0",
"/",
"usableSashFormHeight",
")",
";",
"}",
"m_sashForm",
".",
"setWeights",
"(",
"newWeights",
")",
";",
"}",
"}",
"else",
"{",
"final",
"int",
"minimumWidth",
"=",
"(",
"int",
")",
"(",
"MINIMUM_SASH_PART_PERCENTAGE",
"*",
"(",
"double",
")",
"sashFormSize",
".",
"x",
")",
";",
"final",
"int",
"totalMinimumWidth",
"=",
"(",
"minimumWidth",
"+",
"m_sashForm",
".",
"getSashWidth",
"(",
")",
")",
"*",
"m_otherChildrenCount",
";",
"if",
"(",
"desiredSize",
".",
"x",
"<",
"(",
"sashFormSize",
".",
"x",
"-",
"totalMinimumWidth",
")",
")",
"{",
"}",
"}",
"}",
"else",
"{",
"final",
"Point",
"sectionSize",
"=",
"m_section",
".",
"getSize",
"(",
")",
";",
"final",
"Point",
"sectionClientSize",
"=",
"m_section",
".",
"getClient",
"(",
")",
".",
"getSize",
"(",
")",
";",
"if",
"(",
"m_sashForm",
".",
"getOrientation",
"(",
")",
"==",
"SWT",
".",
"VERTICAL",
")",
"{",
"final",
"double",
"titleBarHeight",
"=",
"sectionSize",
".",
"y",
"-",
"sectionClientSize",
".",
"y",
";",
"final",
"double",
"usableSashFormHeight",
"=",
"sashFormSize",
".",
"y",
"-",
"(",
"totalSashConsumption",
"+",
"titleBarHeight",
")",
";",
"final",
"int",
"[",
"]",
"weights",
"=",
"m_sashForm",
".",
"getWeights",
"(",
")",
";",
"double",
"sumOfOtherWeights",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"m_sectionIndex",
")",
"{",
"sumOfOtherWeights",
"+=",
"weights",
"[",
"i",
"]",
";",
"}",
"}",
"final",
"double",
"[",
"]",
"newHeights",
"=",
"new",
"double",
"[",
"weights",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"i",
"!=",
"m_sectionIndex",
")",
"{",
"final",
"double",
"percentage",
"=",
"(",
"double",
")",
"weights",
"[",
"i",
"]",
"/",
"sumOfOtherWeights",
";",
"newHeights",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"(",
"percentage",
"*",
"usableSashFormHeight",
")",
";",
"}",
"}",
"newHeights",
"[",
"m_sectionIndex",
"]",
"=",
"(",
"int",
")",
"titleBarHeight",
";",
"final",
"int",
"[",
"]",
"newWeights",
"=",
"new",
"int",
"[",
"weights",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"weights",
".",
"length",
";",
"i",
"++",
")",
"{",
"newWeights",
"[",
"i",
"]",
"=",
"(",
"int",
")",
"(",
"newHeights",
"[",
"i",
"]",
"*",
"100.0",
"/",
"usableSashFormHeight",
")",
";",
"}",
"m_sashForm",
".",
"setWeights",
"(",
"newWeights",
")",
";",
"}",
"else",
"{",
"}",
"}",
"}",
"}"
] | There are a few scenarios in which we want the collapse of a section to force a neighboring component to expand into
that space. | [
"There",
"are",
"a",
"few",
"scenarios",
"in",
"which",
"we",
"want",
"the",
"collapse",
"of",
"a",
"section",
"to",
"force",
"a",
"neighboring",
"component",
"to",
"expand",
"into",
"that",
"space",
"."
] | [
"// => now expanded",
"// else let the user fend for themselves",
"// else let the user fend for themselves"
] | [
{
"param": "IExpansionListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "IExpansionListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
070daa0355f87e8010af343a1a635abdb6a89943 | chaupal/jxse-osgi | Workspace/net.jxta/src/net/jxta/impl/document/DOMXMLDocument.java | [
"Apache-2.0"
] | Java | DOMXMLDocument | /**
* This class is an implementation of the StructuredDocument interface using
* DOM
*
* @see <a href="http://www.w3.org/DOM/">W3C Document Object Model (DOM)</a>
* @see <a href="http://www.w3.org/TR/DOM-Level-2-Core/java-binding.html">DOM Java Language Binding</a>
* @see <a href="http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407">Document Object Model (DOM) Level 3 Load and Save Specification</a>
* @see <a href="http://java.sun.com/xml/jaxp/index.html">Java API for XML Processing (JAXP)</a>
* @see org.w3c.dom
*/ | This class is an implementation of the StructuredDocument interface using
DOM
| [
"This",
"class",
"is",
"an",
"implementation",
"of",
"the",
"StructuredDocument",
"interface",
"using",
"DOM"
] | public class DOMXMLDocument extends DOMXMLElement implements XMLDocument<DOMXMLElement> {
private static final class Instantiator implements StructuredDocumentFactory.TextInstantiator {
/**
* The MIME Media Types which this <CODE>StructuredDocument</CODE> is
* capable of emitting.
*/
private static final MimeMediaType[] myTypes = {
MimeMediaType.XML_DEFAULTENCODING,
new MimeMediaType("Application", "Xml")
};
/**
* these are the file extensions which are likely to contain files of
* the type i like.
*/
private static final ExtensionMapping[] myExtensions = {
new ExtensionMapping("xml", myTypes[0]),
new ExtensionMapping("xml", null)
};
/**
* Creates new XMLDocumentInstantiator
*/
public Instantiator() {}
/**
* {@inheritDoc}
*/
public MimeMediaType[] getSupportedMimeTypes() {
return (myTypes);
}
/**
* {@inheritDoc}
*/
public ExtensionMapping[] getSupportedFileExtensions() {
return (myExtensions);
}
/**
* {@inheritDoc}
*/
public StructuredDocument<?> newInstance(MimeMediaType mimeType, String doctype) {
return new DOMXMLDocument(mimeType, doctype);
}
/**
* {@inheritDoc}
*/
public StructuredDocument<?> newInstance(MimeMediaType mimeType, String doctype, String value) {
return new DOMXMLDocument(mimeType, doctype, value);
}
/**
* {@inheritDoc}
*/
public StructuredDocument<?> newInstance(MimeMediaType mimeType, InputStream source) throws IOException {
return new DOMXMLDocument(mimeType, source);
}
/**
* {@inheritDoc}
*/
public StructuredDocument<?> newInstance(MimeMediaType mimeType, Reader source) throws IOException {
return new DOMXMLDocument(mimeType, source);
}
}
public static final StructuredDocumentFactory.TextInstantiator INSTANTIATOR = new Instantiator();
private MimeMediaType mimeType;
/**
* Constructor for new instances of <CODE>DOMXMLDocument</CODE>
* with a value for the root element.
*
* @param mimeType This is the MIME Media Type being requested. In general
* it should be equivalent with the MIME Media Type returned by
* {@link #getMimeType()}. A <CODE>StructuredDocument</CODE>
* sub-class may, however, support more than one MIME Media type so this may be a
* true parameter. XMLDocument supports additional the MIME Media Type parameters,
* "charset". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.
* @param docType Used as the root type of this document. {@link net.jxta.document.XMLDocument} uses this as the XML
* <CODE>DOCTYPE</CODE>.
* @param value String value to be associated with the root element.
* null if none is wanted.
* @throws RuntimeException Exceptions generated by the underlying implementation.
*/
private DOMXMLDocument(final MimeMediaType mimeType, final String docType, final String value) {
super(null, null);
this.root = this;
this.mimeType = mimeType;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setValidating(false);
try {
DocumentBuilder dataDocBuilder = docBuilderFactory.newDocumentBuilder();
DOMImplementation domImpl = dataDocBuilder.getDOMImplementation();
DocumentType doctypeNode = domImpl.createDocumentType(docType, null, null);
domNode = domImpl.createDocument("http://jxta.org", docType, doctypeNode);
} catch (ParserConfigurationException misconfig) {
throw new UndeclaredThrowableException(misconfig);
}
if (value != null) {
Node text = ((Document) domNode).createTextNode(value);
((Document) domNode).getDocumentElement().appendChild(text);
}
}
/**
* Constructor for new instances of <CODE>DOMXMLDocument</CODE>
*
* @param mimeType This is the MIME Media Type being requested. In general it should be equivalent with
* the MIME Media Type returned by {@link #getMimeType()}. A <CODE>StructuredDocument</CODE>
* sub-class may, however, support more than one MIME Media type so this may be a
* true parameter. XMLDocument supports additional the MIME Media Type parameters,
* "charset". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.
* @param docType Used as the root type of this document. {@link net.jxta.document.XMLDocument} uses this as the XML
* <CODE>DOCTYPE</CODE>.
* @throws RuntimeException Exceptions generated by the underlying implementation.
*/
private DOMXMLDocument(final MimeMediaType mimeType, final String docType) {
this(mimeType, docType, null);
}
/**
* Constructor for existing documents.
*
* @param mimeType This is the MIME Media Type being requested. In general
* it should be equivalent with the MIME Media Type returned by
* {@link #getMimeType()}. A <CODE>StructuredDocument</CODE> sub-class may,
* however, support more than one MIME Media type so this may be a
* true parameter. XMLDocument supports additional the MIME Media Type parameters,
* "charset". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.
* @param stream Contains the input used to construct this object. This stream should be of a type
* conformant with the type specified by the MIME Media Type "charset" parameter.
* @throws RuntimeException Propagates exceptions from the underlying implementation.
* @throws java.io.IOException Thrown for failures processing the document.
*/
private DOMXMLDocument(final MimeMediaType mimeType, final InputStream stream) throws IOException {
super(null, null);
this.root = this;
this.mimeType = mimeType;
String charset = mimeType.getParameter("charset");
Reader source;
if (charset == null) {
source = new InputStreamReader(stream);
} else {
source = new InputStreamReader(stream, charset);
}
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setValidating(false);
try {
DocumentBuilder dataDocBuilder = docBuilderFactory.newDocumentBuilder();
domNode = dataDocBuilder.parse(new InputSource(source));
} catch (ParserConfigurationException misconfig) {
throw new UndeclaredThrowableException(misconfig);
} catch (SAXException parseError) {
throw new IOException(parseError.toString());
}
}
/**
* Constructor for existing documents.
*
* @param mimeType This is the MIME Media Type being requested. In general
* it should be equivalent with the MIME Media Type returned by
* {@link #getMimeType()}. A <CODE>StructuredDocument</CODE> sub-class may,
* however, support more than one MIME Media type so this may be a
* true parameter. XMLDocument supports additional the MIME Media Type parameters,
* "charset". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.
* @param source Contains the input used to construct this object. This reader
* should be of a type conformant with the type specified by the MIME Media Type
* "charset" parameter.
* @throws RuntimeException Propagates exceptions from the underlying implementation.
*/
private DOMXMLDocument(final MimeMediaType mimeType, final Reader source) throws IOException {
super(null, null);
this.root = this;
this.mimeType = mimeType;
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
docBuilderFactory.setValidating(false);
try {
DocumentBuilder dataDocBuilder = docBuilderFactory.newDocumentBuilder();
domNode = dataDocBuilder.parse(new InputSource(source));
} catch (ParserConfigurationException misconfig) {
throw new UndeclaredThrowableException(misconfig);
} catch (SAXException parseError) {
throw new IOException(parseError.toString());
}
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
try {
StringWriter stringOut = new StringWriter();
sendToWriter(stringOut);
stringOut.close();
return stringOut.toString();
} catch (IOException ex) {
throw new UndeclaredThrowableException(ex);
}
}
/**
* {@inheritDoc}
*/
public MimeMediaType getMimeType() {
return mimeType;
}
/**
* {@inheritDoc}
*/
public String getFileExtension() {
return Utils.getExtensionForMime(INSTANTIATOR.getSupportedFileExtensions(), getMimeType());
}
/**
* {@inheritDoc}
*/
public InputStream getStream() throws IOException {
String result = toString();
if (null == result) {
return null;
}
String charset = mimeType.getParameter("charset");
if (charset == null) {
return new ByteArrayInputStream(result.getBytes());
} else {
return new ByteArrayInputStream(result.getBytes(charset));
}
}
/**
* {@inheritDoc}
*/
public void sendToStream(OutputStream stream) throws IOException {
Writer osw;
String charset = mimeType.getParameter("charset");
if (charset == null) {
osw = new OutputStreamWriter(stream);
} else {
osw = new OutputStreamWriter(stream, charset);
}
Writer out = new BufferedWriter(osw);
sendToWriter(out);
out.flush();
osw.flush();
}
/**
* {@inheritDoc}
*/
public Reader getReader() {
String result = toString();
if (null == result) {
return null;
}
return new StringReader(result);
}
/**
* {@inheritDoc}
*/
public void sendToWriter(Writer writer) throws IOException {
String charset = mimeType.getParameter("charset");
try {
DOMImplementationLS domImpl = (DOMImplementationLS) ((Document) domNode).getImplementation().getFeature("LS", "3.0");
LSOutput output = domImpl.createLSOutput();
if (charset != null) {
output.setEncoding(charset);
} else {
output.setEncoding("UTF-8");
}
output.setCharacterStream(writer);
LSSerializer serial = domImpl.createLSSerializer();
serial.write(domNode, output);
} catch (Throwable ex) {
if (ex instanceof RuntimeException) {
throw (RuntimeException) ex;
} else if (ex instanceof Error) {
throw (Error) ex;
} else {
throw new UndeclaredThrowableException(ex);
}
}
}
/**
* {@inheritDoc}
*/
public DOMXMLElement createElement(Object key) {
return createElement(key, null);
}
/**
* {@inheritDoc}
*/
public DOMXMLElement createElement(Object key, Object val) {
if (!String.class.isAssignableFrom(key.getClass())) {
throw new ClassCastException(key.getClass().getName() + " not supported by createElement.");
}
if ((null != val) && !String.class.isAssignableFrom(val.getClass())) {
throw new ClassCastException(val.getClass().getName() + " not supported by createElement.");
}
return createElement((String) key, (String) val);
}
// StructuredDocument Methods
/**
* {@inheritDoc}
*/
public DOMXMLElement createElement(String name) {
return new DOMXMLElement(this, ((Document) domNode).createElement(name));
}
/**
* {@inheritDoc}
*/
public DOMXMLElement createElement(String name, String value) {
Element root;
root = ((Document) domNode).createElement(name);
if (null != value) {
root.appendChild(((Document) domNode).createTextNode(value));
}
return new DOMXMLElement(this, root);
}
// Element Methods
// Protected & Private Methods
@Override
protected Node getAssocNode() {
return ((Document) domNode).getDocumentElement();
}
} | [
"public",
"class",
"DOMXMLDocument",
"extends",
"DOMXMLElement",
"implements",
"XMLDocument",
"<",
"DOMXMLElement",
">",
"{",
"private",
"static",
"final",
"class",
"Instantiator",
"implements",
"StructuredDocumentFactory",
".",
"TextInstantiator",
"{",
"/**\n * The MIME Media Types which this <CODE>StructuredDocument</CODE> is\n * capable of emitting.\n */",
"private",
"static",
"final",
"MimeMediaType",
"[",
"]",
"myTypes",
"=",
"{",
"MimeMediaType",
".",
"XML_DEFAULTENCODING",
",",
"new",
"MimeMediaType",
"(",
"\"",
"Application",
"\"",
",",
"\"",
"Xml",
"\"",
")",
"}",
";",
"/**\n * these are the file extensions which are likely to contain files of\n * the type i like.\n */",
"private",
"static",
"final",
"ExtensionMapping",
"[",
"]",
"myExtensions",
"=",
"{",
"new",
"ExtensionMapping",
"(",
"\"",
"xml",
"\"",
",",
"myTypes",
"[",
"0",
"]",
")",
",",
"new",
"ExtensionMapping",
"(",
"\"",
"xml",
"\"",
",",
"null",
")",
"}",
";",
"/**\n * Creates new XMLDocumentInstantiator\n */",
"public",
"Instantiator",
"(",
")",
"{",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"MimeMediaType",
"[",
"]",
"getSupportedMimeTypes",
"(",
")",
"{",
"return",
"(",
"myTypes",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"ExtensionMapping",
"[",
"]",
"getSupportedFileExtensions",
"(",
")",
"{",
"return",
"(",
"myExtensions",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"StructuredDocument",
"<",
"?",
">",
"newInstance",
"(",
"MimeMediaType",
"mimeType",
",",
"String",
"doctype",
")",
"{",
"return",
"new",
"DOMXMLDocument",
"(",
"mimeType",
",",
"doctype",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"StructuredDocument",
"<",
"?",
">",
"newInstance",
"(",
"MimeMediaType",
"mimeType",
",",
"String",
"doctype",
",",
"String",
"value",
")",
"{",
"return",
"new",
"DOMXMLDocument",
"(",
"mimeType",
",",
"doctype",
",",
"value",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"StructuredDocument",
"<",
"?",
">",
"newInstance",
"(",
"MimeMediaType",
"mimeType",
",",
"InputStream",
"source",
")",
"throws",
"IOException",
"{",
"return",
"new",
"DOMXMLDocument",
"(",
"mimeType",
",",
"source",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"StructuredDocument",
"<",
"?",
">",
"newInstance",
"(",
"MimeMediaType",
"mimeType",
",",
"Reader",
"source",
")",
"throws",
"IOException",
"{",
"return",
"new",
"DOMXMLDocument",
"(",
"mimeType",
",",
"source",
")",
";",
"}",
"}",
"public",
"static",
"final",
"StructuredDocumentFactory",
".",
"TextInstantiator",
"INSTANTIATOR",
"=",
"new",
"Instantiator",
"(",
")",
";",
"private",
"MimeMediaType",
"mimeType",
";",
"/**\n * Constructor for new instances of <CODE>DOMXMLDocument</CODE>\n * with a value for the root element.\n *\n * @param mimeType This is the MIME Media Type being requested. In general\n * it should be equivalent with the MIME Media Type returned by\n * {@link #getMimeType()}. A <CODE>StructuredDocument</CODE>\n * sub-class may, however, support more than one MIME Media type so this may be a\n * true parameter. XMLDocument supports additional the MIME Media Type parameters,\n * \"charset\". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.\n * @param docType Used as the root type of this document. {@link net.jxta.document.XMLDocument} uses this as the XML\n * <CODE>DOCTYPE</CODE>.\n * @param value String value to be associated with the root element.\n * null if none is wanted.\n * @throws RuntimeException Exceptions generated by the underlying implementation.\n */",
"private",
"DOMXMLDocument",
"(",
"final",
"MimeMediaType",
"mimeType",
",",
"final",
"String",
"docType",
",",
"final",
"String",
"value",
")",
"{",
"super",
"(",
"null",
",",
"null",
")",
";",
"this",
".",
"root",
"=",
"this",
";",
"this",
".",
"mimeType",
"=",
"mimeType",
";",
"DocumentBuilderFactory",
"docBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"docBuilderFactory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"docBuilderFactory",
".",
"setValidating",
"(",
"false",
")",
";",
"try",
"{",
"DocumentBuilder",
"dataDocBuilder",
"=",
"docBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"DOMImplementation",
"domImpl",
"=",
"dataDocBuilder",
".",
"getDOMImplementation",
"(",
")",
";",
"DocumentType",
"doctypeNode",
"=",
"domImpl",
".",
"createDocumentType",
"(",
"docType",
",",
"null",
",",
"null",
")",
";",
"domNode",
"=",
"domImpl",
".",
"createDocument",
"(",
"\"",
"http://jxta.org",
"\"",
",",
"docType",
",",
"doctypeNode",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"misconfig",
")",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"misconfig",
")",
";",
"}",
"if",
"(",
"value",
"!=",
"null",
")",
"{",
"Node",
"text",
"=",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"createTextNode",
"(",
"value",
")",
";",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"getDocumentElement",
"(",
")",
".",
"appendChild",
"(",
"text",
")",
";",
"}",
"}",
"/**\n * Constructor for new instances of <CODE>DOMXMLDocument</CODE>\n *\n * @param mimeType This is the MIME Media Type being requested. In general it should be equivalent with\n * the MIME Media Type returned by {@link #getMimeType()}. A <CODE>StructuredDocument</CODE>\n * sub-class may, however, support more than one MIME Media type so this may be a\n * true parameter. XMLDocument supports additional the MIME Media Type parameters,\n * \"charset\". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.\n * @param docType Used as the root type of this document. {@link net.jxta.document.XMLDocument} uses this as the XML\n * <CODE>DOCTYPE</CODE>.\n * @throws RuntimeException Exceptions generated by the underlying implementation.\n */",
"private",
"DOMXMLDocument",
"(",
"final",
"MimeMediaType",
"mimeType",
",",
"final",
"String",
"docType",
")",
"{",
"this",
"(",
"mimeType",
",",
"docType",
",",
"null",
")",
";",
"}",
"/**\n * Constructor for existing documents.\n *\n * @param mimeType This is the MIME Media Type being requested. In general\n * it should be equivalent with the MIME Media Type returned by\n * {@link #getMimeType()}. A <CODE>StructuredDocument</CODE> sub-class may,\n * however, support more than one MIME Media type so this may be a\n * true parameter. XMLDocument supports additional the MIME Media Type parameters,\n * \"charset\". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.\n * @param stream Contains the input used to construct this object. This stream should be of a type\n * conformant with the type specified by the MIME Media Type \"charset\" parameter.\n * @throws RuntimeException Propagates exceptions from the underlying implementation.\n * @throws java.io.IOException Thrown for failures processing the document.\n */",
"private",
"DOMXMLDocument",
"(",
"final",
"MimeMediaType",
"mimeType",
",",
"final",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"super",
"(",
"null",
",",
"null",
")",
";",
"this",
".",
"root",
"=",
"this",
";",
"this",
".",
"mimeType",
"=",
"mimeType",
";",
"String",
"charset",
"=",
"mimeType",
".",
"getParameter",
"(",
"\"",
"charset",
"\"",
")",
";",
"Reader",
"source",
";",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"source",
"=",
"new",
"InputStreamReader",
"(",
"stream",
")",
";",
"}",
"else",
"{",
"source",
"=",
"new",
"InputStreamReader",
"(",
"stream",
",",
"charset",
")",
";",
"}",
"DocumentBuilderFactory",
"docBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"docBuilderFactory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"docBuilderFactory",
".",
"setValidating",
"(",
"false",
")",
";",
"try",
"{",
"DocumentBuilder",
"dataDocBuilder",
"=",
"docBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"domNode",
"=",
"dataDocBuilder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"source",
")",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"misconfig",
")",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"misconfig",
")",
";",
"}",
"catch",
"(",
"SAXException",
"parseError",
")",
"{",
"throw",
"new",
"IOException",
"(",
"parseError",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"/**\n * Constructor for existing documents.\n *\n * @param mimeType This is the MIME Media Type being requested. In general\n * it should be equivalent with the MIME Media Type returned by\n * {@link #getMimeType()}. A <CODE>StructuredDocument</CODE> sub-class may,\n * however, support more than one MIME Media type so this may be a\n * true parameter. XMLDocument supports additional the MIME Media Type parameters,\n * \"charset\". The charset parameter must be a value per IETF RFC 2279 or ISO-10646.\n * @param source Contains the input used to construct this object. This reader\n * should be of a type conformant with the type specified by the MIME Media Type\n * \"charset\" parameter.\n * @throws RuntimeException Propagates exceptions from the underlying implementation.\n */",
"private",
"DOMXMLDocument",
"(",
"final",
"MimeMediaType",
"mimeType",
",",
"final",
"Reader",
"source",
")",
"throws",
"IOException",
"{",
"super",
"(",
"null",
",",
"null",
")",
";",
"this",
".",
"root",
"=",
"this",
";",
"this",
".",
"mimeType",
"=",
"mimeType",
";",
"DocumentBuilderFactory",
"docBuilderFactory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"docBuilderFactory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"docBuilderFactory",
".",
"setValidating",
"(",
"false",
")",
";",
"try",
"{",
"DocumentBuilder",
"dataDocBuilder",
"=",
"docBuilderFactory",
".",
"newDocumentBuilder",
"(",
")",
";",
"domNode",
"=",
"dataDocBuilder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"source",
")",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"misconfig",
")",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"misconfig",
")",
";",
"}",
"catch",
"(",
"SAXException",
"parseError",
")",
"{",
"throw",
"new",
"IOException",
"(",
"parseError",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"/**\n * {@inheritDoc}\n */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"try",
"{",
"StringWriter",
"stringOut",
"=",
"new",
"StringWriter",
"(",
")",
";",
"sendToWriter",
"(",
"stringOut",
")",
";",
"stringOut",
".",
"close",
"(",
")",
";",
"return",
"stringOut",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"ex",
")",
";",
"}",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"MimeMediaType",
"getMimeType",
"(",
")",
"{",
"return",
"mimeType",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"String",
"getFileExtension",
"(",
")",
"{",
"return",
"Utils",
".",
"getExtensionForMime",
"(",
"INSTANTIATOR",
".",
"getSupportedFileExtensions",
"(",
")",
",",
"getMimeType",
"(",
")",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"InputStream",
"getStream",
"(",
")",
"throws",
"IOException",
"{",
"String",
"result",
"=",
"toString",
"(",
")",
";",
"if",
"(",
"null",
"==",
"result",
")",
"{",
"return",
"null",
";",
"}",
"String",
"charset",
"=",
"mimeType",
".",
"getParameter",
"(",
"\"",
"charset",
"\"",
")",
";",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"return",
"new",
"ByteArrayInputStream",
"(",
"result",
".",
"getBytes",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"ByteArrayInputStream",
"(",
"result",
".",
"getBytes",
"(",
"charset",
")",
")",
";",
"}",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"void",
"sendToStream",
"(",
"OutputStream",
"stream",
")",
"throws",
"IOException",
"{",
"Writer",
"osw",
";",
"String",
"charset",
"=",
"mimeType",
".",
"getParameter",
"(",
"\"",
"charset",
"\"",
")",
";",
"if",
"(",
"charset",
"==",
"null",
")",
"{",
"osw",
"=",
"new",
"OutputStreamWriter",
"(",
"stream",
")",
";",
"}",
"else",
"{",
"osw",
"=",
"new",
"OutputStreamWriter",
"(",
"stream",
",",
"charset",
")",
";",
"}",
"Writer",
"out",
"=",
"new",
"BufferedWriter",
"(",
"osw",
")",
";",
"sendToWriter",
"(",
"out",
")",
";",
"out",
".",
"flush",
"(",
")",
";",
"osw",
".",
"flush",
"(",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"Reader",
"getReader",
"(",
")",
"{",
"String",
"result",
"=",
"toString",
"(",
")",
";",
"if",
"(",
"null",
"==",
"result",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"StringReader",
"(",
"result",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"void",
"sendToWriter",
"(",
"Writer",
"writer",
")",
"throws",
"IOException",
"{",
"String",
"charset",
"=",
"mimeType",
".",
"getParameter",
"(",
"\"",
"charset",
"\"",
")",
";",
"try",
"{",
"DOMImplementationLS",
"domImpl",
"=",
"(",
"DOMImplementationLS",
")",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"getImplementation",
"(",
")",
".",
"getFeature",
"(",
"\"",
"LS",
"\"",
",",
"\"",
"3.0",
"\"",
")",
";",
"LSOutput",
"output",
"=",
"domImpl",
".",
"createLSOutput",
"(",
")",
";",
"if",
"(",
"charset",
"!=",
"null",
")",
"{",
"output",
".",
"setEncoding",
"(",
"charset",
")",
";",
"}",
"else",
"{",
"output",
".",
"setEncoding",
"(",
"\"",
"UTF-8",
"\"",
")",
";",
"}",
"output",
".",
"setCharacterStream",
"(",
"writer",
")",
";",
"LSSerializer",
"serial",
"=",
"domImpl",
".",
"createLSSerializer",
"(",
")",
";",
"serial",
".",
"write",
"(",
"domNode",
",",
"output",
")",
";",
"}",
"catch",
"(",
"Throwable",
"ex",
")",
"{",
"if",
"(",
"ex",
"instanceof",
"RuntimeException",
")",
"{",
"throw",
"(",
"RuntimeException",
")",
"ex",
";",
"}",
"else",
"if",
"(",
"ex",
"instanceof",
"Error",
")",
"{",
"throw",
"(",
"Error",
")",
"ex",
";",
"}",
"else",
"{",
"throw",
"new",
"UndeclaredThrowableException",
"(",
"ex",
")",
";",
"}",
"}",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"DOMXMLElement",
"createElement",
"(",
"Object",
"key",
")",
"{",
"return",
"createElement",
"(",
"key",
",",
"null",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"DOMXMLElement",
"createElement",
"(",
"Object",
"key",
",",
"Object",
"val",
")",
"{",
"if",
"(",
"!",
"String",
".",
"class",
".",
"isAssignableFrom",
"(",
"key",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"key",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"",
" not supported by createElement.",
"\"",
")",
";",
"}",
"if",
"(",
"(",
"null",
"!=",
"val",
")",
"&&",
"!",
"String",
".",
"class",
".",
"isAssignableFrom",
"(",
"val",
".",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ClassCastException",
"(",
"val",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"",
" not supported by createElement.",
"\"",
")",
";",
"}",
"return",
"createElement",
"(",
"(",
"String",
")",
"key",
",",
"(",
"String",
")",
"val",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"DOMXMLElement",
"createElement",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"DOMXMLElement",
"(",
"this",
",",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"createElement",
"(",
"name",
")",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"public",
"DOMXMLElement",
"createElement",
"(",
"String",
"name",
",",
"String",
"value",
")",
"{",
"Element",
"root",
";",
"root",
"=",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"createElement",
"(",
"name",
")",
";",
"if",
"(",
"null",
"!=",
"value",
")",
"{",
"root",
".",
"appendChild",
"(",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"createTextNode",
"(",
"value",
")",
")",
";",
"}",
"return",
"new",
"DOMXMLElement",
"(",
"this",
",",
"root",
")",
";",
"}",
"@",
"Override",
"protected",
"Node",
"getAssocNode",
"(",
")",
"{",
"return",
"(",
"(",
"Document",
")",
"domNode",
")",
".",
"getDocumentElement",
"(",
")",
";",
"}",
"}"
] | This class is an implementation of the StructuredDocument interface using
DOM | [
"This",
"class",
"is",
"an",
"implementation",
"of",
"the",
"StructuredDocument",
"interface",
"using",
"DOM"
] | [
"// StructuredDocument Methods",
"// Element Methods",
"// Protected & Private Methods"
] | [
{
"param": "DOMXMLElement",
"type": null
},
{
"param": "XMLDocument<DOMXMLElement>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "DOMXMLElement",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "XMLDocument<DOMXMLElement>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0713ab1b49a210bdb05d2da7e914a80cac010c1b | rosariopfernandes/systembuilderlib | src/com/jgoodies/forms/util/DefaultUnitConverter.java | [
"Apache-2.0"
] | Java | DefaultUnitConverter | /**
* This is the default implementation of the {@link UnitConverter} interface.
* It converts horizontal and vertical dialog base units to pixels.<p>
*
* The horizontal base unit is equal to the average width, in pixels,
* of the characters in the system font; the vertical base unit is equal
* to the height, in pixels, of the font.
* Each horizontal base unit is equal to 4 horizontal dialog units;
* each vertical base unit is equal to 8 vertical dialog units.<p>
*
* The DefaultUnitConverter computes dialog base units using a default font
* and a test string for the average character width. You can configure
* the font and the test string via the bound Bean properties
* <em>defaultDialogFont</em> and <em>averageCharacterWidthTestString</em>.
* See also Microsoft's suggestion for a custom computation
* <a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681">custom computation</a>.
* More information how to use dialog units in screen design can be found
* in Microsoft's
* <a href="http://msdn2.microsoft.com/en-us/library/ms997619">Design
* Specifications and Guidelines</a>.<p>
*
* Since the Forms 1.1 this converter logs font information at
* the {@code CONFIG} level.
*
* @version $Revision: 1.23 $
* @author Karsten Lentzsch
* @see UnitConverter
* @see com.jgoodies.forms.layout.Size
* @see com.jgoodies.forms.layout.Sizes
*/ | This is the default implementation of the UnitConverter interface.
It converts horizontal and vertical dialog base units to pixels.
The horizontal base unit is equal to the average width, in pixels,
of the characters in the system font; the vertical base unit is equal
to the height, in pixels, of the font.
Each horizontal base unit is equal to 4 horizontal dialog units;
each vertical base unit is equal to 8 vertical dialog units.
The DefaultUnitConverter computes dialog base units using a default font
and a test string for the average character width. You can configure
the font and the test string via the bound Bean properties
defaultDialogFont and averageCharacterWidthTestString.
See also Microsoft's suggestion for a custom computation
custom computation.
More information how to use dialog units in screen design can be found
in Microsoft's
Design
Specifications and Guidelines.
Since the Forms 1.1 this converter logs font information at
the CONFIG level.
| [
"This",
"is",
"the",
"default",
"implementation",
"of",
"the",
"UnitConverter",
"interface",
".",
"It",
"converts",
"horizontal",
"and",
"vertical",
"dialog",
"base",
"units",
"to",
"pixels",
".",
"The",
"horizontal",
"base",
"unit",
"is",
"equal",
"to",
"the",
"average",
"width",
"in",
"pixels",
"of",
"the",
"characters",
"in",
"the",
"system",
"font",
";",
"the",
"vertical",
"base",
"unit",
"is",
"equal",
"to",
"the",
"height",
"in",
"pixels",
"of",
"the",
"font",
".",
"Each",
"horizontal",
"base",
"unit",
"is",
"equal",
"to",
"4",
"horizontal",
"dialog",
"units",
";",
"each",
"vertical",
"base",
"unit",
"is",
"equal",
"to",
"8",
"vertical",
"dialog",
"units",
".",
"The",
"DefaultUnitConverter",
"computes",
"dialog",
"base",
"units",
"using",
"a",
"default",
"font",
"and",
"a",
"test",
"string",
"for",
"the",
"average",
"character",
"width",
".",
"You",
"can",
"configure",
"the",
"font",
"and",
"the",
"test",
"string",
"via",
"the",
"bound",
"Bean",
"properties",
"defaultDialogFont",
"and",
"averageCharacterWidthTestString",
".",
"See",
"also",
"Microsoft",
"'",
"s",
"suggestion",
"for",
"a",
"custom",
"computation",
"custom",
"computation",
".",
"More",
"information",
"how",
"to",
"use",
"dialog",
"units",
"in",
"screen",
"design",
"can",
"be",
"found",
"in",
"Microsoft",
"'",
"s",
"Design",
"Specifications",
"and",
"Guidelines",
".",
"Since",
"the",
"Forms",
"1",
".",
"1",
"this",
"converter",
"logs",
"font",
"information",
"at",
"the",
"CONFIG",
"level",
"."
] | public final class DefaultUnitConverter extends AbstractUnitConverter {
public static final String PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING =
"averageCharacterWidthTestString";
public static final String PROPERTY_DEFAULT_DIALOG_FONT =
"defaultDialogFont";
/**
* @since 1.6
*/
public static final String OLD_AVERAGE_CHARACTER_TEST_STRING =
"X";
/**
* @since 1.4
*/
public static final String MODERN_AVERAGE_CHARACTER_TEST_STRING =
"abcdefghijklmnopqrstuvwxyz0123456789";
/**
* @since 1.4
*/
public static final String BALANCED_AVERAGE_CHARACTER_TEST_STRING =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
private static final Logger LOGGER =
Logger.getLogger(DefaultUnitConverter.class.getName());
/**
* Holds the sole instance that will be lazily instantiated.
*/
private static DefaultUnitConverter instance;
/**
* Holds the string that is used to compute the average character width.
* Since 1.6 the default value is the balanced average character test
* string, where it was just "X" before.
*/
private String averageCharWidthTestString =
BALANCED_AVERAGE_CHARACTER_TEST_STRING;
/**
* Holds a custom font that is used to compute the global dialog base units.
* If not set, a fallback font is is lazily created in method
* #getCachedDefaultDialogFont, which in turn looks up a font
* in method #lookupDefaultDialogFont.
*/
private Font defaultDialogFont;
// Cached *****************************************************************
/**
* Holds the lazily created cached global dialog base units that are used
* if a component is not (yet) available - for example in a Border.
*/
private DialogBaseUnits cachedGlobalDialogBaseUnits = null;
/**
* Holds the horizontal dialog base units that are valid
* for the FontMetrics stored in {@code cachedFontMetrics}.
*/
private DialogBaseUnits cachedDialogBaseUnits = null;
/**
* Holds the FontMetrics used to compute the per-component dialog units.
* The latter are valid, if a FontMetrics equals this stored metrics.
*/
private FontMetrics cachedFontMetrics = null;
/**
* Holds a cached default dialog font that is used as fallback,
* if no default dialog font has been set.
*
* @see #getDefaultDialogFont()
* @see #setDefaultDialogFont(Font)
*/
private Font cachedDefaultDialogFont = null;
// Instance Creation and Access *******************************************
/**
* Constructs a DefaultUnitConverter and registers
* a listener that handles changes in the look&feel.
*/
private DefaultUnitConverter() {
}
/**
* Lazily instantiates and returns the sole instance.
*
* @return the lazily instantiated sole instance
*/
public static DefaultUnitConverter getInstance() {
if (instance == null) {
instance = new DefaultUnitConverter();
}
return instance;
}
// Access to Bound Properties *********************************************
/**
* Returns the string used to compute the average character width.
* By default it is initialized to
* {@link #BALANCED_AVERAGE_CHARACTER_TEST_STRING}.
*
* @return the test string used to compute the average character width
*/
public String getAverageCharacterWidthTestString() {
return averageCharWidthTestString;
}
/**
* Sets a string that will be used to compute the average character width.
* By default it is initialized to
* {@link #BALANCED_AVERAGE_CHARACTER_TEST_STRING}. You can provide
* other test strings, for example:
* <ul>
* <li>"Xximeee"</li>
* <li>"ABCEDEFHIJKLMNOPQRSTUVWXYZ"</li>
* <li>"abcdefghijklmnopqrstuvwxyz"</li>
* </ul>
*
* @param newTestString the test string to be used
* @throws NullPointerException if {@code newTestString} is {@code null}
* @throws IllegalArgumentException if {@code newTestString} is empty or whitespace
*/
public void setAverageCharacterWidthTestString(String newTestString) {
checkNotBlank(newTestString, MUST_NOT_BE_BLANK, "test string");
String oldTestString = averageCharWidthTestString;
averageCharWidthTestString = newTestString;
firePropertyChange(
PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING,
oldTestString,
newTestString);
}
/**
* Returns the dialog font that is used to compute the dialog base units.
* If a default dialog font has been set using
* {@link #setDefaultDialogFont(Font)}, this font will be returned.
* Otherwise a cached fallback will be lazily created.
*
* @return the font used to compute the dialog base units
*/
public Font getDefaultDialogFont() {
return defaultDialogFont != null
? defaultDialogFont
: getCachedDefaultDialogFont();
}
/**
* Sets a dialog font that will be used to compute the dialog base units.
*
* @param newFont the default dialog font to be set
*/
public void setDefaultDialogFont(Font newFont) {
Font oldFont = defaultDialogFont; // Don't use the getter
defaultDialogFont = newFont;
clearCache();
firePropertyChange(PROPERTY_DEFAULT_DIALOG_FONT, oldFont, newFont);
}
// Implementing Abstract Superclass Behavior ******************************
/**
* Returns the cached or computed horizontal dialog base units.
*
* @param component a Component that provides the font and graphics
* @return the horizontal dialog base units
*/
@Override
protected double getDialogBaseUnitsX(Component component) {
return getDialogBaseUnits(component).x;
}
/**
* Returns the cached or computed vertical dialog base units
* for the given component.
*
* @param component a Component that provides the font and graphics
* @return the vertical dialog base units
*/
@Override
protected double getDialogBaseUnitsY(Component component) {
return getDialogBaseUnits(component).y;
}
// Compute and Cache Global and Components Dialog Base Units **************
/**
* Lazily computes and answer the global dialog base units.
* Should be re-computed if the l&f, platform, or screen changes.
*
* @return a cached DialogBaseUnits object used globally if no container is available
*/
private DialogBaseUnits getGlobalDialogBaseUnits() {
if (cachedGlobalDialogBaseUnits == null) {
cachedGlobalDialogBaseUnits = computeGlobalDialogBaseUnits();
}
return cachedGlobalDialogBaseUnits;
}
/**
* Looks up and returns the dialog base units for the given component.
* In case the component is {@code null} the global dialog base units
* are answered.<p>
*
* Before we compute the dialog base units we check whether they
* have been computed and cached before - for the same component
* {@code FontMetrics}.
*
* @param c the component that provides the graphics object
* @return the DialogBaseUnits object for the given component
*/
private DialogBaseUnits getDialogBaseUnits(Component c) {
FormUtils.ensureValidCache();
if (c == null) { // || (font = c.getFont()) == null) {
// logInfo("Missing font metrics: " + c);
return getGlobalDialogBaseUnits();
}
FontMetrics fm = c.getFontMetrics(getDefaultDialogFont());
if (fm.equals(cachedFontMetrics)) {
return cachedDialogBaseUnits;
}
DialogBaseUnits dialogBaseUnits = computeDialogBaseUnits(fm);
cachedFontMetrics = fm;
cachedDialogBaseUnits = dialogBaseUnits;
return dialogBaseUnits;
}
/**
* Computes and returns the horizontal dialog base units.
* Honors the font, font size and resolution.<p>
*
* Implementation Note: 14dluY map to 22 pixel for 8pt Tahoma on 96 dpi.
* I could not yet manage to compute the Microsoft compliant font height.
* Therefore this method adds a correction value that seems to work
* well with the vast majority of desktops.<p>
*
* TODO: Revise the computation of vertical base units as soon as
* there are more information about the original computation
* in Microsoft environments.
*
* @param metrics the FontMetrics used to measure the dialog font
* @return the horizontal and vertical dialog base units
*/
private DialogBaseUnits computeDialogBaseUnits(FontMetrics metrics) {
double averageCharWidth =
computeAverageCharWidth(metrics, averageCharWidthTestString);
int ascent = metrics.getAscent();
double height = ascent > 14 ? ascent : ascent + (15 - ascent) / 3;
DialogBaseUnits dialogBaseUnits =
new DialogBaseUnits(averageCharWidth, height);
if (LOGGER.isLoggable(Level.CONFIG)) {
LOGGER.config(
"Computed dialog base units "
+ dialogBaseUnits
+ " for: "
+ metrics.getFont());
}
return dialogBaseUnits;
}
/**
* Computes the global dialog base units. The current implementation
* assumes a fixed 8pt font and on 96 or 120 dpi. A better implementation
* should ask for the main dialog font and should honor the current
* screen resolution.<p>
*
* Should be re-computed if the l&f, platform, or screen changes.
*
* @return a DialogBaseUnits object used globally if no container is available
*/
private DialogBaseUnits computeGlobalDialogBaseUnits() {
LOGGER.config("Computing global dialog base units...");
Font dialogFont = getDefaultDialogFont();
FontMetrics metrics = createDefaultGlobalComponent().getFontMetrics(dialogFont);
DialogBaseUnits globalDialogBaseUnits = computeDialogBaseUnits(metrics);
return globalDialogBaseUnits;
}
/**
* Lazily creates and returns a fallback for the dialog font
* that is used to compute the dialog base units.
* This fallback font is cached and will be reset if the L&F changes.
*
* @return the cached fallback font used to compute the dialog base units
*/
private Font getCachedDefaultDialogFont() {
FormUtils.ensureValidCache();
if (cachedDefaultDialogFont == null) {
cachedDefaultDialogFont = lookupDefaultDialogFont();
}
return cachedDefaultDialogFont;
}
/**
* Looks up and returns the font used by buttons.
* First, tries to request the button font from the UIManager;
* if this fails a JButton is created and asked for its font.
*
* @return the font used for a standard button
*/
private static Font lookupDefaultDialogFont() {
Font buttonFont = UIManager.getFont("Button.font");
return buttonFont != null
? buttonFont
: new JButton().getFont();
}
/**
* Creates and returns a component that is used to lookup the default
* font metrics. The current implementation creates a {@code JPanel}.
* Since this panel has no parent, it has no toolkit assigned. And so,
* requesting the font metrics will end up using the default toolkit
* and its deprecated method {@code ToolKit#getFontMetrics()}.<p>
*
* TODO: Consider publishing this method and providing a setter, so that
* an API user can set a realized component that has a toolkit assigned.
*
* @return a component used to compute the default font metrics
*/
private static Component createDefaultGlobalComponent() {
return new JPanel(null);
}
/**
* Invalidates the caches. Resets the global dialog base units,
* clears the Map from {@code FontMetrics} to dialog base units,
* and resets the fallback for the default dialog font.
* This is invoked after a change of the look&feel.
*/
void clearCache() {
cachedGlobalDialogBaseUnits = null;
cachedFontMetrics = null;
cachedDefaultDialogFont = null;
}
// Helper Code ************************************************************
/**
* Describes horizontal and vertical dialog base units.
*/
private static final class DialogBaseUnits {
final double x;
final double y;
DialogBaseUnits(double dialogBaseUnitsX, double dialogBaseUnitsY) {
this.x = dialogBaseUnitsX;
this.y = dialogBaseUnitsY;
}
@Override
public String toString() {
return "DBU(x=" + x + "; y=" + y + ")";
}
}
} | [
"public",
"final",
"class",
"DefaultUnitConverter",
"extends",
"AbstractUnitConverter",
"{",
"public",
"static",
"final",
"String",
"PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING",
"=",
"\"",
"averageCharacterWidthTestString",
"\"",
";",
"public",
"static",
"final",
"String",
"PROPERTY_DEFAULT_DIALOG_FONT",
"=",
"\"",
"defaultDialogFont",
"\"",
";",
"/**\r\n * @since 1.6\r\n */",
"public",
"static",
"final",
"String",
"OLD_AVERAGE_CHARACTER_TEST_STRING",
"=",
"\"",
"X",
"\"",
";",
"/**\r\n * @since 1.4\r\n */",
"public",
"static",
"final",
"String",
"MODERN_AVERAGE_CHARACTER_TEST_STRING",
"=",
"\"",
"abcdefghijklmnopqrstuvwxyz0123456789",
"\"",
";",
"/**\r\n * @since 1.4\r\n */",
"public",
"static",
"final",
"String",
"BALANCED_AVERAGE_CHARACTER_TEST_STRING",
"=",
"\"",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
"\"",
";",
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"Logger",
".",
"getLogger",
"(",
"DefaultUnitConverter",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"/**\r\n * Holds the sole instance that will be lazily instantiated.\r\n */",
"private",
"static",
"DefaultUnitConverter",
"instance",
";",
"/**\r\n * Holds the string that is used to compute the average character width.\r\n * Since 1.6 the default value is the balanced average character test\r\n * string, where it was just "X" before.\r\n */",
"private",
"String",
"averageCharWidthTestString",
"=",
"BALANCED_AVERAGE_CHARACTER_TEST_STRING",
";",
"/**\r\n * Holds a custom font that is used to compute the global dialog base units.\r\n * If not set, a fallback font is is lazily created in method\r\n * #getCachedDefaultDialogFont, which in turn looks up a font\r\n * in method #lookupDefaultDialogFont.\r\n */",
"private",
"Font",
"defaultDialogFont",
";",
"/**\r\n * Holds the lazily created cached global dialog base units that are used\r\n * if a component is not (yet) available - for example in a Border.\r\n */",
"private",
"DialogBaseUnits",
"cachedGlobalDialogBaseUnits",
"=",
"null",
";",
"/**\r\n * Holds the horizontal dialog base units that are valid\r\n * for the FontMetrics stored in {@code cachedFontMetrics}.\r\n */",
"private",
"DialogBaseUnits",
"cachedDialogBaseUnits",
"=",
"null",
";",
"/**\r\n * Holds the FontMetrics used to compute the per-component dialog units.\r\n * The latter are valid, if a FontMetrics equals this stored metrics.\r\n */",
"private",
"FontMetrics",
"cachedFontMetrics",
"=",
"null",
";",
"/**\r\n * Holds a cached default dialog font that is used as fallback,\r\n * if no default dialog font has been set.\r\n *\r\n * @see #getDefaultDialogFont()\r\n * @see #setDefaultDialogFont(Font)\r\n */",
"private",
"Font",
"cachedDefaultDialogFont",
"=",
"null",
";",
"/**\r\n * Constructs a DefaultUnitConverter and registers\r\n * a listener that handles changes in the look&feel.\r\n */",
"private",
"DefaultUnitConverter",
"(",
")",
"{",
"}",
"/**\r\n * Lazily instantiates and returns the sole instance.\r\n *\r\n * @return the lazily instantiated sole instance\r\n */",
"public",
"static",
"DefaultUnitConverter",
"getInstance",
"(",
")",
"{",
"if",
"(",
"instance",
"==",
"null",
")",
"{",
"instance",
"=",
"new",
"DefaultUnitConverter",
"(",
")",
";",
"}",
"return",
"instance",
";",
"}",
"/**\r\n * Returns the string used to compute the average character width.\r\n * By default it is initialized to\r\n * {@link #BALANCED_AVERAGE_CHARACTER_TEST_STRING}.\r\n *\r\n * @return the test string used to compute the average character width\r\n */",
"public",
"String",
"getAverageCharacterWidthTestString",
"(",
")",
"{",
"return",
"averageCharWidthTestString",
";",
"}",
"/**\r\n * Sets a string that will be used to compute the average character width.\r\n * By default it is initialized to\r\n * {@link #BALANCED_AVERAGE_CHARACTER_TEST_STRING}. You can provide\r\n * other test strings, for example:\r\n * <ul>\r\n * <li>"Xximeee"</li>\r\n * <li>"ABCEDEFHIJKLMNOPQRSTUVWXYZ"</li>\r\n * <li>"abcdefghijklmnopqrstuvwxyz"</li>\r\n * </ul>\r\n *\r\n * @param newTestString the test string to be used\r\n * @throws NullPointerException if {@code newTestString} is {@code null}\r\n * @throws IllegalArgumentException if {@code newTestString} is empty or whitespace\r\n */",
"public",
"void",
"setAverageCharacterWidthTestString",
"(",
"String",
"newTestString",
")",
"{",
"checkNotBlank",
"(",
"newTestString",
",",
"MUST_NOT_BE_BLANK",
",",
"\"",
"test string",
"\"",
")",
";",
"String",
"oldTestString",
"=",
"averageCharWidthTestString",
";",
"averageCharWidthTestString",
"=",
"newTestString",
";",
"firePropertyChange",
"(",
"PROPERTY_AVERAGE_CHARACTER_WIDTH_TEST_STRING",
",",
"oldTestString",
",",
"newTestString",
")",
";",
"}",
"/**\r\n * Returns the dialog font that is used to compute the dialog base units.\r\n * If a default dialog font has been set using\r\n * {@link #setDefaultDialogFont(Font)}, this font will be returned.\r\n * Otherwise a cached fallback will be lazily created.\r\n *\r\n * @return the font used to compute the dialog base units\r\n */",
"public",
"Font",
"getDefaultDialogFont",
"(",
")",
"{",
"return",
"defaultDialogFont",
"!=",
"null",
"?",
"defaultDialogFont",
":",
"getCachedDefaultDialogFont",
"(",
")",
";",
"}",
"/**\r\n * Sets a dialog font that will be used to compute the dialog base units.\r\n *\r\n * @param newFont the default dialog font to be set\r\n */",
"public",
"void",
"setDefaultDialogFont",
"(",
"Font",
"newFont",
")",
"{",
"Font",
"oldFont",
"=",
"defaultDialogFont",
";",
"defaultDialogFont",
"=",
"newFont",
";",
"clearCache",
"(",
")",
";",
"firePropertyChange",
"(",
"PROPERTY_DEFAULT_DIALOG_FONT",
",",
"oldFont",
",",
"newFont",
")",
";",
"}",
"/**\r\n * Returns the cached or computed horizontal dialog base units.\r\n *\r\n * @param component a Component that provides the font and graphics\r\n * @return the horizontal dialog base units\r\n */",
"@",
"Override",
"protected",
"double",
"getDialogBaseUnitsX",
"(",
"Component",
"component",
")",
"{",
"return",
"getDialogBaseUnits",
"(",
"component",
")",
".",
"x",
";",
"}",
"/**\r\n * Returns the cached or computed vertical dialog base units\r\n * for the given component.\r\n *\r\n * @param component a Component that provides the font and graphics\r\n * @return the vertical dialog base units\r\n */",
"@",
"Override",
"protected",
"double",
"getDialogBaseUnitsY",
"(",
"Component",
"component",
")",
"{",
"return",
"getDialogBaseUnits",
"(",
"component",
")",
".",
"y",
";",
"}",
"/**\r\n * Lazily computes and answer the global dialog base units.\r\n * Should be re-computed if the l&f, platform, or screen changes.\r\n *\r\n * @return a cached DialogBaseUnits object used globally if no container is available\r\n */",
"private",
"DialogBaseUnits",
"getGlobalDialogBaseUnits",
"(",
")",
"{",
"if",
"(",
"cachedGlobalDialogBaseUnits",
"==",
"null",
")",
"{",
"cachedGlobalDialogBaseUnits",
"=",
"computeGlobalDialogBaseUnits",
"(",
")",
";",
"}",
"return",
"cachedGlobalDialogBaseUnits",
";",
"}",
"/**\r\n * Looks up and returns the dialog base units for the given component.\r\n * In case the component is {@code null} the global dialog base units\r\n * are answered.<p>\r\n *\r\n * Before we compute the dialog base units we check whether they\r\n * have been computed and cached before - for the same component\r\n * {@code FontMetrics}.\r\n *\r\n * @param c the component that provides the graphics object\r\n * @return the DialogBaseUnits object for the given component\r\n */",
"private",
"DialogBaseUnits",
"getDialogBaseUnits",
"(",
"Component",
"c",
")",
"{",
"FormUtils",
".",
"ensureValidCache",
"(",
")",
";",
"if",
"(",
"c",
"==",
"null",
")",
"{",
"return",
"getGlobalDialogBaseUnits",
"(",
")",
";",
"}",
"FontMetrics",
"fm",
"=",
"c",
".",
"getFontMetrics",
"(",
"getDefaultDialogFont",
"(",
")",
")",
";",
"if",
"(",
"fm",
".",
"equals",
"(",
"cachedFontMetrics",
")",
")",
"{",
"return",
"cachedDialogBaseUnits",
";",
"}",
"DialogBaseUnits",
"dialogBaseUnits",
"=",
"computeDialogBaseUnits",
"(",
"fm",
")",
";",
"cachedFontMetrics",
"=",
"fm",
";",
"cachedDialogBaseUnits",
"=",
"dialogBaseUnits",
";",
"return",
"dialogBaseUnits",
";",
"}",
"/**\r\n * Computes and returns the horizontal dialog base units.\r\n * Honors the font, font size and resolution.<p>\r\n *\r\n * Implementation Note: 14dluY map to 22 pixel for 8pt Tahoma on 96 dpi.\r\n * I could not yet manage to compute the Microsoft compliant font height.\r\n * Therefore this method adds a correction value that seems to work\r\n * well with the vast majority of desktops.<p>\r\n *\r\n * TODO: Revise the computation of vertical base units as soon as\r\n * there are more information about the original computation\r\n * in Microsoft environments.\r\n *\r\n * @param metrics the FontMetrics used to measure the dialog font\r\n * @return the horizontal and vertical dialog base units\r\n */",
"private",
"DialogBaseUnits",
"computeDialogBaseUnits",
"(",
"FontMetrics",
"metrics",
")",
"{",
"double",
"averageCharWidth",
"=",
"computeAverageCharWidth",
"(",
"metrics",
",",
"averageCharWidthTestString",
")",
";",
"int",
"ascent",
"=",
"metrics",
".",
"getAscent",
"(",
")",
";",
"double",
"height",
"=",
"ascent",
">",
"14",
"?",
"ascent",
":",
"ascent",
"+",
"(",
"15",
"-",
"ascent",
")",
"/",
"3",
";",
"DialogBaseUnits",
"dialogBaseUnits",
"=",
"new",
"DialogBaseUnits",
"(",
"averageCharWidth",
",",
"height",
")",
";",
"if",
"(",
"LOGGER",
".",
"isLoggable",
"(",
"Level",
".",
"CONFIG",
")",
")",
"{",
"LOGGER",
".",
"config",
"(",
"\"",
"Computed dialog base units ",
"\"",
"+",
"dialogBaseUnits",
"+",
"\"",
" for: ",
"\"",
"+",
"metrics",
".",
"getFont",
"(",
")",
")",
";",
"}",
"return",
"dialogBaseUnits",
";",
"}",
"/**\r\n * Computes the global dialog base units. The current implementation\r\n * assumes a fixed 8pt font and on 96 or 120 dpi. A better implementation\r\n * should ask for the main dialog font and should honor the current\r\n * screen resolution.<p>\r\n *\r\n * Should be re-computed if the l&f, platform, or screen changes.\r\n *\r\n * @return a DialogBaseUnits object used globally if no container is available\r\n */",
"private",
"DialogBaseUnits",
"computeGlobalDialogBaseUnits",
"(",
")",
"{",
"LOGGER",
".",
"config",
"(",
"\"",
"Computing global dialog base units...",
"\"",
")",
";",
"Font",
"dialogFont",
"=",
"getDefaultDialogFont",
"(",
")",
";",
"FontMetrics",
"metrics",
"=",
"createDefaultGlobalComponent",
"(",
")",
".",
"getFontMetrics",
"(",
"dialogFont",
")",
";",
"DialogBaseUnits",
"globalDialogBaseUnits",
"=",
"computeDialogBaseUnits",
"(",
"metrics",
")",
";",
"return",
"globalDialogBaseUnits",
";",
"}",
"/**\r\n * Lazily creates and returns a fallback for the dialog font\r\n * that is used to compute the dialog base units.\r\n * This fallback font is cached and will be reset if the L&F changes.\r\n *\r\n * @return the cached fallback font used to compute the dialog base units\r\n */",
"private",
"Font",
"getCachedDefaultDialogFont",
"(",
")",
"{",
"FormUtils",
".",
"ensureValidCache",
"(",
")",
";",
"if",
"(",
"cachedDefaultDialogFont",
"==",
"null",
")",
"{",
"cachedDefaultDialogFont",
"=",
"lookupDefaultDialogFont",
"(",
")",
";",
"}",
"return",
"cachedDefaultDialogFont",
";",
"}",
"/**\r\n * Looks up and returns the font used by buttons.\r\n * First, tries to request the button font from the UIManager;\r\n * if this fails a JButton is created and asked for its font.\r\n *\r\n * @return the font used for a standard button\r\n */",
"private",
"static",
"Font",
"lookupDefaultDialogFont",
"(",
")",
"{",
"Font",
"buttonFont",
"=",
"UIManager",
".",
"getFont",
"(",
"\"",
"Button.font",
"\"",
")",
";",
"return",
"buttonFont",
"!=",
"null",
"?",
"buttonFont",
":",
"new",
"JButton",
"(",
")",
".",
"getFont",
"(",
")",
";",
"}",
"/**\r\n * Creates and returns a component that is used to lookup the default\r\n * font metrics. The current implementation creates a {@code JPanel}.\r\n * Since this panel has no parent, it has no toolkit assigned. And so,\r\n * requesting the font metrics will end up using the default toolkit\r\n * and its deprecated method {@code ToolKit#getFontMetrics()}.<p>\r\n *\r\n * TODO: Consider publishing this method and providing a setter, so that\r\n * an API user can set a realized component that has a toolkit assigned.\r\n *\r\n * @return a component used to compute the default font metrics\r\n */",
"private",
"static",
"Component",
"createDefaultGlobalComponent",
"(",
")",
"{",
"return",
"new",
"JPanel",
"(",
"null",
")",
";",
"}",
"/**\r\n * Invalidates the caches. Resets the global dialog base units,\r\n * clears the Map from {@code FontMetrics} to dialog base units,\r\n * and resets the fallback for the default dialog font.\r\n * This is invoked after a change of the look&feel.\r\n */",
"void",
"clearCache",
"(",
")",
"{",
"cachedGlobalDialogBaseUnits",
"=",
"null",
";",
"cachedFontMetrics",
"=",
"null",
";",
"cachedDefaultDialogFont",
"=",
"null",
";",
"}",
"/**\r\n * Describes horizontal and vertical dialog base units.\r\n */",
"private",
"static",
"final",
"class",
"DialogBaseUnits",
"{",
"final",
"double",
"x",
";",
"final",
"double",
"y",
";",
"DialogBaseUnits",
"(",
"double",
"dialogBaseUnitsX",
",",
"double",
"dialogBaseUnitsY",
")",
"{",
"this",
".",
"x",
"=",
"dialogBaseUnitsX",
";",
"this",
".",
"y",
"=",
"dialogBaseUnitsY",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"DBU(x=",
"\"",
"+",
"x",
"+",
"\"",
"; y=",
"\"",
"+",
"y",
"+",
"\"",
")",
"\"",
";",
"}",
"}",
"}"
] | This is the default implementation of the {@link UnitConverter} interface. | [
"This",
"is",
"the",
"default",
"implementation",
"of",
"the",
"{",
"@link",
"UnitConverter",
"}",
"interface",
"."
] | [
"// Cached *****************************************************************\r",
"// Instance Creation and Access *******************************************\r",
"// Access to Bound Properties *********************************************\r",
"// Don't use the getter\r",
"// Implementing Abstract Superclass Behavior ******************************\r",
"// Compute and Cache Global and Components Dialog Base Units **************\r",
"// || (font = c.getFont()) == null) {\r",
"// logInfo(\"Missing font metrics: \" + c);\r",
"// Helper Code ************************************************************\r"
] | [
{
"param": "AbstractUnitConverter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractUnitConverter",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0713ab1b49a210bdb05d2da7e914a80cac010c1b | rosariopfernandes/systembuilderlib | src/com/jgoodies/forms/util/DefaultUnitConverter.java | [
"Apache-2.0"
] | Java | DialogBaseUnits | /**
* Describes horizontal and vertical dialog base units.
*/ | Describes horizontal and vertical dialog base units. | [
"Describes",
"horizontal",
"and",
"vertical",
"dialog",
"base",
"units",
"."
] | private static final class DialogBaseUnits {
final double x;
final double y;
DialogBaseUnits(double dialogBaseUnitsX, double dialogBaseUnitsY) {
this.x = dialogBaseUnitsX;
this.y = dialogBaseUnitsY;
}
@Override
public String toString() {
return "DBU(x=" + x + "; y=" + y + ")";
}
} | [
"private",
"static",
"final",
"class",
"DialogBaseUnits",
"{",
"final",
"double",
"x",
";",
"final",
"double",
"y",
";",
"DialogBaseUnits",
"(",
"double",
"dialogBaseUnitsX",
",",
"double",
"dialogBaseUnitsY",
")",
"{",
"this",
".",
"x",
"=",
"dialogBaseUnitsX",
";",
"this",
".",
"y",
"=",
"dialogBaseUnitsY",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"DBU(x=",
"\"",
"+",
"x",
"+",
"\"",
"; y=",
"\"",
"+",
"y",
"+",
"\"",
")",
"\"",
";",
"}",
"}"
] | Describes horizontal and vertical dialog base units. | [
"Describes",
"horizontal",
"and",
"vertical",
"dialog",
"base",
"units",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0715bcddac2ad69afbe0c246bf6769843fb1b599 | twoducks/ossindex | ossindex-report-assistant/src/main/java/ca/twoducks/vor/ossindex/report/ProjectConfig.java | [
"BSD-3-Clause"
] | Java | ProjectConfig | /** This class contains information about a project itself, including:
* o name
* o version - version information if available
* o project - URL of 'project' page
* o scm - URI of source code repository
* o home - URL of 'home' page
* o cpe code
* o project level license(s)
* o identified files (digest pointer)
* o comment for user-provided information
*
* @author Ken Duck
*
*/ |
@author Ken Duck | [
"@author",
"Ken",
"Duck"
] | public class ProjectConfig
{
private String name;
private String description;
private String version;
private String project;
private String scm;
private String home;
private Collection<String> cpes;
private List<String> licenses = new LinkedList<String>();
private List<String> files = new LinkedList<String>();
private String comment;
/**
* Constructor required for JSON deserialization
*/
public ProjectConfig()
{
}
/** Create a project with a specified SCM URI as the key
*
* @param scmUri
*/
public ProjectConfig(String scmUri, String version)
{
this.scm = scmUri;
this.version = version;
}
/** Get the project name.
*
* @return
*/
public String getName()
{
return name;
}
/**
*
* @param name
*/
public void setName(String name)
{
this.name = name;
}
/**
*
* @param description
*/
public void setDescription(String description)
{
this.description = description;
}
/** Get the project version.
*
* @return
*/
public String getVersion()
{
return version;
}
/** Set the project version
*
* @param version
*/
public void setVersion(String version)
{
this.version = version;
}
/** Get a URL that identifies the project.
*
* @return
* @throws MalformedURLException
*/
public URL getProjectUrl() throws MalformedURLException
{
if(project == null) return null;
return new URL(project);
}
/** Set the project URI
*
* @param project
*/
public void setProjectUri(String project)
{
this.project = project;
}
/** Get the SCM URI that can be used to retrieve the source or build artifact.
*
* @return
* @throws URISyntaxException
*/
public URI getScmUri() throws URISyntaxException
{
if(scm == null) return null;
return new URI(scm);
}
/** Get the homepage URL if it is different from the project URL.
*
* @return
* @throws MalformedURLException
*/
public URL getHomeUrl() throws MalformedURLException
{
if(home == null) return null;
return new URL(home);
}
/** Set the home URI
*
* @param home
*/
public void setHomeUri(String home)
{
this.home = home;
}
/** Get a list of all CPE matches against the project.
*
* @return
*/
public Collection<String> getCpes()
{
if(cpes != null)
{
Iterator<String> it = cpes.iterator();
while(it.hasNext())
{
String cpe = it.next();
if("cpe:/none".equals(cpe)) it.remove();
}
if(cpes.isEmpty()) cpes = null;
}
return cpes;
}
/** Add a new CPE
*
* @param cpe
*/
public void addCpe(String cpe)
{
if(cpe != null)
{
if(cpes == null) cpes = new LinkedList<String>();
cpes.add(cpe);
}
}
/** Get a list of all licenses identified for the project itself.
*
* @return
*/
public Collection<String> getLicenses()
{
return licenses;
}
/** Add a new project license
*
* @param license
*/
public void addLicense(String license)
{
if(license != null)
{
licenses.add(license);
}
}
/** Get a list of all file digests that were matched against the project.
*
* @return
*/
public Collection<String> getFiles()
{
return files;
}
/** Add a file to the project. Files are identified by their digest. We don't
* store the entire file config here to avoid duplication.
*
* @param fileConfig
*/
public void addFile(FileConfig fileConfig)
{
files.add(fileConfig.getDigest());
}
/**
*
* @return
*/
public String getComment()
{
return comment;
}
/** Set the project comment
*
* @param comment
*/
public void setComment(String comment)
{
this.comment = comment;
}
/** Export CSV configuration information.
*
* @param csvOut
* @param lookup File lookup information
* @throws IOException
*/
public void exportCsv(CSVPrinter csvOut, Map<String, FileConfig> lookup) throws IOException
{
if(files.isEmpty())
{
//String[] header = {"Path", "State", "Project Name", "Project URI", "Version", "CPEs", "Project Licenses", "File License", "Project Description", "Digest", "Comment"};
List<Object> row = new ArrayList<Object>();
row.add(null);
row.add("Dependency");
row.add(name);
List<String> urls = new LinkedList<String>();
if(home != null) urls.add(home);
if(project != null) urls.add(project);
if(scm != null)
{
if(project == null || !scm.toString().startsWith(project.toString()))
{
urls.add(scm);
}
}
row.add(urls);
row.add(version);
row.add(getCpes());
row.add(licenses);
row.add(null);
row.add(description);
row.add(null);
row.add(getComment());
csvOut.printRecord(row);
}
else
{
for(String digest: files)
{
if(lookup.containsKey(digest))
{
FileConfig file = lookup.get(digest);
List<Object> row = new ArrayList<Object>();
String path = file.getPath();
if(path != null && !path.isEmpty())
{
row.add(path);
}
else
{
row.add(file.getName());
}
row.add(file.getState());
row.add(name);
List<String> urls = new LinkedList<String>();
if(scm != null) urls.add(scm);
else urls.add("");
// Only report the project if it is different from the SCM
boolean doProject = true;
if(project != null)
{
if(scm != null)
{
// Remove trailing slashes to simplify comparison
while(project.endsWith("/")) project = project.substring(0, project.length() - 1);
while(scm.endsWith("/")) scm = scm.substring(0, scm.length() - 1);
if(project.equals(scm)) doProject = false;
}
}
else
{
doProject = false;
}
if(doProject) urls.add(project);
else urls.add("");
if(home != null) urls.add(home);
else urls.add("");
row.add(urls);
row.add(version);
row.add(getCpes());
row.add(licenses);
row.add(file.getLicense());
row.add(description);
row.add(digest);
row.add(file.getComment());
csvOut.printRecord(row);
}
else
{
// This happens if we exclude some files from the output
// System.err.println("Unmatched digest found in project: " + digest);
}
}
}
}
} | [
"public",
"class",
"ProjectConfig",
"{",
"private",
"String",
"name",
";",
"private",
"String",
"description",
";",
"private",
"String",
"version",
";",
"private",
"String",
"project",
";",
"private",
"String",
"scm",
";",
"private",
"String",
"home",
";",
"private",
"Collection",
"<",
"String",
">",
"cpes",
";",
"private",
"List",
"<",
"String",
">",
"licenses",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"private",
"List",
"<",
"String",
">",
"files",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"private",
"String",
"comment",
";",
"/**\n\t * Constructor required for JSON deserialization\n\t */",
"public",
"ProjectConfig",
"(",
")",
"{",
"}",
"/** Create a project with a specified SCM URI as the key\n\t * \n\t * @param scmUri\n\t */",
"public",
"ProjectConfig",
"(",
"String",
"scmUri",
",",
"String",
"version",
")",
"{",
"this",
".",
"scm",
"=",
"scmUri",
";",
"this",
".",
"version",
"=",
"version",
";",
"}",
"/** Get the project name.\n\t * \n\t * @return\n\t */",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"/**\n\t * \n\t * @param name\n\t */",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"/**\n\t * \n\t * @param description\n\t */",
"public",
"void",
"setDescription",
"(",
"String",
"description",
")",
"{",
"this",
".",
"description",
"=",
"description",
";",
"}",
"/** Get the project version.\n\t * \n\t * @return\n\t */",
"public",
"String",
"getVersion",
"(",
")",
"{",
"return",
"version",
";",
"}",
"/** Set the project version\n\t * \n\t * @param version\n\t */",
"public",
"void",
"setVersion",
"(",
"String",
"version",
")",
"{",
"this",
".",
"version",
"=",
"version",
";",
"}",
"/** Get a URL that identifies the project.\n\t * \n\t * @return\n\t * @throws MalformedURLException\n\t */",
"public",
"URL",
"getProjectUrl",
"(",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"project",
"==",
"null",
")",
"return",
"null",
";",
"return",
"new",
"URL",
"(",
"project",
")",
";",
"}",
"/** Set the project URI\n\t * \n\t * @param project\n\t */",
"public",
"void",
"setProjectUri",
"(",
"String",
"project",
")",
"{",
"this",
".",
"project",
"=",
"project",
";",
"}",
"/** Get the SCM URI that can be used to retrieve the source or build artifact.\n\t * \n\t * @return\n\t * @throws URISyntaxException\n\t */",
"public",
"URI",
"getScmUri",
"(",
")",
"throws",
"URISyntaxException",
"{",
"if",
"(",
"scm",
"==",
"null",
")",
"return",
"null",
";",
"return",
"new",
"URI",
"(",
"scm",
")",
";",
"}",
"/** Get the homepage URL if it is different from the project URL.\n\t * \n\t * @return\n\t * @throws MalformedURLException\n\t */",
"public",
"URL",
"getHomeUrl",
"(",
")",
"throws",
"MalformedURLException",
"{",
"if",
"(",
"home",
"==",
"null",
")",
"return",
"null",
";",
"return",
"new",
"URL",
"(",
"home",
")",
";",
"}",
"/** Set the home URI\n\t * \n\t * @param home\n\t */",
"public",
"void",
"setHomeUri",
"(",
"String",
"home",
")",
"{",
"this",
".",
"home",
"=",
"home",
";",
"}",
"/** Get a list of all CPE matches against the project.\n\t * \n\t * @return\n\t */",
"public",
"Collection",
"<",
"String",
">",
"getCpes",
"(",
")",
"{",
"if",
"(",
"cpes",
"!=",
"null",
")",
"{",
"Iterator",
"<",
"String",
">",
"it",
"=",
"cpes",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"String",
"cpe",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"\"",
"cpe:/none",
"\"",
".",
"equals",
"(",
"cpe",
")",
")",
"it",
".",
"remove",
"(",
")",
";",
"}",
"if",
"(",
"cpes",
".",
"isEmpty",
"(",
")",
")",
"cpes",
"=",
"null",
";",
"}",
"return",
"cpes",
";",
"}",
"/** Add a new CPE\n\t * \n\t * @param cpe\n\t */",
"public",
"void",
"addCpe",
"(",
"String",
"cpe",
")",
"{",
"if",
"(",
"cpe",
"!=",
"null",
")",
"{",
"if",
"(",
"cpes",
"==",
"null",
")",
"cpes",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"cpes",
".",
"add",
"(",
"cpe",
")",
";",
"}",
"}",
"/** Get a list of all licenses identified for the project itself.\n\t * \n\t * @return\n\t */",
"public",
"Collection",
"<",
"String",
">",
"getLicenses",
"(",
")",
"{",
"return",
"licenses",
";",
"}",
"/** Add a new project license\n\t * \n\t * @param license\n\t */",
"public",
"void",
"addLicense",
"(",
"String",
"license",
")",
"{",
"if",
"(",
"license",
"!=",
"null",
")",
"{",
"licenses",
".",
"add",
"(",
"license",
")",
";",
"}",
"}",
"/** Get a list of all file digests that were matched against the project.\n\t * \n\t * @return\n\t */",
"public",
"Collection",
"<",
"String",
">",
"getFiles",
"(",
")",
"{",
"return",
"files",
";",
"}",
"/** Add a file to the project. Files are identified by their digest. We don't\n\t * store the entire file config here to avoid duplication.\n\t * \n\t * @param fileConfig\n\t */",
"public",
"void",
"addFile",
"(",
"FileConfig",
"fileConfig",
")",
"{",
"files",
".",
"add",
"(",
"fileConfig",
".",
"getDigest",
"(",
")",
")",
";",
"}",
"/**\n\t * \n\t * @return\n\t */",
"public",
"String",
"getComment",
"(",
")",
"{",
"return",
"comment",
";",
"}",
"/** Set the project comment\n\t * \n\t * @param comment\n\t */",
"public",
"void",
"setComment",
"(",
"String",
"comment",
")",
"{",
"this",
".",
"comment",
"=",
"comment",
";",
"}",
"/** Export CSV configuration information.\n\t * \n\t * @param csvOut\n\t * @param lookup File lookup information\n\t * @throws IOException \n\t */",
"public",
"void",
"exportCsv",
"(",
"CSVPrinter",
"csvOut",
",",
"Map",
"<",
"String",
",",
"FileConfig",
">",
"lookup",
")",
"throws",
"IOException",
"{",
"if",
"(",
"files",
".",
"isEmpty",
"(",
")",
")",
"{",
"List",
"<",
"Object",
">",
"row",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"row",
".",
"add",
"(",
"null",
")",
";",
"row",
".",
"add",
"(",
"\"",
"Dependency",
"\"",
")",
";",
"row",
".",
"add",
"(",
"name",
")",
";",
"List",
"<",
"String",
">",
"urls",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"home",
"!=",
"null",
")",
"urls",
".",
"add",
"(",
"home",
")",
";",
"if",
"(",
"project",
"!=",
"null",
")",
"urls",
".",
"add",
"(",
"project",
")",
";",
"if",
"(",
"scm",
"!=",
"null",
")",
"{",
"if",
"(",
"project",
"==",
"null",
"||",
"!",
"scm",
".",
"toString",
"(",
")",
".",
"startsWith",
"(",
"project",
".",
"toString",
"(",
")",
")",
")",
"{",
"urls",
".",
"add",
"(",
"scm",
")",
";",
"}",
"}",
"row",
".",
"add",
"(",
"urls",
")",
";",
"row",
".",
"add",
"(",
"version",
")",
";",
"row",
".",
"add",
"(",
"getCpes",
"(",
")",
")",
";",
"row",
".",
"add",
"(",
"licenses",
")",
";",
"row",
".",
"add",
"(",
"null",
")",
";",
"row",
".",
"add",
"(",
"description",
")",
";",
"row",
".",
"add",
"(",
"null",
")",
";",
"row",
".",
"add",
"(",
"getComment",
"(",
")",
")",
";",
"csvOut",
".",
"printRecord",
"(",
"row",
")",
";",
"}",
"else",
"{",
"for",
"(",
"String",
"digest",
":",
"files",
")",
"{",
"if",
"(",
"lookup",
".",
"containsKey",
"(",
"digest",
")",
")",
"{",
"FileConfig",
"file",
"=",
"lookup",
".",
"get",
"(",
"digest",
")",
";",
"List",
"<",
"Object",
">",
"row",
"=",
"new",
"ArrayList",
"<",
"Object",
">",
"(",
")",
";",
"String",
"path",
"=",
"file",
".",
"getPath",
"(",
")",
";",
"if",
"(",
"path",
"!=",
"null",
"&&",
"!",
"path",
".",
"isEmpty",
"(",
")",
")",
"{",
"row",
".",
"add",
"(",
"path",
")",
";",
"}",
"else",
"{",
"row",
".",
"add",
"(",
"file",
".",
"getName",
"(",
")",
")",
";",
"}",
"row",
".",
"add",
"(",
"file",
".",
"getState",
"(",
")",
")",
";",
"row",
".",
"add",
"(",
"name",
")",
";",
"List",
"<",
"String",
">",
"urls",
"=",
"new",
"LinkedList",
"<",
"String",
">",
"(",
")",
";",
"if",
"(",
"scm",
"!=",
"null",
")",
"urls",
".",
"add",
"(",
"scm",
")",
";",
"else",
"urls",
".",
"add",
"(",
"\"",
"\"",
")",
";",
"boolean",
"doProject",
"=",
"true",
";",
"if",
"(",
"project",
"!=",
"null",
")",
"{",
"if",
"(",
"scm",
"!=",
"null",
")",
"{",
"while",
"(",
"project",
".",
"endsWith",
"(",
"\"",
"/",
"\"",
")",
")",
"project",
"=",
"project",
".",
"substring",
"(",
"0",
",",
"project",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"while",
"(",
"scm",
".",
"endsWith",
"(",
"\"",
"/",
"\"",
")",
")",
"scm",
"=",
"scm",
".",
"substring",
"(",
"0",
",",
"scm",
".",
"length",
"(",
")",
"-",
"1",
")",
";",
"if",
"(",
"project",
".",
"equals",
"(",
"scm",
")",
")",
"doProject",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"doProject",
"=",
"false",
";",
"}",
"if",
"(",
"doProject",
")",
"urls",
".",
"add",
"(",
"project",
")",
";",
"else",
"urls",
".",
"add",
"(",
"\"",
"\"",
")",
";",
"if",
"(",
"home",
"!=",
"null",
")",
"urls",
".",
"add",
"(",
"home",
")",
";",
"else",
"urls",
".",
"add",
"(",
"\"",
"\"",
")",
";",
"row",
".",
"add",
"(",
"urls",
")",
";",
"row",
".",
"add",
"(",
"version",
")",
";",
"row",
".",
"add",
"(",
"getCpes",
"(",
")",
")",
";",
"row",
".",
"add",
"(",
"licenses",
")",
";",
"row",
".",
"add",
"(",
"file",
".",
"getLicense",
"(",
")",
")",
";",
"row",
".",
"add",
"(",
"description",
")",
";",
"row",
".",
"add",
"(",
"digest",
")",
";",
"row",
".",
"add",
"(",
"file",
".",
"getComment",
"(",
")",
")",
";",
"csvOut",
".",
"printRecord",
"(",
"row",
")",
";",
"}",
"else",
"{",
"}",
"}",
"}",
"}",
"}"
] | This class contains information about a project itself, including:
o name
o version - version information if available
o project - URL of 'project' page
o scm - URI of source code repository
o home - URL of 'home' page
o cpe code
o project level license(s)
o identified files (digest pointer)
o comment for user-provided information | [
"This",
"class",
"contains",
"information",
"about",
"a",
"project",
"itself",
"including",
":",
"o",
"name",
"o",
"version",
"-",
"version",
"information",
"if",
"available",
"o",
"project",
"-",
"URL",
"of",
"'",
"project",
"'",
"page",
"o",
"scm",
"-",
"URI",
"of",
"source",
"code",
"repository",
"o",
"home",
"-",
"URL",
"of",
"'",
"home",
"'",
"page",
"o",
"cpe",
"code",
"o",
"project",
"level",
"license",
"(",
"s",
")",
"o",
"identified",
"files",
"(",
"digest",
"pointer",
")",
"o",
"comment",
"for",
"user",
"-",
"provided",
"information"
] | [
"//String[] header = {\"Path\", \"State\", \"Project Name\", \"Project URI\", \"Version\", \"CPEs\", \"Project Licenses\", \"File License\", \"Project Description\", \"Digest\", \"Comment\"};",
"// Only report the project if it is different from the SCM",
"// Remove trailing slashes to simplify comparison",
"// This happens if we exclude some files from the output",
"// System.err.println(\"Unmatched digest found in project: \" + digest);"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
071ae16fb59995ba9216817c31ab49cf55c2fa0f | osglworks/java-tool | src/main/java/org/osgl/util/S.java | [
"Apache-2.0"
] | Java | Buffer | /**
* A `S.Buffer` is OSGL's implementation of JDK's
* {@link StringBuilder} with additional method to track
* the state of the instance, i.e. decide whether the
* constructor's buffer has been consumed (via {@link #toString()}
* method.
*
* **Note** when buffer is consumed (i.e. the `toString()`) method
* is called, the length of the buffer will be reset to `0`. However
* the internal char array will be leave as it is.
*
* **Note** this class is **NOT** thread safe
*
* **Note** Unlike {@link StringBuilder} when appending `null`
* it will **NOT** change the state of this object.
*/ | A `S.Buffer` is OSGL's implementation of JDK's
StringBuilder with additional method to track
the state of the instance, i.e. decide whether the
constructor's buffer has been consumed (via #toString()
method.
Note** when buffer is consumed `) method
is called, the length of the buffer will be reset to `0`. However
the internal char array will be leave as it is.
| [
"A",
"`",
"S",
".",
"Buffer",
"`",
"is",
"OSGL",
"'",
"s",
"implementation",
"of",
"JDK",
"'",
"s",
"StringBuilder",
"with",
"additional",
"method",
"to",
"track",
"the",
"state",
"of",
"the",
"instance",
"i",
".",
"e",
".",
"decide",
"whether",
"the",
"constructor",
"'",
"s",
"buffer",
"has",
"been",
"consumed",
"(",
"via",
"#toString",
"()",
"method",
".",
"Note",
"**",
"when",
"buffer",
"is",
"consumed",
"`",
")",
"method",
"is",
"called",
"the",
"length",
"of",
"the",
"buffer",
"will",
"be",
"reset",
"to",
"`",
"0",
"`",
".",
"However",
"the",
"internal",
"char",
"array",
"will",
"be",
"leave",
"as",
"it",
"is",
"."
] | public static class Buffer extends Writer implements Appendable, CharSequence {
/**
* The value is used for character storage.
*/
private char[] value;
/**
* The count is the number of characters used.
*/
private int count;
/**
* track if {@link #toString()} method is called
*/
private boolean consumed;
/**
* This no-arg constructor is necessary for serialization of subclasses.
*/
public Buffer() {
this(16);
}
/**
* Creates an Buffer of the specified capacity.
*/
public Buffer(int capacity) {
value = new char[capacity];
consumed = false;
}
public final boolean consumed() {
return consumed;
}
private String consume() {
return toString();
}
public Buffer reset() {
this.setLength(0);
this.consumed = false;
return this;
}
public Buffer clear() {
this.setLength(0);
return this;
}
/**
* Returns the length (character count).
*
* @return the length of the sequence of characters currently
* represented by this object
*/
@Override
public int length() {
return count;
}
/**
* Check if the buffer is empty. Calling this method is essentially equivalent to calling
*
* ```java
* 0 == length()
* ```
* @return `true` if this buffer is empty or `false` otherwise
*/
public boolean isEmpty() {
return 0 == count;
}
/**
* Returns the current capacity. The capacity is the amount of storage
* available for newly inserted characters, beyond which an allocation
* will occur.
*
* @return the current capacity
*/
public int capacity() {
return value.length;
}
/**
* Ensures that the capacity is at least equal to the specified minimum.
* If the current capacity is less than the argument, then a new internal
* array is allocated with greater capacity. The new capacity is the
* larger of:
* <ul>
* <li>The {@code minimumCapacity} argument.
* <li>Twice the old capacity, plus {@code 2}.
* </ul>
* If the {@code minimumCapacity} argument is nonpositive, this
* method takes no action and simply returns.
* Note that subsequent operations on this object can reduce the
* actual capacity below that requested here.
*
* @param minimumCapacity the minimum desired capacity.
*/
public void ensureCapacity(int minimumCapacity) {
if (minimumCapacity > 0)
ensureCapacityInternal(minimumCapacity);
}
/**
* Attempts to reduce storage used for the character sequence.
* If the buffer is larger than necessary to hold its current sequence of
* characters, then it may be resized to become more space efficient.
* Calling this method may, but is not required to, affect the value
* returned by a subsequent call to the {@link #capacity()} method.
*/
public void trimToSize() {
if (count < value.length) {
value = Arrays.copyOf(value, count);
}
}
/**
* Sets the length of the character sequence.
* The sequence is changed to a new character sequence
* whose length is specified by the argument. For every nonnegative
* index <i>k</i> less than {@code newLength}, the character at
* index <i>k</i> in the new character sequence is the same as the
* character at index <i>k</i> in the old sequence if <i>k</i> is less
* than the length of the old character sequence; otherwise, it is the
* null character {@code '\u005Cu0000'}.
* <p>
* In other words, if the {@code newLength} argument is less than
* the current length, the length is changed to the specified length.
* <p>
* If the {@code newLength} argument is greater than or equal
* to the current length, sufficient null characters
* ({@code '\u005Cu0000'}) are appended so that
* length becomes the {@code newLength} argument.
* <p>
* The {@code newLength} argument must be greater than or equal
* to {@code 0}.
*
* @param newLength the new length
* @throws IndexOutOfBoundsException if the
* {@code newLength} argument is negative.
*/
public void setLength(int newLength) {
if (newLength < 0)
throw new StringIndexOutOfBoundsException(newLength);
ensureCapacityInternal(newLength);
if (count < newLength) {
Arrays.fill(value, count, newLength, '\0');
}
count = newLength;
}
/**
* Returns the {@code char} value in this sequence at the specified index.
* The first {@code char} value is at index {@code 0}, the next at index
* {@code 1}, and so on, as in array indexing.
* <p>
* The index argument must be greater than or equal to
* {@code 0}, and less than the length of this sequence.
* <p>
* <p>If the {@code char} value specified by the index is a
* <a href="Character.html#unicode">surrogate</a>, the surrogate
* value is returned.
*
* @param index the index of the desired {@code char} value.
* @return the {@code char} value at the specified index.
* @throws IndexOutOfBoundsException if {@code index} is
* negative or greater than or equal to {@code length()}.
*/
@Override
public char charAt(int index) {
if ((index < 0) || (index >= count))
throw new StringIndexOutOfBoundsException(index);
return value[index];
}
/**
* Alias of {@link #charAt(int)}
*/
public char get(int index) {
return charAt(index);
}
/**
* Returns the character (Unicode code point) at the specified
* index. The index refers to {@code char} values
* (Unicode code units) and ranges from {@code 0} to
* {@link #length()}{@code - 1}.
* <p>
* <p> If the {@code char} value specified at the given index
* is in the high-surrogate range, the following index is less
* than the length of this sequence, and the
* {@code char} value at the following index is in the
* low-surrogate range, then the supplementary code point
* corresponding to this surrogate pair is returned. Otherwise,
* the {@code char} value at the given index is returned.
*
* @param index the index to the {@code char} values
* @return the code point value of the character at the
* {@code index}
* @throws IndexOutOfBoundsException if the {@code index}
* argument is negative or not less than the length of this
* sequence.
*/
public int codePointAt(int index) {
if ((index < 0) || (index >= count)) {
throw new StringIndexOutOfBoundsException(index);
}
return Character.codePointAt(value, index, count);
}
/**
* Returns the character (Unicode code point) before the specified
* index. The index refers to {@code char} values
* (Unicode code units) and ranges from {@code 1} to {@link
* #length()}.
* <p>
* <p> If the {@code char} value at {@code (index - 1)}
* is in the low-surrogate range, {@code (index - 2)} is not
* negative, and the {@code char} value at {@code (index -
* 2)} is in the high-surrogate range, then the
* supplementary code point value of the surrogate pair is
* returned. If the {@code char} value at {@code index -
* 1} is an unpaired low-surrogate or a high-surrogate, the
* surrogate value is returned.
*
* @param index the index following the code point that should be returned
* @return the Unicode code point value before the given index.
* @throws IndexOutOfBoundsException if the {@code index}
* argument is less than 1 or greater than the length
* of this sequence.
*/
public int codePointBefore(int index) {
int i = index - 1;
if ((i < 0) || (i >= count)) {
throw new StringIndexOutOfBoundsException(index);
}
return Character.codePointBefore(value, index, 0);
}
/**
* Returns the number of Unicode code points in the specified text
* range of this sequence. The text range begins at the specified
* {@code beginIndex} and extends to the {@code char} at
* index {@code endIndex - 1}. Thus the length (in
* {@code char}s) of the text range is
* {@code endIndex-beginIndex}. Unpaired surrogates within
* this sequence count as one code point each.
*
* @param beginIndex the index to the first {@code char} of
* the text range.
* @param endIndex the index after the last {@code char} of
* the text range.
* @return the number of Unicode code points in the specified text
* range
* @throws IndexOutOfBoundsException if the
* {@code beginIndex} is negative, or {@code endIndex}
* is larger than the length of this sequence, or
* {@code beginIndex} is larger than {@code endIndex}.
*/
public int codePointCount(int beginIndex, int endIndex) {
if (beginIndex < 0 || endIndex > count || beginIndex > endIndex) {
throw new IndexOutOfBoundsException();
}
return Character.codePointCount(value, beginIndex, endIndex - beginIndex);
}
/**
* Returns the index within this sequence that is offset from the
* given {@code index} by {@code codePointOffset} code
* points. Unpaired surrogates within the text range given by
* {@code index} and {@code codePointOffset} count as
* one code point each.
*
* @param index the index to be offset
* @param codePointOffset the offset in code points
* @return the index within this sequence
* @throws IndexOutOfBoundsException if {@code index}
* is negative or larger then the length of this sequence,
* or if {@code codePointOffset} is positive and the subsequence
* starting with {@code index} has fewer than
* {@code codePointOffset} code points,
* or if {@code codePointOffset} is negative and the subsequence
* before {@code index} has fewer than the absolute value of
* {@code codePointOffset} code points.
*/
public int offsetByCodePoints(int index, int codePointOffset) {
if (index < 0 || index > count) {
throw new IndexOutOfBoundsException();
}
return Character.offsetByCodePoints(value, 0, count,
index, codePointOffset);
}
/**
* Characters are copied from this sequence into the
* destination character array {@code dst}. The first character to
* be copied is at index {@code srcBegin}; the last character to
* be copied is at index {@code srcEnd-1}. The total number of
* characters to be copied is {@code srcEnd-srcBegin}. The
* characters are copied into the subarray of {@code dst} starting
* at index {@code dstBegin} and ending at index:
* <pre>{@code
* dstbegin + (srcEnd-srcBegin) - 1
* }</pre>
*
* @param srcBegin start copying at this offset.
* @param srcEnd stop copying at this offset.
* @param dst the array to copy the data into.
* @param dstBegin offset into {@code dst}.
* @throws IndexOutOfBoundsException if any of the following is true:
* <ul>
* <li>{@code srcBegin} is negative
* <li>{@code dstBegin} is negative
* <li>the {@code srcBegin} argument is greater than
* the {@code srcEnd} argument.
* <li>{@code srcEnd} is greater than
* {@code this.length()}.
* <li>{@code dstBegin+srcEnd-srcBegin} is greater than
* {@code dst.length}
* </ul>
*/
public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
if (srcBegin < 0)
throw new StringIndexOutOfBoundsException(srcBegin);
if ((srcEnd < 0) || (srcEnd > count))
throw new StringIndexOutOfBoundsException(srcEnd);
if (srcBegin > srcEnd)
throw new StringIndexOutOfBoundsException("srcBegin > srcEnd");
System.arraycopy(value, srcBegin, dst, dstBegin, srcEnd - srcBegin);
}
/**
* The character at the specified index is set to {@code ch}. This
* sequence is altered to represent a new character sequence that is
* identical to the old character sequence, except that it contains the
* character {@code ch} at position {@code index}.
* <p>
* The index argument must be greater than or equal to
* {@code 0}, and less than the length of this sequence.
*
* @param index the index of the character to modify.
* @param ch the new character.
* @throws IndexOutOfBoundsException if {@code index} is
* negative or greater than or equal to {@code length()}.
*/
public void setCharAt(int index, char ch) {
if ((index < 0) || (index >= count))
throw new StringIndexOutOfBoundsException(index);
value[index] = ch;
}
/**
* Alias of {@link #setCharAt(int, char)}
*/
public void set(int index, char ch) {
setCharAt(index, ch);
}
/**
* Appends the string representation of the {@code Object} argument.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(Object)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param obj an {@code Object}.
* @return a reference to this object.
*/
public Buffer append(Object obj) {
return append(string(obj));
}
/**
* Alias of {@link #append(Object)}
*/
public Buffer a(Object obj) {
return append(obj);
}
public Buffer prepend(Object obj) {
return prepend(String.valueOf(obj));
}
/**
* Alias of {@link #prepend(Object)}
*/
public Buffer p(Object obj) {
return prepend(obj);
}
/**
* Appends the specified string to this character sequence.
* <p>
* The characters of the {@code String} argument are appended, in
* order, increasing the length of this sequence by the length of the
* argument. If {@code str} is {@code null}, then nothing is appended
* <p>
* Let <i>n</i> be the length of this character sequence just prior to
* execution of the {@code append} method. Then the character at
* index <i>k</i> in the new character sequence is equal to the character
* at index <i>k</i> in the old character sequence, if <i>k</i> is less
* than <i>n</i>; otherwise, it is equal to the character at index
* <i>k-n</i> in the argument {@code str}.
*
* @param str a string.
* @return a reference to this object.
*/
public Buffer append(String str) {
if (str == null)
return appendNull();
int len = str.length();
ensureCapacityInternal(count + len);
str.getChars(0, len, value, count);
count += len;
return this;
}
/**
* Alias of {@link #append(String)}
*/
public Buffer a(String str) {
return append(str);
}
public Buffer prepend(String str) {
if (null == str)
return prependNull();
int len = str.length();
ensureCapacityInternal(count + len);
System.arraycopy(value, 0, value, len, count);
str.getChars(0, len, value, 0);
count += len;
return this;
}
/**
* Alias of {@link #prepend(String)}
*/
public Buffer p(String str) {
return prepend(str);
}
// Documentation in subclasses because of synchro difference
public Buffer append(StringBuffer sb) {
if (sb == null)
return appendNull();
int len = sb.length();
ensureCapacityInternal(count + len);
sb.getChars(0, len, value, count);
count += len;
return this;
}
/**
* Alias of {@link #append(StringBuffer)}
*/
public Buffer a(StringBuffer sb) {
return append(sb);
}
// Documentation in subclasses because of synchro difference
public Buffer prepend(StringBuffer sb) {
if (sb == null)
return appendNull();
int len = sb.length();
ensureCapacityInternal(count + len);
System.arraycopy(value, 0, value, len, count);
sb.getChars(0, len, value, 0);
count += len;
return this;
}
/**
* Alias of {@link #prepend(StringBuffer)}
*/
public Buffer p(StringBuffer sb) {
return prepend(sb);
}
// Documentation in subclasses because of synchro difference
public Buffer append(StringBuilder sb) {
if (sb == null)
return appendNull();
int len = sb.length();
ensureCapacityInternal(count + len);
sb.getChars(0, len, value, count);
count += len;
return this;
}
/**
* Alias of {@link #append(StringBuilder)}
*/
public Buffer a(StringBuilder sb) {
return append(sb);
}
// Documentation in subclasses because of synchro difference
public Buffer prepend(StringBuilder sb) {
if (sb == null)
return prependNull();
int len = sb.length();
ensureCapacityInternal(count + len);
System.arraycopy(value, 0, value, len, count);
sb.getChars(0, len, value, 0);
count += len;
return this;
}
/**
* Alias of {@link #prepend(StringBuilder)}
*/
public Buffer p(StringBuilder sb) {
return prepend(sb);
}
public Buffer append(Buffer asb) {
if (asb == null)
return appendNull();
int len = asb.length();
ensureCapacityInternal(count + len);
asb.getChars(0, len, value, count);
count += len;
return this;
}
/**
* Alias of {@link #append(Buffer)}
*/
public Buffer a(Buffer asb) {
return append(asb);
}
public Buffer prepend(Buffer asb) {
if (asb == null)
return prependNull();
int len = asb.length();
ensureCapacityInternal(count + len);
System.arraycopy(value, 0, value, len, count);
asb.getChars(0, len, value, 0);
count += len;
return this;
}
/**
* Alias of {@link #prepend(Buffer)}
*/
public Buffer p(Buffer asb) {
return prepend(asb);
}
// Documentation in subclasses because of synchro difference
@Override
public Buffer append(CharSequence s) {
if (s == null)
return appendNull();
if (s instanceof String)
return this.append((String) s);
if (s instanceof Buffer)
return this.append((Buffer) s);
return this.append(s, 0, s.length());
}
/**
* Alias of {@link #append(CharSequence)}
*/
public Buffer a(CharSequence s) {
return append(s);
}
public Buffer prepend(CharSequence s) {
if (s == null)
return prependNull();
if (s instanceof String)
return this.prepend((String) s);
if (s instanceof Buffer)
return this.prepend((Buffer) s);
if (s instanceof StringBuffer) {
return this.prepend((StringBuffer) s);
}
if (s instanceof StringBuilder) {
return this.prepend((StringBuilder) s);
}
return this.append(s, 0, s.length());
}
/**
* Alias of {@link #prepend(CharSequence)}
*/
public Buffer p(CharSequence s) {
return prepend(s);
}
private Buffer appendNull() {
return this;
}
private Buffer prependNull() {
return this;
}
/**
* Appends a subsequence of the specified {@code CharSequence} to this
* sequence.
* <p>
* Characters of the argument {@code s}, starting at
* index {@code start}, are appended, in order, to the contents of
* this sequence up to the (exclusive) index {@code end}. The length
* of this sequence is increased by the value of {@code end - start}.
* <p>
* Let <i>n</i> be the length of this character sequence just prior to
* execution of the {@code append} method. Then the character at
* index <i>k</i> in this character sequence becomes equal to the
* character at index <i>k</i> in this sequence, if <i>k</i> is less than
* <i>n</i>; otherwise, it is equal to the character at index
* <i>k+start-n</i> in the argument {@code s}.
* <p>
* If {@code s} is {@code null}, then this method appends
* characters as if the s parameter was a sequence containing the four
* characters {@code "null"}.
*
* @param s the sequence to append.
* @param start the starting index of the subsequence to be appended.
* @param end the end index of the subsequence to be appended.
* @return a reference to this object.
* @throws IndexOutOfBoundsException if
* {@code start} is negative, or
* {@code start} is greater than {@code end} or
* {@code end} is greater than {@code s.length()}
*/
@Override
public Buffer append(CharSequence s, int start, int end) {
if (s == null)
s = "null";
if ((start < 0) || (start > end) || (end > s.length()))
throw new IndexOutOfBoundsException(
"start " + start + ", end " + end + ", s.length() "
+ s.length());
int len = end - start;
ensureCapacityInternal(count + len);
for (int i = start, j = count; i < end; i++, j++)
value[j] = s.charAt(i);
count += len;
return this;
}
/**
* Appends the string representation of the {@code char} array
* argument to this sequence.
* <p>
* The characters of the array argument are appended, in order, to
* the contents of this sequence. The length of this sequence
* increases by the length of the argument.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(char[])},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param str the characters to be appended.
* @return a reference to this object.
*/
public Buffer append(char[] str) {
int len = str.length;
ensureCapacityInternal(count + len);
System.arraycopy(str, 0, value, count, len);
count += len;
return this;
}
/**
* Alias of {@link #append(char[])}
*/
public Buffer a(char[] str) {
return append(str);
}
public Buffer prepend(char[] str) {
int len = str.length;
ensureCapacityInternal(count + len);
System.arraycopy(value, 0, value, count, count);
System.arraycopy(str, 0, value, count, 0);
count += len;
return this;
}
/**
* Alias of {@link #prepend(char[])}
*/
public Buffer p(char[] str) {
return prepend(str);
}
/**
* Appends the string representation of a subarray of the
* {@code char} array argument to this sequence.
* <p>
* Characters of the {@code char} array {@code str}, starting at
* index {@code offset}, are appended, in order, to the contents
* of this sequence. The length of this sequence increases
* by the value of {@code len}.
* <p>
* The overall effect is exactly as if the arguments were converted
* to a string by the method {@link String#valueOf(char[], int, int)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param str the characters to be appended.
* @param offset the index of the first {@code char} to append.
* @param len the number of {@code char}s to append.
* @return a reference to this object.
* @throws IndexOutOfBoundsException if {@code offset < 0} or {@code len < 0}
* or {@code offset+len > str.length}
*/
public Buffer append(char str[], int offset, int len) {
if (len > 0) // let arraycopy report AIOOBE for len < 0
ensureCapacityInternal(count + len);
System.arraycopy(str, offset, value, count, len);
count += len;
return this;
}
/**
* Appends the string representation of the {@code boolean}
* argument to the sequence.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(boolean)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param b a {@code boolean}.
* @return a reference to this object.
*/
public Buffer prepend(boolean b) {
if (b) {
ensureCapacityInternal(count + 4);
System.arraycopy(value, 0, value, 4, count);
int cursor = 0;
value[cursor++] = 't';
value[cursor++] = 'r';
value[cursor++] = 'u';
value[cursor++] = 'e';
count += 4;
} else {
ensureCapacityInternal(count + 5);
System.arraycopy(value, 0, value, 5, count);
int cursor = 0;
value[cursor++] = 'f';
value[cursor++] = 'a';
value[cursor++] = 'l';
value[cursor++] = 's';
value[cursor++] = 'e';
count += 5;
}
return this;
}
/**
* Alias of {@link #prepend(boolean)}
*/
public Buffer p(boolean b) {
return prepend(b);
}
public Buffer append(boolean b) {
if (b) {
ensureCapacityInternal(count + 4);
value[count++] = 't';
value[count++] = 'r';
value[count++] = 'u';
value[count++] = 'e';
} else {
ensureCapacityInternal(count + 5);
value[count++] = 'f';
value[count++] = 'a';
value[count++] = 'l';
value[count++] = 's';
value[count++] = 'e';
}
return this;
}
/**
* Alias of {@link #append(boolean)}
*/
public Buffer a(boolean b) {
return append(b);
}
/**
* Appends the string representation of the {@code char}
* argument to this sequence.
* <p>
* The argument is appended to the contents of this sequence.
* The length of this sequence increases by {@code 1}.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(char)},
* and the character in that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param c a {@code char}.
* @return a reference to this object.
*/
@Override
public Buffer append(char c) {
ensureCapacityInternal(count + 1);
value[count++] = c;
return this;
}
/**
* alias of {@link #append(char)}
*/
public Buffer a(char c) {
return append(c);
}
public Buffer prepend(char c) {
ensureCapacityInternal(count + 1);
System.arraycopy(value, 0, value, 1, count);
value[0] = c;
return this;
}
/**
* alias of {@link #prepend(char)}
*/
public Buffer p(char c) {
return prepend(c);
}
/**
* Appends the string representation of the {@code int}
* argument to this sequence.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(int)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param i an {@code int}.
* @return a reference to this object.
*/
public Buffer append(int i) {
if (i == Integer.MIN_VALUE) {
append("-2147483648");
return this;
}
int appendedLength = (i < 0) ? stringSize(-i) + 1
: stringSize(i);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
getChars(i, spaceNeeded, value);
count = spaceNeeded;
return this;
}
/**
* alias of {@link #append(int)}
*/
public Buffer a(int i) {
return append(i);
}
public Buffer prepend(int i) {
if (i == Integer.MIN_VALUE) {
prepend("-2147483648");
return this;
}
int appendedLength = (i < 0) ? stringSize(-i) + 1
: stringSize(i);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
System.arraycopy(value, 0, value, appendedLength, count);
getChars(i, appendedLength, value);
count = spaceNeeded;
return this;
}
/**
* alias of {@link #prepend(int)}
*/
public Buffer p(int i) {
return prepend(i);
}
/**
* Appends the string representation of the {@code long}
* argument to this sequence.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(long)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param l a {@code long}.
* @return a reference to this object.
*/
public Buffer append(long l) {
if (l == Long.MIN_VALUE) {
append("-9223372036854775808");
return this;
}
int appendedLength = (l < 0) ? stringSize(-l) + 1
: stringSize(l);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
getChars(l, spaceNeeded, value);
count = spaceNeeded;
return this;
}
/**
* alias of {@link #append(long)}
*/
public Buffer a(long l) {
return append(l);
}
public Buffer prepend(long l) {
if (l == Long.MIN_VALUE) {
append("-9223372036854775808");
return this;
}
int appendedLength = (l < 0) ? stringSize(-l) + 1
: stringSize(l);
int spaceNeeded = count + appendedLength;
ensureCapacityInternal(spaceNeeded);
System.arraycopy(value, 0, value, appendedLength, count);
getChars(l, appendedLength, value);
count = spaceNeeded;
return this;
}
/**
* alias of {@link #prepend(long)}
*/
public Buffer p(long l) {
return prepend(l);
}
/**
* Appends the string representation of the {@code float}
* argument to this sequence.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(float)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param f a {@code float}.
* @return a reference to this object.
*/
public Buffer append(float f) {
return this.append(String.valueOf(f));
}
/**
* Alias of {@link #append(float)}
*/
public Buffer a(float f) {
return append(f);
}
public Buffer prepend(float f) {
return prepend(String.valueOf(f));
}
/**
* Alias of {@link #prepend(float)}
*/
public Buffer p(float f) {
return prepend(f);
}
/**
* Appends the string representation of the {@code double}
* argument to this sequence.
* <p>
* The overall effect is exactly as if the argument were converted
* to a string by the method {@link String#valueOf(double)},
* and the characters of that string were then
* {@link #append(String) appended} to this character sequence.
*
* @param d a {@code double}.
* @return a reference to this object.
*/
public Buffer append(double d) {
return this.append(String.valueOf(d));
}
/**
* Alias of {@link #append(double)}
*/
public Buffer a(double d) {
return append(d);
}
public Buffer prepend(double d) {
return this.prepend(String.valueOf(d));
}
/**
* Alias of {@link #prepend(double)}
*/
public Buffer p(double d) {
return prepend(d);
}
/**
* Removes the characters in a substring of this sequence.
* The substring begins at the specified {@code start} and extends to
* the character at index {@code end - 1} or to the end of the
* sequence if no such character exists. If
* {@code start} is equal to {@code end}, no changes are made.
*
* @param start The beginning index, inclusive.
* @param end The ending index, exclusive.
* @return This object.
* @throws StringIndexOutOfBoundsException if {@code start}
* is negative, greater than {@code length()}, or
* greater than {@code end}.
*/
public Buffer delete(int start, int end) {
if (start < 0)
throw new StringIndexOutOfBoundsException(start);
if (end > count)
end = count;
if (start > end)
throw new StringIndexOutOfBoundsException();
int len = end - start;
if (len > 0) {
System.arraycopy(value, start + len, value, start, count - end);
count -= len;
}
return this;
}
/**
* Appends the string representation of the {@code codePoint}
* argument to this sequence.
* <p>
* <p> The argument is appended to the contents of this sequence.
* The length of this sequence increases by
* {@link Character#charCount(int) Character.charCount(codePoint)}.
* <p>
* <p> The overall effect is exactly as if the argument were
* converted to a {@code char} array by the method
* {@link Character#toChars(int)} and the character in that array
* were then {@link #append(char[]) appended} to this character
* sequence.
*
* @param codePoint a Unicode code point
* @return a reference to this object.
* @throws IllegalArgumentException if the specified
* {@code codePoint} isn't a valid Unicode code point
*/
public Buffer appendCodePoint(int codePoint) {
final int count = this.count;
if (Character.isBmpCodePoint(codePoint)) {
ensureCapacityInternal(count + 1);
value[count] = (char) codePoint;
this.count = count + 1;
} else if (Character.isValidCodePoint(codePoint)) {
ensureCapacityInternal(count + 2);
toSurrogates(codePoint, value, count);
this.count = count + 2;
} else {
throw new IllegalArgumentException();
}
return this;
}
/**
* Removes the {@code char} at the specified position in this
* sequence. This sequence is shortened by one {@code char}.
* <p>
* <p>Note: If the character at the given index is a supplementary
* character, this method does not remove the entire character. If
* correct handling of supplementary characters is required,
* determine the number of {@code char}s to remove by calling
* {@code Character.charCount(thisSequence.codePointAt(index))},
* where {@code thisSequence} is this sequence.
*
* @param index Index of {@code char} to remove
* @return This object.
* @throws StringIndexOutOfBoundsException if the {@code index}
* is negative or greater than or equal to
* {@code length()}.
*/
public Buffer deleteCharAt(int index) {
if ((index < 0) || (index >= count))
throw new StringIndexOutOfBoundsException(index);
System.arraycopy(value, index + 1, value, index, count - index - 1);
count--;
return this;
}
/**
* Replaces the characters in a substring of this sequence
* with characters in the specified {@code String}. The substring
* begins at the specified {@code start} and extends to the character
* at index {@code end - 1} or to the end of the
* sequence if no such character exists. First the
* characters in the substring are removed and then the specified
* {@code String} is inserted at {@code start}. (This
* sequence will be lengthened to accommodate the
* specified String if necessary.)
*
* @param start The beginning index, inclusive.
* @param end The ending index, exclusive.
* @param str String that will replace previous contents.
* @return This object.
* @throws StringIndexOutOfBoundsException if {@code start}
* is negative, greater than {@code length()}, or
* greater than {@code end}.
*/
public Buffer replace(int start, int end, String str) {
if (start < 0)
throw new StringIndexOutOfBoundsException(start);
if (start > count)
throw new StringIndexOutOfBoundsException("start > length()");
if (start > end)
throw new StringIndexOutOfBoundsException("start > end");
if (end > count)
end = count;
int len = str.length();
int newCount = count + len - (end - start);
ensureCapacityInternal(newCount);
System.arraycopy(value, end, value, start + len, count - end);
char[] strVal = str.toCharArray();
System.arraycopy(value, 0, strVal, start, value.length);
count = newCount;
return this;
}
/**
* Returns a new {@code String} that contains a subsequence of
* characters currently contained in this character sequence. The
* substring begins at the specified index and extends to the end of
* this sequence.
*
* @param start The beginning index, inclusive.
* @return The new string.
* @throws StringIndexOutOfBoundsException if {@code start} is
* less than zero, or greater than the length of this object.
*/
public String substring(int start) {
return substring(start, count);
}
/**
* Returns a new character sequence that is a subsequence of this sequence.
* <p>
* <p> An invocation of this method of the form
* <p>
* <pre>{@code
* sb.subSequence(begin, end)}</pre>
* <p>
* behaves in exactly the same way as the invocation
* <p>
* <pre>{@code
* sb.substring(begin, end)}</pre>
* <p>
* This method is provided so that this class can
* implement the {@link CharSequence} interface.
*
* @param start the start index, inclusive.
* @param end the end index, exclusive.
* @return the specified subsequence.
* @throws IndexOutOfBoundsException if {@code start} or {@code end} are negative,
* if {@code end} is greater than {@code length()},
* or if {@code start} is greater than {@code end}
*/
@Override
public CharSequence subSequence(int start, int end) {
return substring(start, end);
}
/**
* Returns a new {@code String} that contains a subsequence of
* characters currently contained in this sequence. The
* substring begins at the specified {@code start} and
* extends to the character at index {@code end - 1}.
*
* @param start The beginning index, inclusive.
* @param end The ending index, exclusive.
* @return The new string.
* @throws StringIndexOutOfBoundsException if {@code start}
* or {@code end} are negative or greater than
* {@code length()}, or {@code start} is
* greater than {@code end}.
*/
public String substring(int start, int end) {
if (start < 0)
throw new StringIndexOutOfBoundsException(start);
if (end > count)
throw new StringIndexOutOfBoundsException(end);
if (start > end)
throw new StringIndexOutOfBoundsException(end - start);
return new String(value, start, end - start);
}
/**
* Inserts the string representation of a subarray of the {@code str}
* array argument into this sequence. The subarray begins at the
* specified {@code offset} and extends {@code len} {@code char}s.
* The characters of the subarray are inserted into this sequence at
* the position indicated by {@code index}. The length of this
* sequence increases by {@code len} {@code char}s.
*
* @param index position at which to insert subarray.
* @param str A {@code char} array.
* @param offset the index of the first {@code char} in subarray to
* be inserted.
* @param len the number of {@code char}s in the subarray to
* be inserted.
* @return This object
* @throws StringIndexOutOfBoundsException if {@code index}
* is negative or greater than {@code length()}, or
* {@code offset} or {@code len} are negative, or
* {@code (offset+len)} is greater than
* {@code str.length}.
*/
public Buffer insert(int index, char[] str, int offset,
int len) {
if ((index < 0) || (index > length()))
throw new StringIndexOutOfBoundsException(index);
if ((offset < 0) || (len < 0) || (offset > str.length - len))
throw new StringIndexOutOfBoundsException(
"offset " + offset + ", len " + len + ", str.length "
+ str.length);
ensureCapacityInternal(count + len);
System.arraycopy(value, index, value, index + len, count - index);
System.arraycopy(str, offset, value, index, len);
count += len;
return this;
}
/**
* Inserts the string representation of the {@code Object}
* argument into this character sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(Object)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param obj an {@code Object}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, Object obj) {
return insert(offset, String.valueOf(obj));
}
/**
* Inserts the string into this character sequence.
* <p>
* The characters of the {@code String} argument are inserted, in
* order, into this sequence at the indicated offset, moving up any
* characters originally above that position and increasing the length
* of this sequence by the length of the argument. If
* {@code str} is {@code null}, then the four characters
* {@code "null"} are inserted into this sequence.
* <p>
* The character at index <i>k</i> in the new character sequence is
* equal to:
* <ul>
* <li>the character at index <i>k</i> in the old character sequence, if
* <i>k</i> is less than {@code offset}
* <li>the character at index <i>k</i>{@code -offset} in the
* argument {@code str}, if <i>k</i> is not less than
* {@code offset} but is less than {@code offset+str.length()}
* <li>the character at index <i>k</i>{@code -str.length()} in the
* old character sequence, if <i>k</i> is not less than
* {@code offset+str.length()}
* </ul><p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param str a string.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, String str) {
if ((offset < 0) || (offset > length()))
throw new StringIndexOutOfBoundsException(offset);
if (str == null)
str = "null";
int len = str.length();
ensureCapacityInternal(count + len);
System.arraycopy(value, offset, value, offset + len, count - offset);
char[] strVal = str.toCharArray();
System.arraycopy(value, 0, strVal, offset, value.length);
count += len;
return this;
}
/**
* Inserts the string representation of the {@code char} array
* argument into this sequence.
* <p>
* The characters of the array argument are inserted into the
* contents of this sequence at the position indicated by
* {@code offset}. The length of this sequence increases by
* the length of the argument.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(char[])},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param str a character array.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, char[] str) {
if ((offset < 0) || (offset > length()))
throw new StringIndexOutOfBoundsException(offset);
int len = str.length;
ensureCapacityInternal(count + len);
System.arraycopy(value, offset, value, offset + len, count - offset);
System.arraycopy(str, 0, value, offset, len);
count += len;
return this;
}
/**
* Inserts the specified {@code CharSequence} into this sequence.
* <p>
* The characters of the {@code CharSequence} argument are inserted,
* in order, into this sequence at the indicated offset, moving up
* any characters originally above that position and increasing the length
* of this sequence by the length of the argument s.
* <p>
* The result of this method is exactly the same as if it were an
* invocation of this object's
* {@link #insert(int, CharSequence, int, int) insert}(dstOffset, s, 0, s.length())
* method.
* <p>
* <p>If {@code s} is {@code null}, then the four characters
* {@code "null"} are inserted into this sequence.
*
* @param dstOffset the offset.
* @param s the sequence to be inserted
* @return a reference to this object.
* @throws IndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int dstOffset, CharSequence s) {
if (s == null)
s = "null";
if (s instanceof String)
return this.insert(dstOffset, (String) s);
return this.insert(dstOffset, s, 0, s.length());
}
/**
* Inserts a subsequence of the specified {@code CharSequence} into
* this sequence.
* <p>
* The subsequence of the argument {@code s} specified by
* {@code start} and {@code end} are inserted,
* in order, into this sequence at the specified destination offset, moving
* up any characters originally above that position. The length of this
* sequence is increased by {@code end - start}.
* <p>
* The character at index <i>k</i> in this sequence becomes equal to:
* <ul>
* <li>the character at index <i>k</i> in this sequence, if
* <i>k</i> is less than {@code dstOffset}
* <li>the character at index <i>k</i>{@code +start-dstOffset} in
* the argument {@code s}, if <i>k</i> is greater than or equal to
* {@code dstOffset} but is less than {@code dstOffset+end-start}
* <li>the character at index <i>k</i>{@code -(end-start)} in this
* sequence, if <i>k</i> is greater than or equal to
* {@code dstOffset+end-start}
* </ul><p>
* The {@code dstOffset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
* <p>The start argument must be nonnegative, and not greater than
* {@code end}.
* <p>The end argument must be greater than or equal to
* {@code start}, and less than or equal to the length of s.
* <p>
* <p>If {@code s} is {@code null}, then this method inserts
* characters as if the s parameter was a sequence containing the four
* characters {@code "null"}.
*
* @param dstOffset the offset in this sequence.
* @param s the sequence to be inserted.
* @param start the starting index of the subsequence to be inserted.
* @param end the end index of the subsequence to be inserted.
* @return a reference to this object.
* @throws IndexOutOfBoundsException if {@code dstOffset}
* is negative or greater than {@code this.length()}, or
* {@code start} or {@code end} are negative, or
* {@code start} is greater than {@code end} or
* {@code end} is greater than {@code s.length()}
*/
public Buffer insert(int dstOffset, CharSequence s,
int start, int end) {
if (s == null)
s = "null";
if ((dstOffset < 0) || (dstOffset > this.length()))
throw new IndexOutOfBoundsException("dstOffset " + dstOffset);
if ((start < 0) || (end < 0) || (start > end) || (end > s.length()))
throw new IndexOutOfBoundsException(
"start " + start + ", end " + end + ", s.length() "
+ s.length());
int len = end - start;
ensureCapacityInternal(count + len);
System.arraycopy(value, dstOffset, value, dstOffset + len,
count - dstOffset);
for (int i = start; i < end; i++)
value[dstOffset++] = s.charAt(i);
count += len;
return this;
}
/**
* Inserts the string representation of the {@code boolean}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(boolean)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param b a {@code boolean}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, boolean b) {
return insert(offset, String.valueOf(b));
}
/**
* Inserts the string representation of the {@code char}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(char)},
* and the character in that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param c a {@code char}.
* @return a reference to this object.
* @throws IndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, char c) {
ensureCapacityInternal(count + 1);
System.arraycopy(value, offset, value, offset + 1, count - offset);
value[offset] = c;
count += 1;
return this;
}
/**
* Inserts the string representation of the second {@code int}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(int)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param i an {@code int}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, int i) {
return insert(offset, String.valueOf(i));
}
/**
* Inserts the string representation of the {@code long}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(long)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param l a {@code long}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, long l) {
return insert(offset, String.valueOf(l));
}
/**
* Inserts the string representation of the {@code float}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(float)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param f a {@code float}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, float f) {
return insert(offset, String.valueOf(f));
}
/**
* Inserts the string representation of the {@code double}
* argument into this sequence.
* <p>
* The overall effect is exactly as if the second argument were
* converted to a string by the method {@link String#valueOf(double)},
* and the characters of that string were then
* {@link #insert(int, String) inserted} into this character
* sequence at the indicated offset.
* <p>
* The {@code offset} argument must be greater than or equal to
* {@code 0}, and less than or equal to the {@linkplain #length() length}
* of this sequence.
*
* @param offset the offset.
* @param d a {@code double}.
* @return a reference to this object.
* @throws StringIndexOutOfBoundsException if the offset is invalid.
*/
public Buffer insert(int offset, double d) {
return insert(offset, String.valueOf(d));
}
@Override
public void write(char[] cbuf, int off, int len) {
append(cbuf, off, len);
}
/**
* Write a character `c` to this buf.
*
* Special note, this method is **NOT** the same with
* {@link #append(int)}, which will append String representation
* of passed in int, while this method, instead,
* treats the int as a character
*
* @param c
* the character `c`
*/
@Override
public void write(int c) {
append((char) c);
}
@Override
public void write(char[] cbuf) {
write(cbuf, 0, cbuf.length);
}
@Override
public void write(String str) {
write(str, 0, str.length());
}
@Override
public void write(String str, int off, int len) {
append(str, off, off + len);
}
@Override
public void flush() {
}
@Override
public void close() {
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring. The integer returned is the smallest value
* <i>k</i> such that:
* <pre>{@code
* this.toString().startsWith(str, <i>k</i>)
* }</pre>
* is {@code true}.
*
* @param str any string.
* @return if the string argument occurs as a substring within this
* object, then the index of the first character of the first
* such substring is returned; if it does not occur as a
* substring, {@code -1} is returned.
*/
public int indexOf(String str) {
return indexOf(str, 0);
}
/**
* Returns the index within this string of the first occurrence of the
* specified substring, starting at the specified index. The integer
* returned is the smallest value {@code k} for which:
* <pre>{@code
* k >= Math.min(fromIndex, this.length()) &&
* this.toString().startsWith(str, k)
* }</pre>
* If no such value of <i>k</i> exists, then -1 is returned.
*
* @param str the substring for which to search.
* @param fromIndex the index from which to start the search.
* @return the index within this string of the first occurrence of the
* specified substring, starting at the specified index.
*/
public int indexOf(String str, int fromIndex) {
char[] buf = str.toCharArray();
return S.indexOf(this.value, 0, count, buf, 0, buf.length, fromIndex);
}
/**
* Returns the index within this string of the rightmost occurrence
* of the specified substring. The rightmost empty string "" is
* considered to occur at the index value {@code this.length()}.
* The returned index is the largest value <i>k</i> such that
* <pre>{@code
* this.toString().startsWith(str, k)
* }</pre>
* is true.
*
* @param str the substring to search for.
* @return if the string argument occurs one or more times as a substring
* within this object, then the index of the first character of
* the last such substring is returned. If it does not occur as
* a substring, {@code -1} is returned.
*/
public int lastIndexOf(String str) {
return lastIndexOf(str, count);
}
/**
* Returns the index within this string of the last occurrence of the
* specified substring. The integer returned is the largest value <i>k</i>
* such that:
* <pre>{@code
* k <= Math.min(fromIndex, this.length()) &&
* this.toString().startsWith(str, k)
* }</pre>
* If no such value of <i>k</i> exists, then -1 is returned.
*
* @param str the substring to search for.
* @param fromIndex the index to start the search from.
* @return the index within this sequence of the last occurrence of the
* specified substring.
*/
public int lastIndexOf(String str, int fromIndex) {
char[] buf = str.toCharArray();
return S.lastIndexOf(value, 0, count, buf, 0, buf.length, fromIndex);
}
/**
* Causes this character sequence to be replaced by the reverse of
* the sequence. If there are any surrogate pairs included in the
* sequence, these are treated as single characters for the
* reverse operation. Thus, the order of the high-low surrogates
* is never reversed.
* <p>
* Let <i>n</i> be the character length of this character sequence
* (not the length in {@code char} values) just prior to
* execution of the {@code reverse} method. Then the
* character at index <i>k</i> in the new character sequence is
* equal to the character at index <i>n-k-1</i> in the old
* character sequence.
* <p>
* <p>Note that the reverse operation may result in producing
* surrogate pairs that were unpaired low-surrogates and
* high-surrogates before the operation. For example, reversing
* "\u005CuDC00\u005CuD800" produces "\u005CuD800\u005CuDC00" which is
* a valid surrogate pair.
*
* @return a reference to this object.
*/
public Buffer reverse() {
boolean hasSurrogates = false;
int n = count - 1;
for (int j = (n - 1) >> 1; j >= 0; j--) {
int k = n - j;
char cj = value[j];
char ck = value[k];
value[j] = ck;
value[k] = cj;
if (Character.isSurrogate(cj) ||
Character.isSurrogate(ck)) {
hasSurrogates = true;
}
}
if (hasSurrogates) {
reverseAllValidSurrogatePairs();
}
return this;
}
/**
* The maximum size of array to allocate (unless necessary).
* Some VMs reserve some header words in an array.
* Attempts to allocate larger arrays may result in
* OutOfMemoryError: Requested array size exceeds VM limit
*/
private static final int MAX_ARRAY_SIZE = Integer.MAX_VALUE - 8;
/**
* For positive values of {@code minimumCapacity}, this method
* behaves like {@code ensureCapacity}, however it is never
* synchronized.
* If {@code minimumCapacity} is non positive due to numeric
* overflow, this method throws {@code OutOfMemoryError}.
*/
private void ensureCapacityInternal(int minimumCapacity) {
// overflow-conscious code
if (minimumCapacity - value.length > 0) {
value = Arrays.copyOf(value,
newCapacity(minimumCapacity));
}
}
/**
* Returns a capacity at least as large as the given minimum capacity.
* Returns the current capacity increased by the same amount + 2 if
* that suffices.
* Will not return a capacity greater than {@code MAX_ARRAY_SIZE}
* unless the given minimum capacity is greater than that.
*
* @param minCapacity the desired minimum capacity
* @throws OutOfMemoryError if minCapacity is less than zero or
* greater than Integer.MAX_VALUE
*/
private int newCapacity(int minCapacity) {
// overflow-conscious code
int newCapacity = (value.length << 1) + 2;
if (newCapacity - minCapacity < 0) {
newCapacity = minCapacity;
}
return (newCapacity <= 0 || MAX_ARRAY_SIZE - newCapacity < 0)
? hugeCapacity(minCapacity)
: newCapacity;
}
private int hugeCapacity(int minCapacity) {
if (Integer.MAX_VALUE - minCapacity < 0) { // overflow
throw new OutOfMemoryError();
}
return (minCapacity > MAX_ARRAY_SIZE)
? minCapacity : MAX_ARRAY_SIZE;
}
/**
* Outlined helper method for reverse()
*/
private void reverseAllValidSurrogatePairs() {
for (int i = 0; i < count - 1; i++) {
char c2 = value[i];
if (Character.isLowSurrogate(c2)) {
char c1 = value[i + 1];
if (Character.isHighSurrogate(c1)) {
value[i++] = c1;
value[i] = c2;
}
}
}
}
/**
* Returns a string representing the data in this sequence.
* A new {@code String} object is allocated and initialized to
* contain the character sequence currently represented by this
* object. This {@code String} is then returned. Subsequent
* changes to this sequence do not affect the contents of the
* {@code String}.
* <p>
* After this method is called, the buffer of this Buffer
* instance will be reset to 0, meaning this Buffer is
* consumed
*
* @return a string representation of this sequence of characters.
*/
@Override
public String toString() {
// Create a copy, don't share the array
String retval = new String(value, 0, count);
this.consumed = true;
return retval;
}
public String view() {
return new String(value, 0, count);
}
/**
* Needed by {@code String} for the contentEquals method.
*/
final char[] getValue() {
return value;
}
final static int[] sizeTable = {9, 99, 999, 9999, 99999, 999999, 9999999,
99999999, 999999999, Integer.MAX_VALUE};
// Requires positive x
static int stringSize(int x) {
for (int i = 0; ; i++)
if (x <= sizeTable[i])
return i + 1;
}
final static char[] DigitTens = {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0',
'1', '1', '1', '1', '1', '1', '1', '1', '1', '1',
'2', '2', '2', '2', '2', '2', '2', '2', '2', '2',
'3', '3', '3', '3', '3', '3', '3', '3', '3', '3',
'4', '4', '4', '4', '4', '4', '4', '4', '4', '4',
'5', '5', '5', '5', '5', '5', '5', '5', '5', '5',
'6', '6', '6', '6', '6', '6', '6', '6', '6', '6',
'7', '7', '7', '7', '7', '7', '7', '7', '7', '7',
'8', '8', '8', '8', '8', '8', '8', '8', '8', '8',
'9', '9', '9', '9', '9', '9', '9', '9', '9', '9',
};
final static char[] DigitOnes = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
};
/**
* All possible chars for representing a number as a String
*/
final static char[] digits = {
'0', '1', '2', '3', '4', '5',
'6', '7', '8', '9', 'a', 'b',
'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't',
'u', 'v', 'w', 'x', 'y', 'z'
};
/**
* Places characters representing the integer i into the
* character array buf. The characters are placed into
* the buffer backwards starting with the least significant
* digit at the specified index (exclusive), and working
* backwards from there.
* <p>
* Will fail if i == Integer.MIN_VALUE
*/
static void getChars(int i, int index, char[] buf) {
int q, r;
int charPos = index;
char sign = 0;
if (i < 0) {
sign = '-';
i = -i;
}
// Generate two digits per iteration
while (i >= 65536) {
q = i / 100;
// really: r = i - (q * 100);
r = i - ((q << 6) + (q << 5) + (q << 2));
i = q;
buf[--charPos] = DigitOnes[r];
buf[--charPos] = DigitTens[r];
}
// Fall thru to fast mode for smaller numbers
// assert(i <= 65536, i);
for (; ; ) {
q = (i * 52429) >>> (16 + 3);
r = i - ((q << 3) + (q << 1)); // r = i-(q*10) ...
buf[--charPos] = digits[r];
i = q;
if (i == 0) break;
}
if (sign != 0) {
buf[--charPos] = sign;
}
}
// Requires positive x
static int stringSize(long x) {
long p = 10;
for (int i = 1; i < 19; i++) {
if (x < p)
return i;
p = 10 * p;
}
return 19;
}
/**
* Places characters representing the integer i into the
* character array buf. The characters are placed into
* the buffer backwards starting with the least significant
* digit at the specified index (exclusive), and working
* backwards from there.
* <p>
* Will fail if i == Long.MIN_VALUE
*/
static void getChars(long i, int index, char[] buf) {
long q;
int r;
int charPos = index;
char sign = 0;
if (i < 0) {
sign = '-';
i = -i;
}
// Get 2 digits/iteration using longs until quotient fits into an int
while (i > Integer.MAX_VALUE) {
q = i / 100;
// really: r = i - (q * 100);
r = (int) (i - ((q << 6) + (q << 5) + (q << 2)));
i = q;
buf[--charPos] = DigitOnes[r];
buf[--charPos] = DigitTens[r];
}
// Get 2 digits/iteration using ints
int q2;
int i2 = (int) i;
while (i2 >= 65536) {
q2 = i2 / 100;
// really: r = i2 - (q * 100);
r = i2 - ((q2 << 6) + (q2 << 5) + (q2 << 2));
i2 = q2;
buf[--charPos] = DigitOnes[r];
buf[--charPos] = DigitTens[r];
}
// Fall thru to fast mode for smaller numbers
// assert(i2 <= 65536, i2);
for (; ; ) {
q2 = (i2 * 52429) >>> (16 + 3);
r = i2 - ((q2 << 3) + (q2 << 1)); // r = i2-(q2*10) ...
buf[--charPos] = digits[r];
i2 = q2;
if (i2 == 0) break;
}
if (sign != 0) {
buf[--charPos] = sign;
}
}
static void toSurrogates(int codePoint, char[] dst, int index) {
// We write elements "backwards" to guarantee all-or-nothing
dst[index + 1] = lowSurrogate(codePoint);
dst[index] = highSurrogate(codePoint);
}
} | [
"public",
"static",
"class",
"Buffer",
"extends",
"Writer",
"implements",
"Appendable",
",",
"CharSequence",
"{",
"/**\n * The value is used for character storage.\n */",
"private",
"char",
"[",
"]",
"value",
";",
"/**\n * The count is the number of characters used.\n */",
"private",
"int",
"count",
";",
"/**\n * track if {@link #toString()} method is called\n */",
"private",
"boolean",
"consumed",
";",
"/**\n * This no-arg constructor is necessary for serialization of subclasses.\n */",
"public",
"Buffer",
"(",
")",
"{",
"this",
"(",
"16",
")",
";",
"}",
"/**\n * Creates an Buffer of the specified capacity.\n */",
"public",
"Buffer",
"(",
"int",
"capacity",
")",
"{",
"value",
"=",
"new",
"char",
"[",
"capacity",
"]",
";",
"consumed",
"=",
"false",
";",
"}",
"public",
"final",
"boolean",
"consumed",
"(",
")",
"{",
"return",
"consumed",
";",
"}",
"private",
"String",
"consume",
"(",
")",
"{",
"return",
"toString",
"(",
")",
";",
"}",
"public",
"Buffer",
"reset",
"(",
")",
"{",
"this",
".",
"setLength",
"(",
"0",
")",
";",
"this",
".",
"consumed",
"=",
"false",
";",
"return",
"this",
";",
"}",
"public",
"Buffer",
"clear",
"(",
")",
"{",
"this",
".",
"setLength",
"(",
"0",
")",
";",
"return",
"this",
";",
"}",
"/**\n * Returns the length (character count).\n *\n * @return the length of the sequence of characters currently\n * represented by this object\n */",
"@",
"Override",
"public",
"int",
"length",
"(",
")",
"{",
"return",
"count",
";",
"}",
"/**\n * Check if the buffer is empty. Calling this method is essentially equivalent to calling\n *\n * ```java\n * 0 == length()\n * ```\n * @return `true` if this buffer is empty or `false` otherwise\n */",
"public",
"boolean",
"isEmpty",
"(",
")",
"{",
"return",
"0",
"==",
"count",
";",
"}",
"/**\n * Returns the current capacity. The capacity is the amount of storage\n * available for newly inserted characters, beyond which an allocation\n * will occur.\n *\n * @return the current capacity\n */",
"public",
"int",
"capacity",
"(",
")",
"{",
"return",
"value",
".",
"length",
";",
"}",
"/**\n * Ensures that the capacity is at least equal to the specified minimum.\n * If the current capacity is less than the argument, then a new internal\n * array is allocated with greater capacity. The new capacity is the\n * larger of:\n * <ul>\n * <li>The {@code minimumCapacity} argument.\n * <li>Twice the old capacity, plus {@code 2}.\n * </ul>\n * If the {@code minimumCapacity} argument is nonpositive, this\n * method takes no action and simply returns.\n * Note that subsequent operations on this object can reduce the\n * actual capacity below that requested here.\n *\n * @param minimumCapacity the minimum desired capacity.\n */",
"public",
"void",
"ensureCapacity",
"(",
"int",
"minimumCapacity",
")",
"{",
"if",
"(",
"minimumCapacity",
">",
"0",
")",
"ensureCapacityInternal",
"(",
"minimumCapacity",
")",
";",
"}",
"/**\n * Attempts to reduce storage used for the character sequence.\n * If the buffer is larger than necessary to hold its current sequence of\n * characters, then it may be resized to become more space efficient.\n * Calling this method may, but is not required to, affect the value\n * returned by a subsequent call to the {@link #capacity()} method.\n */",
"public",
"void",
"trimToSize",
"(",
")",
"{",
"if",
"(",
"count",
"<",
"value",
".",
"length",
")",
"{",
"value",
"=",
"Arrays",
".",
"copyOf",
"(",
"value",
",",
"count",
")",
";",
"}",
"}",
"/**\n * Sets the length of the character sequence.\n * The sequence is changed to a new character sequence\n * whose length is specified by the argument. For every nonnegative\n * index <i>k</i> less than {@code newLength}, the character at\n * index <i>k</i> in the new character sequence is the same as the\n * character at index <i>k</i> in the old sequence if <i>k</i> is less\n * than the length of the old character sequence; otherwise, it is the\n * null character {@code '\\u005Cu0000'}.\n * <p>\n * In other words, if the {@code newLength} argument is less than\n * the current length, the length is changed to the specified length.\n * <p>\n * If the {@code newLength} argument is greater than or equal\n * to the current length, sufficient null characters\n * ({@code '\\u005Cu0000'}) are appended so that\n * length becomes the {@code newLength} argument.\n * <p>\n * The {@code newLength} argument must be greater than or equal\n * to {@code 0}.\n *\n * @param newLength the new length\n * @throws IndexOutOfBoundsException if the\n * {@code newLength} argument is negative.\n */",
"public",
"void",
"setLength",
"(",
"int",
"newLength",
")",
"{",
"if",
"(",
"newLength",
"<",
"0",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"newLength",
")",
";",
"ensureCapacityInternal",
"(",
"newLength",
")",
";",
"if",
"(",
"count",
"<",
"newLength",
")",
"{",
"Arrays",
".",
"fill",
"(",
"value",
",",
"count",
",",
"newLength",
",",
"'\\0'",
")",
";",
"}",
"count",
"=",
"newLength",
";",
"}",
"/**\n * Returns the {@code char} value in this sequence at the specified index.\n * The first {@code char} value is at index {@code 0}, the next at index\n * {@code 1}, and so on, as in array indexing.\n * <p>\n * The index argument must be greater than or equal to\n * {@code 0}, and less than the length of this sequence.\n * <p>\n * <p>If the {@code char} value specified by the index is a\n * <a href=\"Character.html#unicode\">surrogate</a>, the surrogate\n * value is returned.\n *\n * @param index the index of the desired {@code char} value.\n * @return the {@code char} value at the specified index.\n * @throws IndexOutOfBoundsException if {@code index} is\n * negative or greater than or equal to {@code length()}.\n */",
"@",
"Override",
"public",
"char",
"charAt",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">=",
"count",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"return",
"value",
"[",
"index",
"]",
";",
"}",
"/**\n * Alias of {@link #charAt(int)}\n */",
"public",
"char",
"get",
"(",
"int",
"index",
")",
"{",
"return",
"charAt",
"(",
"index",
")",
";",
"}",
"/**\n * Returns the character (Unicode code point) at the specified\n * index. The index refers to {@code char} values\n * (Unicode code units) and ranges from {@code 0} to\n * {@link #length()}{@code - 1}.\n * <p>\n * <p> If the {@code char} value specified at the given index\n * is in the high-surrogate range, the following index is less\n * than the length of this sequence, and the\n * {@code char} value at the following index is in the\n * low-surrogate range, then the supplementary code point\n * corresponding to this surrogate pair is returned. Otherwise,\n * the {@code char} value at the given index is returned.\n *\n * @param index the index to the {@code char} values\n * @return the code point value of the character at the\n * {@code index}\n * @throws IndexOutOfBoundsException if the {@code index}\n * argument is negative or not less than the length of this\n * sequence.\n */",
"public",
"int",
"codePointAt",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">=",
"count",
")",
")",
"{",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"}",
"return",
"Character",
".",
"codePointAt",
"(",
"value",
",",
"index",
",",
"count",
")",
";",
"}",
"/**\n * Returns the character (Unicode code point) before the specified\n * index. The index refers to {@code char} values\n * (Unicode code units) and ranges from {@code 1} to {@link\n * #length()}.\n * <p>\n * <p> If the {@code char} value at {@code (index - 1)}\n * is in the low-surrogate range, {@code (index - 2)} is not\n * negative, and the {@code char} value at {@code (index -\n * 2)} is in the high-surrogate range, then the\n * supplementary code point value of the surrogate pair is\n * returned. If the {@code char} value at {@code index -\n * 1} is an unpaired low-surrogate or a high-surrogate, the\n * surrogate value is returned.\n *\n * @param index the index following the code point that should be returned\n * @return the Unicode code point value before the given index.\n * @throws IndexOutOfBoundsException if the {@code index}\n * argument is less than 1 or greater than the length\n * of this sequence.\n */",
"public",
"int",
"codePointBefore",
"(",
"int",
"index",
")",
"{",
"int",
"i",
"=",
"index",
"-",
"1",
";",
"if",
"(",
"(",
"i",
"<",
"0",
")",
"||",
"(",
"i",
">=",
"count",
")",
")",
"{",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"}",
"return",
"Character",
".",
"codePointBefore",
"(",
"value",
",",
"index",
",",
"0",
")",
";",
"}",
"/**\n * Returns the number of Unicode code points in the specified text\n * range of this sequence. The text range begins at the specified\n * {@code beginIndex} and extends to the {@code char} at\n * index {@code endIndex - 1}. Thus the length (in\n * {@code char}s) of the text range is\n * {@code endIndex-beginIndex}. Unpaired surrogates within\n * this sequence count as one code point each.\n *\n * @param beginIndex the index to the first {@code char} of\n * the text range.\n * @param endIndex the index after the last {@code char} of\n * the text range.\n * @return the number of Unicode code points in the specified text\n * range\n * @throws IndexOutOfBoundsException if the\n * {@code beginIndex} is negative, or {@code endIndex}\n * is larger than the length of this sequence, or\n * {@code beginIndex} is larger than {@code endIndex}.\n */",
"public",
"int",
"codePointCount",
"(",
"int",
"beginIndex",
",",
"int",
"endIndex",
")",
"{",
"if",
"(",
"beginIndex",
"<",
"0",
"||",
"endIndex",
">",
"count",
"||",
"beginIndex",
">",
"endIndex",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"return",
"Character",
".",
"codePointCount",
"(",
"value",
",",
"beginIndex",
",",
"endIndex",
"-",
"beginIndex",
")",
";",
"}",
"/**\n * Returns the index within this sequence that is offset from the\n * given {@code index} by {@code codePointOffset} code\n * points. Unpaired surrogates within the text range given by\n * {@code index} and {@code codePointOffset} count as\n * one code point each.\n *\n * @param index the index to be offset\n * @param codePointOffset the offset in code points\n * @return the index within this sequence\n * @throws IndexOutOfBoundsException if {@code index}\n * is negative or larger then the length of this sequence,\n * or if {@code codePointOffset} is positive and the subsequence\n * starting with {@code index} has fewer than\n * {@code codePointOffset} code points,\n * or if {@code codePointOffset} is negative and the subsequence\n * before {@code index} has fewer than the absolute value of\n * {@code codePointOffset} code points.\n */",
"public",
"int",
"offsetByCodePoints",
"(",
"int",
"index",
",",
"int",
"codePointOffset",
")",
"{",
"if",
"(",
"index",
"<",
"0",
"||",
"index",
">",
"count",
")",
"{",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
")",
";",
"}",
"return",
"Character",
".",
"offsetByCodePoints",
"(",
"value",
",",
"0",
",",
"count",
",",
"index",
",",
"codePointOffset",
")",
";",
"}",
"/**\n * Characters are copied from this sequence into the\n * destination character array {@code dst}. The first character to\n * be copied is at index {@code srcBegin}; the last character to\n * be copied is at index {@code srcEnd-1}. The total number of\n * characters to be copied is {@code srcEnd-srcBegin}. The\n * characters are copied into the subarray of {@code dst} starting\n * at index {@code dstBegin} and ending at index:\n * <pre>{@code\n * dstbegin + (srcEnd-srcBegin) - 1\n * }</pre>\n *\n * @param srcBegin start copying at this offset.\n * @param srcEnd stop copying at this offset.\n * @param dst the array to copy the data into.\n * @param dstBegin offset into {@code dst}.\n * @throws IndexOutOfBoundsException if any of the following is true:\n * <ul>\n * <li>{@code srcBegin} is negative\n * <li>{@code dstBegin} is negative\n * <li>the {@code srcBegin} argument is greater than\n * the {@code srcEnd} argument.\n * <li>{@code srcEnd} is greater than\n * {@code this.length()}.\n * <li>{@code dstBegin+srcEnd-srcBegin} is greater than\n * {@code dst.length}\n * </ul>\n */",
"public",
"void",
"getChars",
"(",
"int",
"srcBegin",
",",
"int",
"srcEnd",
",",
"char",
"[",
"]",
"dst",
",",
"int",
"dstBegin",
")",
"{",
"if",
"(",
"srcBegin",
"<",
"0",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"srcBegin",
")",
";",
"if",
"(",
"(",
"srcEnd",
"<",
"0",
")",
"||",
"(",
"srcEnd",
">",
"count",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"srcEnd",
")",
";",
"if",
"(",
"srcBegin",
">",
"srcEnd",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"\"",
"srcBegin > srcEnd",
"\"",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"srcBegin",
",",
"dst",
",",
"dstBegin",
",",
"srcEnd",
"-",
"srcBegin",
")",
";",
"}",
"/**\n * The character at the specified index is set to {@code ch}. This\n * sequence is altered to represent a new character sequence that is\n * identical to the old character sequence, except that it contains the\n * character {@code ch} at position {@code index}.\n * <p>\n * The index argument must be greater than or equal to\n * {@code 0}, and less than the length of this sequence.\n *\n * @param index the index of the character to modify.\n * @param ch the new character.\n * @throws IndexOutOfBoundsException if {@code index} is\n * negative or greater than or equal to {@code length()}.\n */",
"public",
"void",
"setCharAt",
"(",
"int",
"index",
",",
"char",
"ch",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">=",
"count",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"value",
"[",
"index",
"]",
"=",
"ch",
";",
"}",
"/**\n * Alias of {@link #setCharAt(int, char)}\n */",
"public",
"void",
"set",
"(",
"int",
"index",
",",
"char",
"ch",
")",
"{",
"setCharAt",
"(",
"index",
",",
"ch",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code Object} argument.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(Object)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param obj an {@code Object}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"Object",
"obj",
")",
"{",
"return",
"append",
"(",
"string",
"(",
"obj",
")",
")",
";",
"}",
"/**\n * Alias of {@link #append(Object)}\n */",
"public",
"Buffer",
"a",
"(",
"Object",
"obj",
")",
"{",
"return",
"append",
"(",
"obj",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"Object",
"obj",
")",
"{",
"return",
"prepend",
"(",
"String",
".",
"valueOf",
"(",
"obj",
")",
")",
";",
"}",
"/**\n * Alias of {@link #prepend(Object)}\n */",
"public",
"Buffer",
"p",
"(",
"Object",
"obj",
")",
"{",
"return",
"prepend",
"(",
"obj",
")",
";",
"}",
"/**\n * Appends the specified string to this character sequence.\n * <p>\n * The characters of the {@code String} argument are appended, in\n * order, increasing the length of this sequence by the length of the\n * argument. If {@code str} is {@code null}, then nothing is appended\n * <p>\n * Let <i>n</i> be the length of this character sequence just prior to\n * execution of the {@code append} method. Then the character at\n * index <i>k</i> in the new character sequence is equal to the character\n * at index <i>k</i> in the old character sequence, if <i>k</i> is less\n * than <i>n</i>; otherwise, it is equal to the character at index\n * <i>k-n</i> in the argument {@code str}.\n *\n * @param str a string.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"str",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"int",
"len",
"=",
"str",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"str",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"count",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(String)}\n */",
"public",
"Buffer",
"a",
"(",
"String",
"str",
")",
"{",
"return",
"append",
"(",
"str",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"String",
"str",
")",
"{",
"if",
"(",
"null",
"==",
"str",
")",
"return",
"prependNull",
"(",
")",
";",
"int",
"len",
"=",
"str",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"len",
",",
"count",
")",
";",
"str",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"0",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(String)}\n */",
"public",
"Buffer",
"p",
"(",
"String",
"str",
")",
"{",
"return",
"prepend",
"(",
"str",
")",
";",
"}",
"public",
"Buffer",
"append",
"(",
"StringBuffer",
"sb",
")",
"{",
"if",
"(",
"sb",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"int",
"len",
"=",
"sb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"sb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"count",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(StringBuffer)}\n */",
"public",
"Buffer",
"a",
"(",
"StringBuffer",
"sb",
")",
"{",
"return",
"append",
"(",
"sb",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"StringBuffer",
"sb",
")",
"{",
"if",
"(",
"sb",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"int",
"len",
"=",
"sb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"len",
",",
"count",
")",
";",
"sb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"0",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(StringBuffer)}\n */",
"public",
"Buffer",
"p",
"(",
"StringBuffer",
"sb",
")",
"{",
"return",
"prepend",
"(",
"sb",
")",
";",
"}",
"public",
"Buffer",
"append",
"(",
"StringBuilder",
"sb",
")",
"{",
"if",
"(",
"sb",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"int",
"len",
"=",
"sb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"sb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"count",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(StringBuilder)}\n */",
"public",
"Buffer",
"a",
"(",
"StringBuilder",
"sb",
")",
"{",
"return",
"append",
"(",
"sb",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"StringBuilder",
"sb",
")",
"{",
"if",
"(",
"sb",
"==",
"null",
")",
"return",
"prependNull",
"(",
")",
";",
"int",
"len",
"=",
"sb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"len",
",",
"count",
")",
";",
"sb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"0",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(StringBuilder)}\n */",
"public",
"Buffer",
"p",
"(",
"StringBuilder",
"sb",
")",
"{",
"return",
"prepend",
"(",
"sb",
")",
";",
"}",
"public",
"Buffer",
"append",
"(",
"Buffer",
"asb",
")",
"{",
"if",
"(",
"asb",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"int",
"len",
"=",
"asb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"asb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"count",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(Buffer)}\n */",
"public",
"Buffer",
"a",
"(",
"Buffer",
"asb",
")",
"{",
"return",
"append",
"(",
"asb",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"Buffer",
"asb",
")",
"{",
"if",
"(",
"asb",
"==",
"null",
")",
"return",
"prependNull",
"(",
")",
";",
"int",
"len",
"=",
"asb",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"len",
",",
"count",
")",
";",
"asb",
".",
"getChars",
"(",
"0",
",",
"len",
",",
"value",
",",
"0",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(Buffer)}\n */",
"public",
"Buffer",
"p",
"(",
"Buffer",
"asb",
")",
"{",
"return",
"prepend",
"(",
"asb",
")",
";",
"}",
"@",
"Override",
"public",
"Buffer",
"append",
"(",
"CharSequence",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"return",
"appendNull",
"(",
")",
";",
"if",
"(",
"s",
"instanceof",
"String",
")",
"return",
"this",
".",
"append",
"(",
"(",
"String",
")",
"s",
")",
";",
"if",
"(",
"s",
"instanceof",
"Buffer",
")",
"return",
"this",
".",
"append",
"(",
"(",
"Buffer",
")",
"s",
")",
";",
"return",
"this",
".",
"append",
"(",
"s",
",",
"0",
",",
"s",
".",
"length",
"(",
")",
")",
";",
"}",
"/**\n * Alias of {@link #append(CharSequence)}\n */",
"public",
"Buffer",
"a",
"(",
"CharSequence",
"s",
")",
"{",
"return",
"append",
"(",
"s",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"CharSequence",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"return",
"prependNull",
"(",
")",
";",
"if",
"(",
"s",
"instanceof",
"String",
")",
"return",
"this",
".",
"prepend",
"(",
"(",
"String",
")",
"s",
")",
";",
"if",
"(",
"s",
"instanceof",
"Buffer",
")",
"return",
"this",
".",
"prepend",
"(",
"(",
"Buffer",
")",
"s",
")",
";",
"if",
"(",
"s",
"instanceof",
"StringBuffer",
")",
"{",
"return",
"this",
".",
"prepend",
"(",
"(",
"StringBuffer",
")",
"s",
")",
";",
"}",
"if",
"(",
"s",
"instanceof",
"StringBuilder",
")",
"{",
"return",
"this",
".",
"prepend",
"(",
"(",
"StringBuilder",
")",
"s",
")",
";",
"}",
"return",
"this",
".",
"append",
"(",
"s",
",",
"0",
",",
"s",
".",
"length",
"(",
")",
")",
";",
"}",
"/**\n * Alias of {@link #prepend(CharSequence)}\n */",
"public",
"Buffer",
"p",
"(",
"CharSequence",
"s",
")",
"{",
"return",
"prepend",
"(",
"s",
")",
";",
"}",
"private",
"Buffer",
"appendNull",
"(",
")",
"{",
"return",
"this",
";",
"}",
"private",
"Buffer",
"prependNull",
"(",
")",
"{",
"return",
"this",
";",
"}",
"/**\n * Appends a subsequence of the specified {@code CharSequence} to this\n * sequence.\n * <p>\n * Characters of the argument {@code s}, starting at\n * index {@code start}, are appended, in order, to the contents of\n * this sequence up to the (exclusive) index {@code end}. The length\n * of this sequence is increased by the value of {@code end - start}.\n * <p>\n * Let <i>n</i> be the length of this character sequence just prior to\n * execution of the {@code append} method. Then the character at\n * index <i>k</i> in this character sequence becomes equal to the\n * character at index <i>k</i> in this sequence, if <i>k</i> is less than\n * <i>n</i>; otherwise, it is equal to the character at index\n * <i>k+start-n</i> in the argument {@code s}.\n * <p>\n * If {@code s} is {@code null}, then this method appends\n * characters as if the s parameter was a sequence containing the four\n * characters {@code \"null\"}.\n *\n * @param s the sequence to append.\n * @param start the starting index of the subsequence to be appended.\n * @param end the end index of the subsequence to be appended.\n * @return a reference to this object.\n * @throws IndexOutOfBoundsException if\n * {@code start} is negative, or\n * {@code start} is greater than {@code end} or\n * {@code end} is greater than {@code s.length()}\n */",
"@",
"Override",
"public",
"Buffer",
"append",
"(",
"CharSequence",
"s",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"s",
"=",
"\"",
"null",
"\"",
";",
"if",
"(",
"(",
"start",
"<",
"0",
")",
"||",
"(",
"start",
">",
"end",
")",
"||",
"(",
"end",
">",
"s",
".",
"length",
"(",
")",
")",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"",
"start ",
"\"",
"+",
"start",
"+",
"\"",
", end ",
"\"",
"+",
"end",
"+",
"\"",
", s.length() ",
"\"",
"+",
"s",
".",
"length",
"(",
")",
")",
";",
"int",
"len",
"=",
"end",
"-",
"start",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"for",
"(",
"int",
"i",
"=",
"start",
",",
"j",
"=",
"count",
";",
"i",
"<",
"end",
";",
"i",
"++",
",",
"j",
"++",
")",
"value",
"[",
"j",
"]",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Appends the string representation of the {@code char} array\n * argument to this sequence.\n * <p>\n * The characters of the array argument are appended, in order, to\n * the contents of this sequence. The length of this sequence\n * increases by the length of the argument.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(char[])},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param str the characters to be appended.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"char",
"[",
"]",
"str",
")",
"{",
"int",
"len",
"=",
"str",
".",
"length",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"str",
",",
"0",
",",
"value",
",",
"count",
",",
"len",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(char[])}\n */",
"public",
"Buffer",
"a",
"(",
"char",
"[",
"]",
"str",
")",
"{",
"return",
"append",
"(",
"str",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"char",
"[",
"]",
"str",
")",
"{",
"int",
"len",
"=",
"str",
".",
"length",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"count",
",",
"count",
")",
";",
"System",
".",
"arraycopy",
"(",
"str",
",",
"0",
",",
"value",
",",
"count",
",",
"0",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(char[])}\n */",
"public",
"Buffer",
"p",
"(",
"char",
"[",
"]",
"str",
")",
"{",
"return",
"prepend",
"(",
"str",
")",
";",
"}",
"/**\n * Appends the string representation of a subarray of the\n * {@code char} array argument to this sequence.\n * <p>\n * Characters of the {@code char} array {@code str}, starting at\n * index {@code offset}, are appended, in order, to the contents\n * of this sequence. The length of this sequence increases\n * by the value of {@code len}.\n * <p>\n * The overall effect is exactly as if the arguments were converted\n * to a string by the method {@link String#valueOf(char[], int, int)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param str the characters to be appended.\n * @param offset the index of the first {@code char} to append.\n * @param len the number of {@code char}s to append.\n * @return a reference to this object.\n * @throws IndexOutOfBoundsException if {@code offset < 0} or {@code len < 0}\n * or {@code offset+len > str.length}\n */",
"public",
"Buffer",
"append",
"(",
"char",
"str",
"[",
"]",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"if",
"(",
"len",
">",
"0",
")",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"str",
",",
"offset",
",",
"value",
",",
"count",
",",
"len",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Appends the string representation of the {@code boolean}\n * argument to the sequence.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(boolean)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param b a {@code boolean}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"prepend",
"(",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"4",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"4",
",",
"count",
")",
";",
"int",
"cursor",
"=",
"0",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'t'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'r'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'u'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'e'",
";",
"count",
"+=",
"4",
";",
"}",
"else",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"5",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"5",
",",
"count",
")",
";",
"int",
"cursor",
"=",
"0",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'f'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'a'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'l'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'s'",
";",
"value",
"[",
"cursor",
"++",
"]",
"=",
"'e'",
";",
"count",
"+=",
"5",
";",
"}",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #prepend(boolean)}\n */",
"public",
"Buffer",
"p",
"(",
"boolean",
"b",
")",
"{",
"return",
"prepend",
"(",
"b",
")",
";",
"}",
"public",
"Buffer",
"append",
"(",
"boolean",
"b",
")",
"{",
"if",
"(",
"b",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"4",
")",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'t'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'r'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'u'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'e'",
";",
"}",
"else",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"5",
")",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'f'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'a'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'l'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'s'",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"'e'",
";",
"}",
"return",
"this",
";",
"}",
"/**\n * Alias of {@link #append(boolean)}\n */",
"public",
"Buffer",
"a",
"(",
"boolean",
"b",
")",
"{",
"return",
"append",
"(",
"b",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code char}\n * argument to this sequence.\n * <p>\n * The argument is appended to the contents of this sequence.\n * The length of this sequence increases by {@code 1}.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(char)},\n * and the character in that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param c a {@code char}.\n * @return a reference to this object.\n */",
"@",
"Override",
"public",
"Buffer",
"append",
"(",
"char",
"c",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"1",
")",
";",
"value",
"[",
"count",
"++",
"]",
"=",
"c",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #append(char)}\n */",
"public",
"Buffer",
"a",
"(",
"char",
"c",
")",
"{",
"return",
"append",
"(",
"c",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"char",
"c",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"1",
",",
"count",
")",
";",
"value",
"[",
"0",
"]",
"=",
"c",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #prepend(char)}\n */",
"public",
"Buffer",
"p",
"(",
"char",
"c",
")",
"{",
"return",
"prepend",
"(",
"c",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code int}\n * argument to this sequence.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(int)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param i an {@code int}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"int",
"i",
")",
"{",
"if",
"(",
"i",
"==",
"Integer",
".",
"MIN_VALUE",
")",
"{",
"append",
"(",
"\"",
"-2147483648",
"\"",
")",
";",
"return",
"this",
";",
"}",
"int",
"appendedLength",
"=",
"(",
"i",
"<",
"0",
")",
"?",
"stringSize",
"(",
"-",
"i",
")",
"+",
"1",
":",
"stringSize",
"(",
"i",
")",
";",
"int",
"spaceNeeded",
"=",
"count",
"+",
"appendedLength",
";",
"ensureCapacityInternal",
"(",
"spaceNeeded",
")",
";",
"getChars",
"(",
"i",
",",
"spaceNeeded",
",",
"value",
")",
";",
"count",
"=",
"spaceNeeded",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #append(int)}\n */",
"public",
"Buffer",
"a",
"(",
"int",
"i",
")",
"{",
"return",
"append",
"(",
"i",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"int",
"i",
")",
"{",
"if",
"(",
"i",
"==",
"Integer",
".",
"MIN_VALUE",
")",
"{",
"prepend",
"(",
"\"",
"-2147483648",
"\"",
")",
";",
"return",
"this",
";",
"}",
"int",
"appendedLength",
"=",
"(",
"i",
"<",
"0",
")",
"?",
"stringSize",
"(",
"-",
"i",
")",
"+",
"1",
":",
"stringSize",
"(",
"i",
")",
";",
"int",
"spaceNeeded",
"=",
"count",
"+",
"appendedLength",
";",
"ensureCapacityInternal",
"(",
"spaceNeeded",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"appendedLength",
",",
"count",
")",
";",
"getChars",
"(",
"i",
",",
"appendedLength",
",",
"value",
")",
";",
"count",
"=",
"spaceNeeded",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #prepend(int)}\n */",
"public",
"Buffer",
"p",
"(",
"int",
"i",
")",
"{",
"return",
"prepend",
"(",
"i",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code long}\n * argument to this sequence.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(long)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param l a {@code long}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"long",
"l",
")",
"{",
"if",
"(",
"l",
"==",
"Long",
".",
"MIN_VALUE",
")",
"{",
"append",
"(",
"\"",
"-9223372036854775808",
"\"",
")",
";",
"return",
"this",
";",
"}",
"int",
"appendedLength",
"=",
"(",
"l",
"<",
"0",
")",
"?",
"stringSize",
"(",
"-",
"l",
")",
"+",
"1",
":",
"stringSize",
"(",
"l",
")",
";",
"int",
"spaceNeeded",
"=",
"count",
"+",
"appendedLength",
";",
"ensureCapacityInternal",
"(",
"spaceNeeded",
")",
";",
"getChars",
"(",
"l",
",",
"spaceNeeded",
",",
"value",
")",
";",
"count",
"=",
"spaceNeeded",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #append(long)}\n */",
"public",
"Buffer",
"a",
"(",
"long",
"l",
")",
"{",
"return",
"append",
"(",
"l",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"long",
"l",
")",
"{",
"if",
"(",
"l",
"==",
"Long",
".",
"MIN_VALUE",
")",
"{",
"append",
"(",
"\"",
"-9223372036854775808",
"\"",
")",
";",
"return",
"this",
";",
"}",
"int",
"appendedLength",
"=",
"(",
"l",
"<",
"0",
")",
"?",
"stringSize",
"(",
"-",
"l",
")",
"+",
"1",
":",
"stringSize",
"(",
"l",
")",
";",
"int",
"spaceNeeded",
"=",
"count",
"+",
"appendedLength",
";",
"ensureCapacityInternal",
"(",
"spaceNeeded",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"value",
",",
"appendedLength",
",",
"count",
")",
";",
"getChars",
"(",
"l",
",",
"appendedLength",
",",
"value",
")",
";",
"count",
"=",
"spaceNeeded",
";",
"return",
"this",
";",
"}",
"/**\n * alias of {@link #prepend(long)}\n */",
"public",
"Buffer",
"p",
"(",
"long",
"l",
")",
"{",
"return",
"prepend",
"(",
"l",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code float}\n * argument to this sequence.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(float)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param f a {@code float}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"float",
"f",
")",
"{",
"return",
"this",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"f",
")",
")",
";",
"}",
"/**\n * Alias of {@link #append(float)}\n */",
"public",
"Buffer",
"a",
"(",
"float",
"f",
")",
"{",
"return",
"append",
"(",
"f",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"float",
"f",
")",
"{",
"return",
"prepend",
"(",
"String",
".",
"valueOf",
"(",
"f",
")",
")",
";",
"}",
"/**\n * Alias of {@link #prepend(float)}\n */",
"public",
"Buffer",
"p",
"(",
"float",
"f",
")",
"{",
"return",
"prepend",
"(",
"f",
")",
";",
"}",
"/**\n * Appends the string representation of the {@code double}\n * argument to this sequence.\n * <p>\n * The overall effect is exactly as if the argument were converted\n * to a string by the method {@link String#valueOf(double)},\n * and the characters of that string were then\n * {@link #append(String) appended} to this character sequence.\n *\n * @param d a {@code double}.\n * @return a reference to this object.\n */",
"public",
"Buffer",
"append",
"(",
"double",
"d",
")",
"{",
"return",
"this",
".",
"append",
"(",
"String",
".",
"valueOf",
"(",
"d",
")",
")",
";",
"}",
"/**\n * Alias of {@link #append(double)}\n */",
"public",
"Buffer",
"a",
"(",
"double",
"d",
")",
"{",
"return",
"append",
"(",
"d",
")",
";",
"}",
"public",
"Buffer",
"prepend",
"(",
"double",
"d",
")",
"{",
"return",
"this",
".",
"prepend",
"(",
"String",
".",
"valueOf",
"(",
"d",
")",
")",
";",
"}",
"/**\n * Alias of {@link #prepend(double)}\n */",
"public",
"Buffer",
"p",
"(",
"double",
"d",
")",
"{",
"return",
"prepend",
"(",
"d",
")",
";",
"}",
"/**\n * Removes the characters in a substring of this sequence.\n * The substring begins at the specified {@code start} and extends to\n * the character at index {@code end - 1} or to the end of the\n * sequence if no such character exists. If\n * {@code start} is equal to {@code end}, no changes are made.\n *\n * @param start The beginning index, inclusive.\n * @param end The ending index, exclusive.\n * @return This object.\n * @throws StringIndexOutOfBoundsException if {@code start}\n * is negative, greater than {@code length()}, or\n * greater than {@code end}.\n */",
"public",
"Buffer",
"delete",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"start",
")",
";",
"if",
"(",
"end",
">",
"count",
")",
"end",
"=",
"count",
";",
"if",
"(",
"start",
">",
"end",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
")",
";",
"int",
"len",
"=",
"end",
"-",
"start",
";",
"if",
"(",
"len",
">",
"0",
")",
"{",
"System",
".",
"arraycopy",
"(",
"value",
",",
"start",
"+",
"len",
",",
"value",
",",
"start",
",",
"count",
"-",
"end",
")",
";",
"count",
"-=",
"len",
";",
"}",
"return",
"this",
";",
"}",
"/**\n * Appends the string representation of the {@code codePoint}\n * argument to this sequence.\n * <p>\n * <p> The argument is appended to the contents of this sequence.\n * The length of this sequence increases by\n * {@link Character#charCount(int) Character.charCount(codePoint)}.\n * <p>\n * <p> The overall effect is exactly as if the argument were\n * converted to a {@code char} array by the method\n * {@link Character#toChars(int)} and the character in that array\n * were then {@link #append(char[]) appended} to this character\n * sequence.\n *\n * @param codePoint a Unicode code point\n * @return a reference to this object.\n * @throws IllegalArgumentException if the specified\n * {@code codePoint} isn't a valid Unicode code point\n */",
"public",
"Buffer",
"appendCodePoint",
"(",
"int",
"codePoint",
")",
"{",
"final",
"int",
"count",
"=",
"this",
".",
"count",
";",
"if",
"(",
"Character",
".",
"isBmpCodePoint",
"(",
"codePoint",
")",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"1",
")",
";",
"value",
"[",
"count",
"]",
"=",
"(",
"char",
")",
"codePoint",
";",
"this",
".",
"count",
"=",
"count",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"Character",
".",
"isValidCodePoint",
"(",
"codePoint",
")",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"2",
")",
";",
"toSurrogates",
"(",
"codePoint",
",",
"value",
",",
"count",
")",
";",
"this",
".",
"count",
"=",
"count",
"+",
"2",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
")",
";",
"}",
"return",
"this",
";",
"}",
"/**\n * Removes the {@code char} at the specified position in this\n * sequence. This sequence is shortened by one {@code char}.\n * <p>\n * <p>Note: If the character at the given index is a supplementary\n * character, this method does not remove the entire character. If\n * correct handling of supplementary characters is required,\n * determine the number of {@code char}s to remove by calling\n * {@code Character.charCount(thisSequence.codePointAt(index))},\n * where {@code thisSequence} is this sequence.\n *\n * @param index Index of {@code char} to remove\n * @return This object.\n * @throws StringIndexOutOfBoundsException if the {@code index}\n * is negative or greater than or equal to\n * {@code length()}.\n */",
"public",
"Buffer",
"deleteCharAt",
"(",
"int",
"index",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">=",
"count",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"index",
"+",
"1",
",",
"value",
",",
"index",
",",
"count",
"-",
"index",
"-",
"1",
")",
";",
"count",
"--",
";",
"return",
"this",
";",
"}",
"/**\n * Replaces the characters in a substring of this sequence\n * with characters in the specified {@code String}. The substring\n * begins at the specified {@code start} and extends to the character\n * at index {@code end - 1} or to the end of the\n * sequence if no such character exists. First the\n * characters in the substring are removed and then the specified\n * {@code String} is inserted at {@code start}. (This\n * sequence will be lengthened to accommodate the\n * specified String if necessary.)\n *\n * @param start The beginning index, inclusive.\n * @param end The ending index, exclusive.\n * @param str String that will replace previous contents.\n * @return This object.\n * @throws StringIndexOutOfBoundsException if {@code start}\n * is negative, greater than {@code length()}, or\n * greater than {@code end}.\n */",
"public",
"Buffer",
"replace",
"(",
"int",
"start",
",",
"int",
"end",
",",
"String",
"str",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"start",
")",
";",
"if",
"(",
"start",
">",
"count",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"\"",
"start > length()",
"\"",
")",
";",
"if",
"(",
"start",
">",
"end",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"\"",
"start > end",
"\"",
")",
";",
"if",
"(",
"end",
">",
"count",
")",
"end",
"=",
"count",
";",
"int",
"len",
"=",
"str",
".",
"length",
"(",
")",
";",
"int",
"newCount",
"=",
"count",
"+",
"len",
"-",
"(",
"end",
"-",
"start",
")",
";",
"ensureCapacityInternal",
"(",
"newCount",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"end",
",",
"value",
",",
"start",
"+",
"len",
",",
"count",
"-",
"end",
")",
";",
"char",
"[",
"]",
"strVal",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"strVal",
",",
"start",
",",
"value",
".",
"length",
")",
";",
"count",
"=",
"newCount",
";",
"return",
"this",
";",
"}",
"/**\n * Returns a new {@code String} that contains a subsequence of\n * characters currently contained in this character sequence. The\n * substring begins at the specified index and extends to the end of\n * this sequence.\n *\n * @param start The beginning index, inclusive.\n * @return The new string.\n * @throws StringIndexOutOfBoundsException if {@code start} is\n * less than zero, or greater than the length of this object.\n */",
"public",
"String",
"substring",
"(",
"int",
"start",
")",
"{",
"return",
"substring",
"(",
"start",
",",
"count",
")",
";",
"}",
"/**\n * Returns a new character sequence that is a subsequence of this sequence.\n * <p>\n * <p> An invocation of this method of the form\n * <p>\n * <pre>{@code\n * sb.subSequence(begin, end)}</pre>\n * <p>\n * behaves in exactly the same way as the invocation\n * <p>\n * <pre>{@code\n * sb.substring(begin, end)}</pre>\n * <p>\n * This method is provided so that this class can\n * implement the {@link CharSequence} interface.\n *\n * @param start the start index, inclusive.\n * @param end the end index, exclusive.\n * @return the specified subsequence.\n * @throws IndexOutOfBoundsException if {@code start} or {@code end} are negative,\n * if {@code end} is greater than {@code length()},\n * or if {@code start} is greater than {@code end}\n */",
"@",
"Override",
"public",
"CharSequence",
"subSequence",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"return",
"substring",
"(",
"start",
",",
"end",
")",
";",
"}",
"/**\n * Returns a new {@code String} that contains a subsequence of\n * characters currently contained in this sequence. The\n * substring begins at the specified {@code start} and\n * extends to the character at index {@code end - 1}.\n *\n * @param start The beginning index, inclusive.\n * @param end The ending index, exclusive.\n * @return The new string.\n * @throws StringIndexOutOfBoundsException if {@code start}\n * or {@code end} are negative or greater than\n * {@code length()}, or {@code start} is\n * greater than {@code end}.\n */",
"public",
"String",
"substring",
"(",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"start",
"<",
"0",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"start",
")",
";",
"if",
"(",
"end",
">",
"count",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"end",
")",
";",
"if",
"(",
"start",
">",
"end",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"end",
"-",
"start",
")",
";",
"return",
"new",
"String",
"(",
"value",
",",
"start",
",",
"end",
"-",
"start",
")",
";",
"}",
"/**\n * Inserts the string representation of a subarray of the {@code str}\n * array argument into this sequence. The subarray begins at the\n * specified {@code offset} and extends {@code len} {@code char}s.\n * The characters of the subarray are inserted into this sequence at\n * the position indicated by {@code index}. The length of this\n * sequence increases by {@code len} {@code char}s.\n *\n * @param index position at which to insert subarray.\n * @param str A {@code char} array.\n * @param offset the index of the first {@code char} in subarray to\n * be inserted.\n * @param len the number of {@code char}s in the subarray to\n * be inserted.\n * @return This object\n * @throws StringIndexOutOfBoundsException if {@code index}\n * is negative or greater than {@code length()}, or\n * {@code offset} or {@code len} are negative, or\n * {@code (offset+len)} is greater than\n * {@code str.length}.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"index",
",",
"char",
"[",
"]",
"str",
",",
"int",
"offset",
",",
"int",
"len",
")",
"{",
"if",
"(",
"(",
"index",
"<",
"0",
")",
"||",
"(",
"index",
">",
"length",
"(",
")",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"index",
")",
";",
"if",
"(",
"(",
"offset",
"<",
"0",
")",
"||",
"(",
"len",
"<",
"0",
")",
"||",
"(",
"offset",
">",
"str",
".",
"length",
"-",
"len",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"\"",
"offset ",
"\"",
"+",
"offset",
"+",
"\"",
", len ",
"\"",
"+",
"len",
"+",
"\"",
", str.length ",
"\"",
"+",
"str",
".",
"length",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"index",
",",
"value",
",",
"index",
"+",
"len",
",",
"count",
"-",
"index",
")",
";",
"System",
".",
"arraycopy",
"(",
"str",
",",
"offset",
",",
"value",
",",
"index",
",",
"len",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Inserts the string representation of the {@code Object}\n * argument into this character sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(Object)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param obj an {@code Object}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"Object",
"obj",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"obj",
")",
")",
";",
"}",
"/**\n * Inserts the string into this character sequence.\n * <p>\n * The characters of the {@code String} argument are inserted, in\n * order, into this sequence at the indicated offset, moving up any\n * characters originally above that position and increasing the length\n * of this sequence by the length of the argument. If\n * {@code str} is {@code null}, then the four characters\n * {@code \"null\"} are inserted into this sequence.\n * <p>\n * The character at index <i>k</i> in the new character sequence is\n * equal to:\n * <ul>\n * <li>the character at index <i>k</i> in the old character sequence, if\n * <i>k</i> is less than {@code offset}\n * <li>the character at index <i>k</i>{@code -offset} in the\n * argument {@code str}, if <i>k</i> is not less than\n * {@code offset} but is less than {@code offset+str.length()}\n * <li>the character at index <i>k</i>{@code -str.length()} in the\n * old character sequence, if <i>k</i> is not less than\n * {@code offset+str.length()}\n * </ul><p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param str a string.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"String",
"str",
")",
"{",
"if",
"(",
"(",
"offset",
"<",
"0",
")",
"||",
"(",
"offset",
">",
"length",
"(",
")",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"offset",
")",
";",
"if",
"(",
"str",
"==",
"null",
")",
"str",
"=",
"\"",
"null",
"\"",
";",
"int",
"len",
"=",
"str",
".",
"length",
"(",
")",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"offset",
",",
"value",
",",
"offset",
"+",
"len",
",",
"count",
"-",
"offset",
")",
";",
"char",
"[",
"]",
"strVal",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"0",
",",
"strVal",
",",
"offset",
",",
"value",
".",
"length",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Inserts the string representation of the {@code char} array\n * argument into this sequence.\n * <p>\n * The characters of the array argument are inserted into the\n * contents of this sequence at the position indicated by\n * {@code offset}. The length of this sequence increases by\n * the length of the argument.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(char[])},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param str a character array.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"char",
"[",
"]",
"str",
")",
"{",
"if",
"(",
"(",
"offset",
"<",
"0",
")",
"||",
"(",
"offset",
">",
"length",
"(",
")",
")",
")",
"throw",
"new",
"StringIndexOutOfBoundsException",
"(",
"offset",
")",
";",
"int",
"len",
"=",
"str",
".",
"length",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"offset",
",",
"value",
",",
"offset",
"+",
"len",
",",
"count",
"-",
"offset",
")",
";",
"System",
".",
"arraycopy",
"(",
"str",
",",
"0",
",",
"value",
",",
"offset",
",",
"len",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Inserts the specified {@code CharSequence} into this sequence.\n * <p>\n * The characters of the {@code CharSequence} argument are inserted,\n * in order, into this sequence at the indicated offset, moving up\n * any characters originally above that position and increasing the length\n * of this sequence by the length of the argument s.\n * <p>\n * The result of this method is exactly the same as if it were an\n * invocation of this object's\n * {@link #insert(int, CharSequence, int, int) insert}(dstOffset, s, 0, s.length())\n * method.\n * <p>\n * <p>If {@code s} is {@code null}, then the four characters\n * {@code \"null\"} are inserted into this sequence.\n *\n * @param dstOffset the offset.\n * @param s the sequence to be inserted\n * @return a reference to this object.\n * @throws IndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"dstOffset",
",",
"CharSequence",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"s",
"=",
"\"",
"null",
"\"",
";",
"if",
"(",
"s",
"instanceof",
"String",
")",
"return",
"this",
".",
"insert",
"(",
"dstOffset",
",",
"(",
"String",
")",
"s",
")",
";",
"return",
"this",
".",
"insert",
"(",
"dstOffset",
",",
"s",
",",
"0",
",",
"s",
".",
"length",
"(",
")",
")",
";",
"}",
"/**\n * Inserts a subsequence of the specified {@code CharSequence} into\n * this sequence.\n * <p>\n * The subsequence of the argument {@code s} specified by\n * {@code start} and {@code end} are inserted,\n * in order, into this sequence at the specified destination offset, moving\n * up any characters originally above that position. The length of this\n * sequence is increased by {@code end - start}.\n * <p>\n * The character at index <i>k</i> in this sequence becomes equal to:\n * <ul>\n * <li>the character at index <i>k</i> in this sequence, if\n * <i>k</i> is less than {@code dstOffset}\n * <li>the character at index <i>k</i>{@code +start-dstOffset} in\n * the argument {@code s}, if <i>k</i> is greater than or equal to\n * {@code dstOffset} but is less than {@code dstOffset+end-start}\n * <li>the character at index <i>k</i>{@code -(end-start)} in this\n * sequence, if <i>k</i> is greater than or equal to\n * {@code dstOffset+end-start}\n * </ul><p>\n * The {@code dstOffset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n * <p>The start argument must be nonnegative, and not greater than\n * {@code end}.\n * <p>The end argument must be greater than or equal to\n * {@code start}, and less than or equal to the length of s.\n * <p>\n * <p>If {@code s} is {@code null}, then this method inserts\n * characters as if the s parameter was a sequence containing the four\n * characters {@code \"null\"}.\n *\n * @param dstOffset the offset in this sequence.\n * @param s the sequence to be inserted.\n * @param start the starting index of the subsequence to be inserted.\n * @param end the end index of the subsequence to be inserted.\n * @return a reference to this object.\n * @throws IndexOutOfBoundsException if {@code dstOffset}\n * is negative or greater than {@code this.length()}, or\n * {@code start} or {@code end} are negative, or\n * {@code start} is greater than {@code end} or\n * {@code end} is greater than {@code s.length()}\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"dstOffset",
",",
"CharSequence",
"s",
",",
"int",
"start",
",",
"int",
"end",
")",
"{",
"if",
"(",
"s",
"==",
"null",
")",
"s",
"=",
"\"",
"null",
"\"",
";",
"if",
"(",
"(",
"dstOffset",
"<",
"0",
")",
"||",
"(",
"dstOffset",
">",
"this",
".",
"length",
"(",
")",
")",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"",
"dstOffset ",
"\"",
"+",
"dstOffset",
")",
";",
"if",
"(",
"(",
"start",
"<",
"0",
")",
"||",
"(",
"end",
"<",
"0",
")",
"||",
"(",
"start",
">",
"end",
")",
"||",
"(",
"end",
">",
"s",
".",
"length",
"(",
")",
")",
")",
"throw",
"new",
"IndexOutOfBoundsException",
"(",
"\"",
"start ",
"\"",
"+",
"start",
"+",
"\"",
", end ",
"\"",
"+",
"end",
"+",
"\"",
", s.length() ",
"\"",
"+",
"s",
".",
"length",
"(",
")",
")",
";",
"int",
"len",
"=",
"end",
"-",
"start",
";",
"ensureCapacityInternal",
"(",
"count",
"+",
"len",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"dstOffset",
",",
"value",
",",
"dstOffset",
"+",
"len",
",",
"count",
"-",
"dstOffset",
")",
";",
"for",
"(",
"int",
"i",
"=",
"start",
";",
"i",
"<",
"end",
";",
"i",
"++",
")",
"value",
"[",
"dstOffset",
"++",
"]",
"=",
"s",
".",
"charAt",
"(",
"i",
")",
";",
"count",
"+=",
"len",
";",
"return",
"this",
";",
"}",
"/**\n * Inserts the string representation of the {@code boolean}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(boolean)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param b a {@code boolean}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"boolean",
"b",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"b",
")",
")",
";",
"}",
"/**\n * Inserts the string representation of the {@code char}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(char)},\n * and the character in that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param c a {@code char}.\n * @return a reference to this object.\n * @throws IndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"char",
"c",
")",
"{",
"ensureCapacityInternal",
"(",
"count",
"+",
"1",
")",
";",
"System",
".",
"arraycopy",
"(",
"value",
",",
"offset",
",",
"value",
",",
"offset",
"+",
"1",
",",
"count",
"-",
"offset",
")",
";",
"value",
"[",
"offset",
"]",
"=",
"c",
";",
"count",
"+=",
"1",
";",
"return",
"this",
";",
"}",
"/**\n * Inserts the string representation of the second {@code int}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(int)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param i an {@code int}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"int",
"i",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"i",
")",
")",
";",
"}",
"/**\n * Inserts the string representation of the {@code long}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(long)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param l a {@code long}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"long",
"l",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"l",
")",
")",
";",
"}",
"/**\n * Inserts the string representation of the {@code float}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(float)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param f a {@code float}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"float",
"f",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"f",
")",
")",
";",
"}",
"/**\n * Inserts the string representation of the {@code double}\n * argument into this sequence.\n * <p>\n * The overall effect is exactly as if the second argument were\n * converted to a string by the method {@link String#valueOf(double)},\n * and the characters of that string were then\n * {@link #insert(int, String) inserted} into this character\n * sequence at the indicated offset.\n * <p>\n * The {@code offset} argument must be greater than or equal to\n * {@code 0}, and less than or equal to the {@linkplain #length() length}\n * of this sequence.\n *\n * @param offset the offset.\n * @param d a {@code double}.\n * @return a reference to this object.\n * @throws StringIndexOutOfBoundsException if the offset is invalid.\n */",
"public",
"Buffer",
"insert",
"(",
"int",
"offset",
",",
"double",
"d",
")",
"{",
"return",
"insert",
"(",
"offset",
",",
"String",
".",
"valueOf",
"(",
"d",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"write",
"(",
"char",
"[",
"]",
"cbuf",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"append",
"(",
"cbuf",
",",
"off",
",",
"len",
")",
";",
"}",
"/**\n * Write a character `c` to this buf.\n *\n * Special note, this method is **NOT** the same with\n * {@link #append(int)}, which will append String representation\n * of passed in int, while this method, instead,\n * treats the int as a character\n *\n * @param c\n * the character `c`\n */",
"@",
"Override",
"public",
"void",
"write",
"(",
"int",
"c",
")",
"{",
"append",
"(",
"(",
"char",
")",
"c",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"write",
"(",
"char",
"[",
"]",
"cbuf",
")",
"{",
"write",
"(",
"cbuf",
",",
"0",
",",
"cbuf",
".",
"length",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"write",
"(",
"String",
"str",
")",
"{",
"write",
"(",
"str",
",",
"0",
",",
"str",
".",
"length",
"(",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"write",
"(",
"String",
"str",
",",
"int",
"off",
",",
"int",
"len",
")",
"{",
"append",
"(",
"str",
",",
"off",
",",
"off",
"+",
"len",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"flush",
"(",
")",
"{",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"}",
"/**\n * Returns the index within this string of the first occurrence of the\n * specified substring. The integer returned is the smallest value\n * <i>k</i> such that:\n * <pre>{@code\n * this.toString().startsWith(str, <i>k</i>)\n * }</pre>\n * is {@code true}.\n *\n * @param str any string.\n * @return if the string argument occurs as a substring within this\n * object, then the index of the first character of the first\n * such substring is returned; if it does not occur as a\n * substring, {@code -1} is returned.\n */",
"public",
"int",
"indexOf",
"(",
"String",
"str",
")",
"{",
"return",
"indexOf",
"(",
"str",
",",
"0",
")",
";",
"}",
"/**\n * Returns the index within this string of the first occurrence of the\n * specified substring, starting at the specified index. The integer\n * returned is the smallest value {@code k} for which:\n * <pre>{@code\n * k >= Math.min(fromIndex, this.length()) &&\n * this.toString().startsWith(str, k)\n * }</pre>\n * If no such value of <i>k</i> exists, then -1 is returned.\n *\n * @param str the substring for which to search.\n * @param fromIndex the index from which to start the search.\n * @return the index within this string of the first occurrence of the\n * specified substring, starting at the specified index.\n */",
"public",
"int",
"indexOf",
"(",
"String",
"str",
",",
"int",
"fromIndex",
")",
"{",
"char",
"[",
"]",
"buf",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"return",
"S",
".",
"indexOf",
"(",
"this",
".",
"value",
",",
"0",
",",
"count",
",",
"buf",
",",
"0",
",",
"buf",
".",
"length",
",",
"fromIndex",
")",
";",
"}",
"/**\n * Returns the index within this string of the rightmost occurrence\n * of the specified substring. The rightmost empty string \"\" is\n * considered to occur at the index value {@code this.length()}.\n * The returned index is the largest value <i>k</i> such that\n * <pre>{@code\n * this.toString().startsWith(str, k)\n * }</pre>\n * is true.\n *\n * @param str the substring to search for.\n * @return if the string argument occurs one or more times as a substring\n * within this object, then the index of the first character of\n * the last such substring is returned. If it does not occur as\n * a substring, {@code -1} is returned.\n */",
"public",
"int",
"lastIndexOf",
"(",
"String",
"str",
")",
"{",
"return",
"lastIndexOf",
"(",
"str",
",",
"count",
")",
";",
"}",
"/**\n * Returns the index within this string of the last occurrence of the\n * specified substring. The integer returned is the largest value <i>k</i>\n * such that:\n * <pre>{@code\n * k <= Math.min(fromIndex, this.length()) &&\n * this.toString().startsWith(str, k)\n * }</pre>\n * If no such value of <i>k</i> exists, then -1 is returned.\n *\n * @param str the substring to search for.\n * @param fromIndex the index to start the search from.\n * @return the index within this sequence of the last occurrence of the\n * specified substring.\n */",
"public",
"int",
"lastIndexOf",
"(",
"String",
"str",
",",
"int",
"fromIndex",
")",
"{",
"char",
"[",
"]",
"buf",
"=",
"str",
".",
"toCharArray",
"(",
")",
";",
"return",
"S",
".",
"lastIndexOf",
"(",
"value",
",",
"0",
",",
"count",
",",
"buf",
",",
"0",
",",
"buf",
".",
"length",
",",
"fromIndex",
")",
";",
"}",
"/**\n * Causes this character sequence to be replaced by the reverse of\n * the sequence. If there are any surrogate pairs included in the\n * sequence, these are treated as single characters for the\n * reverse operation. Thus, the order of the high-low surrogates\n * is never reversed.\n * <p>\n * Let <i>n</i> be the character length of this character sequence\n * (not the length in {@code char} values) just prior to\n * execution of the {@code reverse} method. Then the\n * character at index <i>k</i> in the new character sequence is\n * equal to the character at index <i>n-k-1</i> in the old\n * character sequence.\n * <p>\n * <p>Note that the reverse operation may result in producing\n * surrogate pairs that were unpaired low-surrogates and\n * high-surrogates before the operation. For example, reversing\n * \"\\u005CuDC00\\u005CuD800\" produces \"\\u005CuD800\\u005CuDC00\" which is\n * a valid surrogate pair.\n *\n * @return a reference to this object.\n */",
"public",
"Buffer",
"reverse",
"(",
")",
"{",
"boolean",
"hasSurrogates",
"=",
"false",
";",
"int",
"n",
"=",
"count",
"-",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"(",
"n",
"-",
"1",
")",
">>",
"1",
";",
"j",
">=",
"0",
";",
"j",
"--",
")",
"{",
"int",
"k",
"=",
"n",
"-",
"j",
";",
"char",
"cj",
"=",
"value",
"[",
"j",
"]",
";",
"char",
"ck",
"=",
"value",
"[",
"k",
"]",
";",
"value",
"[",
"j",
"]",
"=",
"ck",
";",
"value",
"[",
"k",
"]",
"=",
"cj",
";",
"if",
"(",
"Character",
".",
"isSurrogate",
"(",
"cj",
")",
"||",
"Character",
".",
"isSurrogate",
"(",
"ck",
")",
")",
"{",
"hasSurrogates",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"hasSurrogates",
")",
"{",
"reverseAllValidSurrogatePairs",
"(",
")",
";",
"}",
"return",
"this",
";",
"}",
"/**\n * The maximum size of array to allocate (unless necessary).\n * Some VMs reserve some header words in an array.\n * Attempts to allocate larger arrays may result in\n * OutOfMemoryError: Requested array size exceeds VM limit\n */",
"private",
"static",
"final",
"int",
"MAX_ARRAY_SIZE",
"=",
"Integer",
".",
"MAX_VALUE",
"-",
"8",
";",
"/**\n * For positive values of {@code minimumCapacity}, this method\n * behaves like {@code ensureCapacity}, however it is never\n * synchronized.\n * If {@code minimumCapacity} is non positive due to numeric\n * overflow, this method throws {@code OutOfMemoryError}.\n */",
"private",
"void",
"ensureCapacityInternal",
"(",
"int",
"minimumCapacity",
")",
"{",
"if",
"(",
"minimumCapacity",
"-",
"value",
".",
"length",
">",
"0",
")",
"{",
"value",
"=",
"Arrays",
".",
"copyOf",
"(",
"value",
",",
"newCapacity",
"(",
"minimumCapacity",
")",
")",
";",
"}",
"}",
"/**\n * Returns a capacity at least as large as the given minimum capacity.\n * Returns the current capacity increased by the same amount + 2 if\n * that suffices.\n * Will not return a capacity greater than {@code MAX_ARRAY_SIZE}\n * unless the given minimum capacity is greater than that.\n *\n * @param minCapacity the desired minimum capacity\n * @throws OutOfMemoryError if minCapacity is less than zero or\n * greater than Integer.MAX_VALUE\n */",
"private",
"int",
"newCapacity",
"(",
"int",
"minCapacity",
")",
"{",
"int",
"newCapacity",
"=",
"(",
"value",
".",
"length",
"<<",
"1",
")",
"+",
"2",
";",
"if",
"(",
"newCapacity",
"-",
"minCapacity",
"<",
"0",
")",
"{",
"newCapacity",
"=",
"minCapacity",
";",
"}",
"return",
"(",
"newCapacity",
"<=",
"0",
"||",
"MAX_ARRAY_SIZE",
"-",
"newCapacity",
"<",
"0",
")",
"?",
"hugeCapacity",
"(",
"minCapacity",
")",
":",
"newCapacity",
";",
"}",
"private",
"int",
"hugeCapacity",
"(",
"int",
"minCapacity",
")",
"{",
"if",
"(",
"Integer",
".",
"MAX_VALUE",
"-",
"minCapacity",
"<",
"0",
")",
"{",
"throw",
"new",
"OutOfMemoryError",
"(",
")",
";",
"}",
"return",
"(",
"minCapacity",
">",
"MAX_ARRAY_SIZE",
")",
"?",
"minCapacity",
":",
"MAX_ARRAY_SIZE",
";",
"}",
"/**\n * Outlined helper method for reverse()\n */",
"private",
"void",
"reverseAllValidSurrogatePairs",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"count",
"-",
"1",
";",
"i",
"++",
")",
"{",
"char",
"c2",
"=",
"value",
"[",
"i",
"]",
";",
"if",
"(",
"Character",
".",
"isLowSurrogate",
"(",
"c2",
")",
")",
"{",
"char",
"c1",
"=",
"value",
"[",
"i",
"+",
"1",
"]",
";",
"if",
"(",
"Character",
".",
"isHighSurrogate",
"(",
"c1",
")",
")",
"{",
"value",
"[",
"i",
"++",
"]",
"=",
"c1",
";",
"value",
"[",
"i",
"]",
"=",
"c2",
";",
"}",
"}",
"}",
"}",
"/**\n * Returns a string representing the data in this sequence.\n * A new {@code String} object is allocated and initialized to\n * contain the character sequence currently represented by this\n * object. This {@code String} is then returned. Subsequent\n * changes to this sequence do not affect the contents of the\n * {@code String}.\n * <p>\n * After this method is called, the buffer of this Buffer\n * instance will be reset to 0, meaning this Buffer is\n * consumed\n *\n * @return a string representation of this sequence of characters.\n */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"String",
"retval",
"=",
"new",
"String",
"(",
"value",
",",
"0",
",",
"count",
")",
";",
"this",
".",
"consumed",
"=",
"true",
";",
"return",
"retval",
";",
"}",
"public",
"String",
"view",
"(",
")",
"{",
"return",
"new",
"String",
"(",
"value",
",",
"0",
",",
"count",
")",
";",
"}",
"/**\n * Needed by {@code String} for the contentEquals method.\n */",
"final",
"char",
"[",
"]",
"getValue",
"(",
")",
"{",
"return",
"value",
";",
"}",
"final",
"static",
"int",
"[",
"]",
"sizeTable",
"=",
"{",
"9",
",",
"99",
",",
"999",
",",
"9999",
",",
"99999",
",",
"999999",
",",
"9999999",
",",
"99999999",
",",
"999999999",
",",
"Integer",
".",
"MAX_VALUE",
"}",
";",
"static",
"int",
"stringSize",
"(",
"int",
"x",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
";",
"i",
"++",
")",
"if",
"(",
"x",
"<=",
"sizeTable",
"[",
"i",
"]",
")",
"return",
"i",
"+",
"1",
";",
"}",
"final",
"static",
"char",
"[",
"]",
"DigitTens",
"=",
"{",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'0'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'1'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'2'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'3'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'4'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'5'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'6'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'7'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'8'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"'9'",
",",
"}",
";",
"final",
"static",
"char",
"[",
"]",
"DigitOnes",
"=",
"{",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"}",
";",
"/**\n * All possible chars for representing a number as a String\n */",
"final",
"static",
"char",
"[",
"]",
"digits",
"=",
"{",
"'0'",
",",
"'1'",
",",
"'2'",
",",
"'3'",
",",
"'4'",
",",
"'5'",
",",
"'6'",
",",
"'7'",
",",
"'8'",
",",
"'9'",
",",
"'a'",
",",
"'b'",
",",
"'c'",
",",
"'d'",
",",
"'e'",
",",
"'f'",
",",
"'g'",
",",
"'h'",
",",
"'i'",
",",
"'j'",
",",
"'k'",
",",
"'l'",
",",
"'m'",
",",
"'n'",
",",
"'o'",
",",
"'p'",
",",
"'q'",
",",
"'r'",
",",
"'s'",
",",
"'t'",
",",
"'u'",
",",
"'v'",
",",
"'w'",
",",
"'x'",
",",
"'y'",
",",
"'z'",
"}",
";",
"/**\n * Places characters representing the integer i into the\n * character array buf. The characters are placed into\n * the buffer backwards starting with the least significant\n * digit at the specified index (exclusive), and working\n * backwards from there.\n * <p>\n * Will fail if i == Integer.MIN_VALUE\n */",
"static",
"void",
"getChars",
"(",
"int",
"i",
",",
"int",
"index",
",",
"char",
"[",
"]",
"buf",
")",
"{",
"int",
"q",
",",
"r",
";",
"int",
"charPos",
"=",
"index",
";",
"char",
"sign",
"=",
"0",
";",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"sign",
"=",
"'-'",
";",
"i",
"=",
"-",
"i",
";",
"}",
"while",
"(",
"i",
">=",
"65536",
")",
"{",
"q",
"=",
"i",
"/",
"100",
";",
"r",
"=",
"i",
"-",
"(",
"(",
"q",
"<<",
"6",
")",
"+",
"(",
"q",
"<<",
"5",
")",
"+",
"(",
"q",
"<<",
"2",
")",
")",
";",
"i",
"=",
"q",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitOnes",
"[",
"r",
"]",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitTens",
"[",
"r",
"]",
";",
"}",
"for",
"(",
";",
";",
")",
"{",
"q",
"=",
"(",
"i",
"*",
"52429",
")",
">>>",
"(",
"16",
"+",
"3",
")",
";",
"r",
"=",
"i",
"-",
"(",
"(",
"q",
"<<",
"3",
")",
"+",
"(",
"q",
"<<",
"1",
")",
")",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"digits",
"[",
"r",
"]",
";",
"i",
"=",
"q",
";",
"if",
"(",
"i",
"==",
"0",
")",
"break",
";",
"}",
"if",
"(",
"sign",
"!=",
"0",
")",
"{",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"sign",
";",
"}",
"}",
"static",
"int",
"stringSize",
"(",
"long",
"x",
")",
"{",
"long",
"p",
"=",
"10",
";",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<",
"19",
";",
"i",
"++",
")",
"{",
"if",
"(",
"x",
"<",
"p",
")",
"return",
"i",
";",
"p",
"=",
"10",
"*",
"p",
";",
"}",
"return",
"19",
";",
"}",
"/**\n * Places characters representing the integer i into the\n * character array buf. The characters are placed into\n * the buffer backwards starting with the least significant\n * digit at the specified index (exclusive), and working\n * backwards from there.\n * <p>\n * Will fail if i == Long.MIN_VALUE\n */",
"static",
"void",
"getChars",
"(",
"long",
"i",
",",
"int",
"index",
",",
"char",
"[",
"]",
"buf",
")",
"{",
"long",
"q",
";",
"int",
"r",
";",
"int",
"charPos",
"=",
"index",
";",
"char",
"sign",
"=",
"0",
";",
"if",
"(",
"i",
"<",
"0",
")",
"{",
"sign",
"=",
"'-'",
";",
"i",
"=",
"-",
"i",
";",
"}",
"while",
"(",
"i",
">",
"Integer",
".",
"MAX_VALUE",
")",
"{",
"q",
"=",
"i",
"/",
"100",
";",
"r",
"=",
"(",
"int",
")",
"(",
"i",
"-",
"(",
"(",
"q",
"<<",
"6",
")",
"+",
"(",
"q",
"<<",
"5",
")",
"+",
"(",
"q",
"<<",
"2",
")",
")",
")",
";",
"i",
"=",
"q",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitOnes",
"[",
"r",
"]",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitTens",
"[",
"r",
"]",
";",
"}",
"int",
"q2",
";",
"int",
"i2",
"=",
"(",
"int",
")",
"i",
";",
"while",
"(",
"i2",
">=",
"65536",
")",
"{",
"q2",
"=",
"i2",
"/",
"100",
";",
"r",
"=",
"i2",
"-",
"(",
"(",
"q2",
"<<",
"6",
")",
"+",
"(",
"q2",
"<<",
"5",
")",
"+",
"(",
"q2",
"<<",
"2",
")",
")",
";",
"i2",
"=",
"q2",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitOnes",
"[",
"r",
"]",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"DigitTens",
"[",
"r",
"]",
";",
"}",
"for",
"(",
";",
";",
")",
"{",
"q2",
"=",
"(",
"i2",
"*",
"52429",
")",
">>>",
"(",
"16",
"+",
"3",
")",
";",
"r",
"=",
"i2",
"-",
"(",
"(",
"q2",
"<<",
"3",
")",
"+",
"(",
"q2",
"<<",
"1",
")",
")",
";",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"digits",
"[",
"r",
"]",
";",
"i2",
"=",
"q2",
";",
"if",
"(",
"i2",
"==",
"0",
")",
"break",
";",
"}",
"if",
"(",
"sign",
"!=",
"0",
")",
"{",
"buf",
"[",
"--",
"charPos",
"]",
"=",
"sign",
";",
"}",
"}",
"static",
"void",
"toSurrogates",
"(",
"int",
"codePoint",
",",
"char",
"[",
"]",
"dst",
",",
"int",
"index",
")",
"{",
"dst",
"[",
"index",
"+",
"1",
"]",
"=",
"lowSurrogate",
"(",
"codePoint",
")",
";",
"dst",
"[",
"index",
"]",
"=",
"highSurrogate",
"(",
"codePoint",
")",
";",
"}",
"}"
] | A `S.Buffer` is OSGL's implementation of JDK's
{@link StringBuilder} with additional method to track
the state of the instance, i.e. | [
"A",
"`",
"S",
".",
"Buffer",
"`",
"is",
"OSGL",
"'",
"s",
"implementation",
"of",
"JDK",
"'",
"s",
"{",
"@link",
"StringBuilder",
"}",
"with",
"additional",
"method",
"to",
"track",
"the",
"state",
"of",
"the",
"instance",
"i",
".",
"e",
"."
] | [
"// Documentation in subclasses because of synchro difference",
"// Documentation in subclasses because of synchro difference",
"// Documentation in subclasses because of synchro difference",
"// Documentation in subclasses because of synchro difference",
"// Documentation in subclasses because of synchro difference",
"// let arraycopy report AIOOBE for len < 0",
"// overflow-conscious code",
"// overflow-conscious code",
"// overflow",
"// Create a copy, don't share the array",
"// Requires positive x",
"// Generate two digits per iteration",
"// really: r = i - (q * 100);",
"// Fall thru to fast mode for smaller numbers",
"// assert(i <= 65536, i);",
"// r = i-(q*10) ...",
"// Requires positive x",
"// Get 2 digits/iteration using longs until quotient fits into an int",
"// really: r = i - (q * 100);",
"// Get 2 digits/iteration using ints",
"// really: r = i2 - (q * 100);",
"// Fall thru to fast mode for smaller numbers",
"// assert(i2 <= 65536, i2);",
"// r = i2-(q2*10) ...",
"// We write elements \"backwards\" to guarantee all-or-nothing"
] | [
{
"param": "Writer",
"type": null
},
{
"param": "Appendable, CharSequence",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Writer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Appendable, CharSequence",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
071ae78e92b910299485558d32ea9e04ef3eecc2 | ocelotpotpie/ItemLocker | src/nu/nerd/itemlocker/PlayerState.java | [
"MIT"
] | Java | PlayerState | /**
* Transient, per-player state, created on join and removed when the player
* leaves.
*/ | Transient, per-player state, created on join and removed when the player
leaves. | [
"Transient",
"per",
"-",
"player",
"state",
"created",
"on",
"join",
"and",
"removed",
"when",
"the",
"player",
"leaves",
"."
] | public class PlayerState {
// ------------------------------------------------------------------------
/**
* Constructor.
*
* @param player the player.
* @param config the configuration from which player preferences are loaded.
*/
public PlayerState(Player player, YamlConfiguration config) {
_player = player;
load(config);
}
// ------------------------------------------------------------------------
/**
* Return the default permissions as a PermissionChange instance.
*
* @return the default permissions as a PermissionChange instance.
*/
public PermissionChange asPermissionChange() {
return new PermissionChange(_player, getDefaultRegionName(), getDefaultAccessGroup(), getDefaultRotateGroup());
}
// ------------------------------------------------------------------------
/**
* Set the default region name to use when locking.
*
* @param name the region name; use "-" to signify no region.
*/
public void setDefaultRegionName(String name) {
_defaultRegionName = name;
}
// ------------------------------------------------------------------------
/**
* Return the default region name to use when locking.
*
* A non-null region name will suppress region inference if none is
* specified in the /ilock command.
*
* @return the default region name to use when locking.
*/
public String getDefaultRegionName() {
return _defaultRegionName;
}
// ------------------------------------------------------------------------
/**
* Set the default access group to use when locking.
*
* @param group the group.
*/
public void setDefaultAccessGroup(PermissionGroup group) {
_defaultAccessGroup = group;
}
// ------------------------------------------------------------------------
/**
* Return the default access permission group to use when locking.
*
* @return the default access permission group to use when locking.
*/
public PermissionGroup getDefaultAccessGroup() {
return _defaultAccessGroup;
}
// ------------------------------------------------------------------------
/**
* Set the default rotate group to use when locking.
*
* @param group the group.
*/
public void setDefaultRotateGroup(PermissionGroup group) {
_defaultRotateGroup = group;
}
// ------------------------------------------------------------------------
/**
* Return the default rotate permission group to use when locking.
*
* @return the default rotate permission group to use when locking.
*/
public PermissionGroup getDefaultRotateGroup() {
return _defaultRotateGroup;
}
// ------------------------------------------------------------------------
/**
* Save this player's preferences to the specified configuration.
*
* @param config the configuration to update.
*/
public void save(YamlConfiguration config) {
ConfigurationSection section = config.createSection(_player.getUniqueId().toString());
section.set("name", _player.getName());
section.set("region", _defaultRegionName);
if (_defaultAccessGroup != null) {
section.set("access", _defaultAccessGroup.toString());
}
if (_defaultRotateGroup != null) {
section.set("rotate", _defaultRotateGroup.toString());
}
}
// ------------------------------------------------------------------------
/**
* Load the Player's preferences from the specified configuration
*
* @param config the configuration from which player preferences are loaded.
*/
protected void load(YamlConfiguration config) {
ConfigurationSection section = config.getConfigurationSection(_player.getUniqueId().toString());
if (section == null) {
section = config.createSection(_player.getUniqueId().toString());
}
_defaultRegionName = section.getString("region");
_defaultAccessGroup = parsePermissionGroup(section.getString("access"));
_defaultRotateGroup = parsePermissionGroup(section.getString("rotate"));
}
// ------------------------------------------------------------------------
/**
* Parse a permission group setting loaded from the configuration.
*
* @param setting the group as a string.
* @return the corresponding PermissionGroup; return null for a null (unset)
* setting.
*/
protected static PermissionGroup parsePermissionGroup(String setting) {
return (setting == null) ? null : PermissionGroup.valueOf(setting);
}
// ------------------------------------------------------------------------
/**
* The player's name.
*/
protected Player _player;
/**
* Default region name.
*/
protected String _defaultRegionName;
/**
* Default access permission group; null to signify use the global default.
*/
protected PermissionGroup _defaultAccessGroup;
/**
* Default rotate permission group; null to signify use the global default.
*/
protected PermissionGroup _defaultRotateGroup;
} | [
"public",
"class",
"PlayerState",
"{",
"/**\n * Constructor.\n *\n * @param player the player.\n * @param config the configuration from which player preferences are loaded.\n */",
"public",
"PlayerState",
"(",
"Player",
"player",
",",
"YamlConfiguration",
"config",
")",
"{",
"_player",
"=",
"player",
";",
"load",
"(",
"config",
")",
";",
"}",
"/**\n * Return the default permissions as a PermissionChange instance.\n * \n * @return the default permissions as a PermissionChange instance.\n */",
"public",
"PermissionChange",
"asPermissionChange",
"(",
")",
"{",
"return",
"new",
"PermissionChange",
"(",
"_player",
",",
"getDefaultRegionName",
"(",
")",
",",
"getDefaultAccessGroup",
"(",
")",
",",
"getDefaultRotateGroup",
"(",
")",
")",
";",
"}",
"/**\n * Set the default region name to use when locking.\n * \n * @param name the region name; use \"-\" to signify no region.\n */",
"public",
"void",
"setDefaultRegionName",
"(",
"String",
"name",
")",
"{",
"_defaultRegionName",
"=",
"name",
";",
"}",
"/**\n * Return the default region name to use when locking.\n * \n * A non-null region name will suppress region inference if none is\n * specified in the /ilock command.\n * \n * @return the default region name to use when locking.\n */",
"public",
"String",
"getDefaultRegionName",
"(",
")",
"{",
"return",
"_defaultRegionName",
";",
"}",
"/**\n * Set the default access group to use when locking.\n * \n * @param group the group.\n */",
"public",
"void",
"setDefaultAccessGroup",
"(",
"PermissionGroup",
"group",
")",
"{",
"_defaultAccessGroup",
"=",
"group",
";",
"}",
"/**\n * Return the default access permission group to use when locking.\n * \n * @return the default access permission group to use when locking.\n */",
"public",
"PermissionGroup",
"getDefaultAccessGroup",
"(",
")",
"{",
"return",
"_defaultAccessGroup",
";",
"}",
"/**\n * Set the default rotate group to use when locking.\n * \n * @param group the group.\n */",
"public",
"void",
"setDefaultRotateGroup",
"(",
"PermissionGroup",
"group",
")",
"{",
"_defaultRotateGroup",
"=",
"group",
";",
"}",
"/**\n * Return the default rotate permission group to use when locking.\n * \n * @return the default rotate permission group to use when locking.\n */",
"public",
"PermissionGroup",
"getDefaultRotateGroup",
"(",
")",
"{",
"return",
"_defaultRotateGroup",
";",
"}",
"/**\n * Save this player's preferences to the specified configuration.\n *\n * @param config the configuration to update.\n */",
"public",
"void",
"save",
"(",
"YamlConfiguration",
"config",
")",
"{",
"ConfigurationSection",
"section",
"=",
"config",
".",
"createSection",
"(",
"_player",
".",
"getUniqueId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"section",
".",
"set",
"(",
"\"",
"name",
"\"",
",",
"_player",
".",
"getName",
"(",
")",
")",
";",
"section",
".",
"set",
"(",
"\"",
"region",
"\"",
",",
"_defaultRegionName",
")",
";",
"if",
"(",
"_defaultAccessGroup",
"!=",
"null",
")",
"{",
"section",
".",
"set",
"(",
"\"",
"access",
"\"",
",",
"_defaultAccessGroup",
".",
"toString",
"(",
")",
")",
";",
"}",
"if",
"(",
"_defaultRotateGroup",
"!=",
"null",
")",
"{",
"section",
".",
"set",
"(",
"\"",
"rotate",
"\"",
",",
"_defaultRotateGroup",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"/**\n * Load the Player's preferences from the specified configuration\n *\n * @param config the configuration from which player preferences are loaded.\n */",
"protected",
"void",
"load",
"(",
"YamlConfiguration",
"config",
")",
"{",
"ConfigurationSection",
"section",
"=",
"config",
".",
"getConfigurationSection",
"(",
"_player",
".",
"getUniqueId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"if",
"(",
"section",
"==",
"null",
")",
"{",
"section",
"=",
"config",
".",
"createSection",
"(",
"_player",
".",
"getUniqueId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"}",
"_defaultRegionName",
"=",
"section",
".",
"getString",
"(",
"\"",
"region",
"\"",
")",
";",
"_defaultAccessGroup",
"=",
"parsePermissionGroup",
"(",
"section",
".",
"getString",
"(",
"\"",
"access",
"\"",
")",
")",
";",
"_defaultRotateGroup",
"=",
"parsePermissionGroup",
"(",
"section",
".",
"getString",
"(",
"\"",
"rotate",
"\"",
")",
")",
";",
"}",
"/**\n * Parse a permission group setting loaded from the configuration.\n * \n * @param setting the group as a string.\n * @return the corresponding PermissionGroup; return null for a null (unset)\n * setting.\n */",
"protected",
"static",
"PermissionGroup",
"parsePermissionGroup",
"(",
"String",
"setting",
")",
"{",
"return",
"(",
"setting",
"==",
"null",
")",
"?",
"null",
":",
"PermissionGroup",
".",
"valueOf",
"(",
"setting",
")",
";",
"}",
"/**\n * The player's name.\n */",
"protected",
"Player",
"_player",
";",
"/**\n * Default region name.\n */",
"protected",
"String",
"_defaultRegionName",
";",
"/**\n * Default access permission group; null to signify use the global default.\n */",
"protected",
"PermissionGroup",
"_defaultAccessGroup",
";",
"/**\n * Default rotate permission group; null to signify use the global default.\n */",
"protected",
"PermissionGroup",
"_defaultRotateGroup",
";",
"}"
] | Transient, per-player state, created on join and removed when the player
leaves. | [
"Transient",
"per",
"-",
"player",
"state",
"created",
"on",
"join",
"and",
"removed",
"when",
"the",
"player",
"leaves",
"."
] | [
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------",
"// ------------------------------------------------------------------------"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
071d27382dc474715585d9d6494151cfc15bdbc3 | Yumenokanata/Avocado | avocado-functional/src/main/java/indi/yume/tools/avocado/functional/listmatch/UnitCase.java | [
"Apache-2.0"
] | Java | UnitCase | /**
* Created by yume on 16-8-15.
*/ | Created by yume on 16-8-15. | [
"Created",
"by",
"yume",
"on",
"16",
"-",
"8",
"-",
"15",
"."
] | public class UnitCase {
public static <T> UnitStartWord<T> when(T value) {
return new UnitStartWord<>(value);
}
@Data
public static class UnitStartWord<C> {
private final C checkValue;
public <W> UnitCaseWord<C> case_(
Function<C, Tuple2<Boolean, W>> matcher,
Consumer<W> action) {
final Tuple2<Boolean, W> data = FuncUtils.runUnsafe(matcher, checkValue);
if(data.getData1()) {
FuncUtils.runUnsafe(action, data.getData2());
return UnitCaseWord.RightCase.unit(checkValue);
}
return UnitCaseWord.LeftCase.unit(checkValue);
}
public UnitCaseWord<C> case_pd(
Function<C, Boolean> matcher,
Consumer<C> action) {
return case_(v -> Tuple2.<Boolean, C>of(matcher.apply(v), v), action);
}
}
public static abstract class UnitCaseWord<C> {
public abstract <W> UnitCaseWord<C> case_(
Function<C, Tuple2<Boolean, W>> matcher,
Consumer<W> action);
public abstract void else_(Consumer<C> action);
public UnitCaseWord<C> case_pd(Function<C, Boolean> matcher,
Consumer<C> action){
return this.case_(v -> Tuple2.<Boolean, C>of(matcher.apply(v), v), action);
}
@Data(staticConstructor = "unit")
@EqualsAndHashCode(callSuper = false)
public static class LeftCase<C> extends UnitCaseWord<C> {
private final C checkValue;
@Override
public <W> UnitCaseWord<C> case_(
Function<C, Tuple2<Boolean, W>> matcher,
Consumer<W> action) {
final Tuple2<Boolean, W> data = FuncUtils.runUnsafe(matcher, checkValue);
if(data.getData1()) {
FuncUtils.runUnsafe(action, data.getData2());
return RightCase.unit(checkValue);
}
return this;
}
@Override
public void else_(Consumer<C> action) {
FuncUtils.runUnsafe(action, checkValue);
}
}
@Data(staticConstructor = "unit")
@EqualsAndHashCode(callSuper = false)
public static class RightCase<C> extends UnitCaseWord<C> {
private final C checkValue;
@Override
public <W> UnitCaseWord<C> case_(
Function<C, Tuple2<Boolean, W>> matcher,
Consumer<W> action) {
return this;
}
@Override
public void else_(Consumer<C> action) {
}
}
}
} | [
"public",
"class",
"UnitCase",
"{",
"public",
"static",
"<",
"T",
">",
"UnitStartWord",
"<",
"T",
">",
"when",
"(",
"T",
"value",
")",
"{",
"return",
"new",
"UnitStartWord",
"<",
">",
"(",
"value",
")",
";",
"}",
"@",
"Data",
"public",
"static",
"class",
"UnitStartWord",
"<",
"C",
">",
"{",
"private",
"final",
"C",
"checkValue",
";",
"public",
"<",
"W",
">",
"UnitCaseWord",
"<",
"C",
">",
"case_",
"(",
"Function",
"<",
"C",
",",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
">",
"matcher",
",",
"Consumer",
"<",
"W",
">",
"action",
")",
"{",
"final",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
"data",
"=",
"FuncUtils",
".",
"runUnsafe",
"(",
"matcher",
",",
"checkValue",
")",
";",
"if",
"(",
"data",
".",
"getData1",
"(",
")",
")",
"{",
"FuncUtils",
".",
"runUnsafe",
"(",
"action",
",",
"data",
".",
"getData2",
"(",
")",
")",
";",
"return",
"UnitCaseWord",
".",
"RightCase",
".",
"unit",
"(",
"checkValue",
")",
";",
"}",
"return",
"UnitCaseWord",
".",
"LeftCase",
".",
"unit",
"(",
"checkValue",
")",
";",
"}",
"public",
"UnitCaseWord",
"<",
"C",
">",
"case_pd",
"(",
"Function",
"<",
"C",
",",
"Boolean",
">",
"matcher",
",",
"Consumer",
"<",
"C",
">",
"action",
")",
"{",
"return",
"case_",
"(",
"v",
"->",
"Tuple2",
".",
"<",
"Boolean",
",",
"C",
">",
"of",
"(",
"matcher",
".",
"apply",
"(",
"v",
")",
",",
"v",
")",
",",
"action",
")",
";",
"}",
"}",
"public",
"static",
"abstract",
"class",
"UnitCaseWord",
"<",
"C",
">",
"{",
"public",
"abstract",
"<",
"W",
">",
"UnitCaseWord",
"<",
"C",
">",
"case_",
"(",
"Function",
"<",
"C",
",",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
">",
"matcher",
",",
"Consumer",
"<",
"W",
">",
"action",
")",
";",
"public",
"abstract",
"void",
"else_",
"(",
"Consumer",
"<",
"C",
">",
"action",
")",
";",
"public",
"UnitCaseWord",
"<",
"C",
">",
"case_pd",
"(",
"Function",
"<",
"C",
",",
"Boolean",
">",
"matcher",
",",
"Consumer",
"<",
"C",
">",
"action",
")",
"{",
"return",
"this",
".",
"case_",
"(",
"v",
"->",
"Tuple2",
".",
"<",
"Boolean",
",",
"C",
">",
"of",
"(",
"matcher",
".",
"apply",
"(",
"v",
")",
",",
"v",
")",
",",
"action",
")",
";",
"}",
"@",
"Data",
"(",
"staticConstructor",
"=",
"\"",
"unit",
"\"",
")",
"@",
"EqualsAndHashCode",
"(",
"callSuper",
"=",
"false",
")",
"public",
"static",
"class",
"LeftCase",
"<",
"C",
">",
"extends",
"UnitCaseWord",
"<",
"C",
">",
"{",
"private",
"final",
"C",
"checkValue",
";",
"@",
"Override",
"public",
"<",
"W",
">",
"UnitCaseWord",
"<",
"C",
">",
"case_",
"(",
"Function",
"<",
"C",
",",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
">",
"matcher",
",",
"Consumer",
"<",
"W",
">",
"action",
")",
"{",
"final",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
"data",
"=",
"FuncUtils",
".",
"runUnsafe",
"(",
"matcher",
",",
"checkValue",
")",
";",
"if",
"(",
"data",
".",
"getData1",
"(",
")",
")",
"{",
"FuncUtils",
".",
"runUnsafe",
"(",
"action",
",",
"data",
".",
"getData2",
"(",
")",
")",
";",
"return",
"RightCase",
".",
"unit",
"(",
"checkValue",
")",
";",
"}",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"void",
"else_",
"(",
"Consumer",
"<",
"C",
">",
"action",
")",
"{",
"FuncUtils",
".",
"runUnsafe",
"(",
"action",
",",
"checkValue",
")",
";",
"}",
"}",
"@",
"Data",
"(",
"staticConstructor",
"=",
"\"",
"unit",
"\"",
")",
"@",
"EqualsAndHashCode",
"(",
"callSuper",
"=",
"false",
")",
"public",
"static",
"class",
"RightCase",
"<",
"C",
">",
"extends",
"UnitCaseWord",
"<",
"C",
">",
"{",
"private",
"final",
"C",
"checkValue",
";",
"@",
"Override",
"public",
"<",
"W",
">",
"UnitCaseWord",
"<",
"C",
">",
"case_",
"(",
"Function",
"<",
"C",
",",
"Tuple2",
"<",
"Boolean",
",",
"W",
">",
">",
"matcher",
",",
"Consumer",
"<",
"W",
">",
"action",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"void",
"else_",
"(",
"Consumer",
"<",
"C",
">",
"action",
")",
"{",
"}",
"}",
"}",
"}"
] | Created by yume on 16-8-15. | [
"Created",
"by",
"yume",
"on",
"16",
"-",
"8",
"-",
"15",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
072272757928221cef2d41e444e48a7c81eea486 | AltisourceLabs/ecloudmanager | tmrk-cloudapi/src/main/java/org/ecloudmanager/tmrk/cloudapi/model/ComputePoolMemoryUsageDetailType.java | [
"MIT"
] | Java | ComputePoolMemoryUsageDetailType | /**
* <p>Java class for ComputePoolMemoryUsageDetailType complex type.
* <p/>
* <p>The following schema fragment specifies the expected content contained within this class.
* <p/>
* <pre>
* <complexType name="ComputePoolMemoryUsageDetailType">
* <complexContent>
* <extension base="{}ResourceType">
* <sequence>
* <element name="Time" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="Value" type="{}ResourceUnitType" minOccurs="0"/>
* <element name="VirtualMachines" type="{}MemoryUsage_VirtualMachinesType" minOccurs="0"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*/ | Java class for ComputePoolMemoryUsageDetailType complex type.
The following schema fragment specifies the expected content contained within this class. | [
"Java",
"class",
"for",
"ComputePoolMemoryUsageDetailType",
"complex",
"type",
".",
"The",
"following",
"schema",
"fragment",
"specifies",
"the",
"expected",
"content",
"contained",
"within",
"this",
"class",
"."
] | @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ComputePoolMemoryUsageDetailType", propOrder = {
"time",
"value",
"virtualMachines"
})
public class ComputePoolMemoryUsageDetailType
extends ResourceType {
@XmlElement(name = "Time")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar time;
@XmlElementRef(name = "Value", type = JAXBElement.class, required = false)
protected JAXBElement<ResourceUnitType> value;
@XmlElementRef(name = "VirtualMachines", type = JAXBElement.class, required = false)
protected JAXBElement<MemoryUsageVirtualMachinesType> virtualMachines;
/**
* Gets the value of the time property.
*
* @return possible object is
* {@link XMLGregorianCalendar }
*/
public XMLGregorianCalendar getTime() {
return time;
}
/**
* Sets the value of the time property.
*
* @param value allowed object is
* {@link XMLGregorianCalendar }
*/
public void setTime(XMLGregorianCalendar value) {
this.time = value;
}
/**
* Gets the value of the value property.
*
* @return possible object is
* {@link JAXBElement }{@code <}{@link ResourceUnitType }{@code >}
*/
public JAXBElement<ResourceUnitType> getValue() {
return value;
}
/**
* Sets the value of the value property.
*
* @param value allowed object is
* {@link JAXBElement }{@code <}{@link ResourceUnitType }{@code >}
*/
public void setValue(JAXBElement<ResourceUnitType> value) {
this.value = value;
}
/**
* Gets the value of the virtualMachines property.
*
* @return possible object is
* {@link JAXBElement }{@code <}{@link MemoryUsageVirtualMachinesType }{@code >}
*/
public JAXBElement<MemoryUsageVirtualMachinesType> getVirtualMachines() {
return virtualMachines;
}
/**
* Sets the value of the virtualMachines property.
*
* @param value allowed object is
* {@link JAXBElement }{@code <}{@link MemoryUsageVirtualMachinesType }{@code >}
*/
public void setVirtualMachines(JAXBElement<MemoryUsageVirtualMachinesType> value) {
this.virtualMachines = value;
}
} | [
"@",
"XmlAccessorType",
"(",
"XmlAccessType",
".",
"FIELD",
")",
"@",
"XmlType",
"(",
"name",
"=",
"\"",
"ComputePoolMemoryUsageDetailType",
"\"",
",",
"propOrder",
"=",
"{",
"\"",
"time",
"\"",
",",
"\"",
"value",
"\"",
",",
"\"",
"virtualMachines",
"\"",
"}",
")",
"public",
"class",
"ComputePoolMemoryUsageDetailType",
"extends",
"ResourceType",
"{",
"@",
"XmlElement",
"(",
"name",
"=",
"\"",
"Time",
"\"",
")",
"@",
"XmlSchemaType",
"(",
"name",
"=",
"\"",
"dateTime",
"\"",
")",
"protected",
"XMLGregorianCalendar",
"time",
";",
"@",
"XmlElementRef",
"(",
"name",
"=",
"\"",
"Value",
"\"",
",",
"type",
"=",
"JAXBElement",
".",
"class",
",",
"required",
"=",
"false",
")",
"protected",
"JAXBElement",
"<",
"ResourceUnitType",
">",
"value",
";",
"@",
"XmlElementRef",
"(",
"name",
"=",
"\"",
"VirtualMachines",
"\"",
",",
"type",
"=",
"JAXBElement",
".",
"class",
",",
"required",
"=",
"false",
")",
"protected",
"JAXBElement",
"<",
"MemoryUsageVirtualMachinesType",
">",
"virtualMachines",
";",
"/**\n * Gets the value of the time property.\n *\n * @return possible object is\n * {@link XMLGregorianCalendar }\n */",
"public",
"XMLGregorianCalendar",
"getTime",
"(",
")",
"{",
"return",
"time",
";",
"}",
"/**\n * Sets the value of the time property.\n *\n * @param value allowed object is\n * {@link XMLGregorianCalendar }\n */",
"public",
"void",
"setTime",
"(",
"XMLGregorianCalendar",
"value",
")",
"{",
"this",
".",
"time",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the value property.\n *\n * @return possible object is\n * {@link JAXBElement }{@code <}{@link ResourceUnitType }{@code >}\n */",
"public",
"JAXBElement",
"<",
"ResourceUnitType",
">",
"getValue",
"(",
")",
"{",
"return",
"value",
";",
"}",
"/**\n * Sets the value of the value property.\n *\n * @param value allowed object is\n * {@link JAXBElement }{@code <}{@link ResourceUnitType }{@code >}\n */",
"public",
"void",
"setValue",
"(",
"JAXBElement",
"<",
"ResourceUnitType",
">",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the virtualMachines property.\n *\n * @return possible object is\n * {@link JAXBElement }{@code <}{@link MemoryUsageVirtualMachinesType }{@code >}\n */",
"public",
"JAXBElement",
"<",
"MemoryUsageVirtualMachinesType",
">",
"getVirtualMachines",
"(",
")",
"{",
"return",
"virtualMachines",
";",
"}",
"/**\n * Sets the value of the virtualMachines property.\n *\n * @param value allowed object is\n * {@link JAXBElement }{@code <}{@link MemoryUsageVirtualMachinesType }{@code >}\n */",
"public",
"void",
"setVirtualMachines",
"(",
"JAXBElement",
"<",
"MemoryUsageVirtualMachinesType",
">",
"value",
")",
"{",
"this",
".",
"virtualMachines",
"=",
"value",
";",
"}",
"}"
] | <p>Java class for ComputePoolMemoryUsageDetailType complex type. | [
"<p",
">",
"Java",
"class",
"for",
"ComputePoolMemoryUsageDetailType",
"complex",
"type",
"."
] | [] | [
{
"param": "ResourceType",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ResourceType",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0726eb4a85562fddbb0dff44b5e2b88e044a9da5 | alexandrezia/midpoint-studio | studio-idea-plugin/src/main/java/com/evolveum/midpoint/studio/impl/client/LocalizationServiceImpl.java | [
"Apache-2.0"
] | Java | LocalizationServiceImpl | /**
* Created by Viliam Repan (lazyman).
*/ | Created by Viliam Repan (lazyman). | [
"Created",
"by",
"Viliam",
"Repan",
"(",
"lazyman",
")",
"."
] | public class LocalizationServiceImpl implements LocalizationService {
@Override
public String translate(LocalizableMessage msg, Locale locale, String defaultMessage) {
String translated = translate(msg, locale);
return translated != null ? translated : defaultMessage;
}
@Override
public String translate(PolyString polyString, Locale locale, boolean allowOrig) {
String def = allowOrig ? polyString.getOrig() : null;
return translate(polyString.getOrig(), new Object[]{}, locale, def);
}
@Override
public Locale getDefaultLocale() {
return Locale.getDefault();
}
@Override
public String translate(String key, Object[] params, Locale locale) {
return translate(key, params, locale, null);
}
@Override
public String translate(String key, Object[] params, Locale locale, String defaultMessage) {
if (defaultMessage != null) {
return defaultMessage;
}
return key;
}
@Override
public String translate(LocalizableMessage msg, Locale locale) {
return msg != null ? msg.getFallbackMessage() : null;
}
@Override
public <T extends CommonException> T translate(T e) {
return e;
}
} | [
"public",
"class",
"LocalizationServiceImpl",
"implements",
"LocalizationService",
"{",
"@",
"Override",
"public",
"String",
"translate",
"(",
"LocalizableMessage",
"msg",
",",
"Locale",
"locale",
",",
"String",
"defaultMessage",
")",
"{",
"String",
"translated",
"=",
"translate",
"(",
"msg",
",",
"locale",
")",
";",
"return",
"translated",
"!=",
"null",
"?",
"translated",
":",
"defaultMessage",
";",
"}",
"@",
"Override",
"public",
"String",
"translate",
"(",
"PolyString",
"polyString",
",",
"Locale",
"locale",
",",
"boolean",
"allowOrig",
")",
"{",
"String",
"def",
"=",
"allowOrig",
"?",
"polyString",
".",
"getOrig",
"(",
")",
":",
"null",
";",
"return",
"translate",
"(",
"polyString",
".",
"getOrig",
"(",
")",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
",",
"locale",
",",
"def",
")",
";",
"}",
"@",
"Override",
"public",
"Locale",
"getDefaultLocale",
"(",
")",
"{",
"return",
"Locale",
".",
"getDefault",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"translate",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"params",
",",
"Locale",
"locale",
")",
"{",
"return",
"translate",
"(",
"key",
",",
"params",
",",
"locale",
",",
"null",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"translate",
"(",
"String",
"key",
",",
"Object",
"[",
"]",
"params",
",",
"Locale",
"locale",
",",
"String",
"defaultMessage",
")",
"{",
"if",
"(",
"defaultMessage",
"!=",
"null",
")",
"{",
"return",
"defaultMessage",
";",
"}",
"return",
"key",
";",
"}",
"@",
"Override",
"public",
"String",
"translate",
"(",
"LocalizableMessage",
"msg",
",",
"Locale",
"locale",
")",
"{",
"return",
"msg",
"!=",
"null",
"?",
"msg",
".",
"getFallbackMessage",
"(",
")",
":",
"null",
";",
"}",
"@",
"Override",
"public",
"<",
"T",
"extends",
"CommonException",
">",
"T",
"translate",
"(",
"T",
"e",
")",
"{",
"return",
"e",
";",
"}",
"}"
] | Created by Viliam Repan (lazyman). | [
"Created",
"by",
"Viliam",
"Repan",
"(",
"lazyman",
")",
"."
] | [] | [
{
"param": "LocalizationService",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "LocalizationService",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07273c6c7482faa8f365dcffce0ec36c6c54d11a | stephentetley/sheetreader | src-java/flixspt/sheetio/POIRowIterator.java | [
"Apache-2.0"
] | Java | POIRowIterator | /* Note - this class iterates the rows of org.apache.poi.ss.usermodel.Sheet.
* This is only because delegating to Java to iterating rows was found to
* be a reliable method of reading up to the end of the sheet. Trying to
* find the end with a call to `getLastRowNum` in Flix code seemed error
* prone and was abandoned as a strategy.
*
* As far as I am aware the whole Sheet is read into memory and it
* is streamed while in memory - this module does not implement
* streaming as a way of achieving low memory usage.
*/ | this class iterates the rows of org.apache.poi.ss.usermodel.Sheet.
This is only because delegating to Java to iterating rows was found to
be a reliable method of reading up to the end of the sheet. Trying to
find the end with a call to `getLastRowNum` in Flix code seemed error
prone and was abandoned as a strategy.
As far as I am aware the whole Sheet is read into memory and it
is streamed while in memory - this module does not implement
streaming as a way of achieving low memory usage. | [
"this",
"class",
"iterates",
"the",
"rows",
"of",
"org",
".",
"apache",
".",
"poi",
".",
"ss",
".",
"usermodel",
".",
"Sheet",
".",
"This",
"is",
"only",
"because",
"delegating",
"to",
"Java",
"to",
"iterating",
"rows",
"was",
"found",
"to",
"be",
"a",
"reliable",
"method",
"of",
"reading",
"up",
"to",
"the",
"end",
"of",
"the",
"sheet",
".",
"Trying",
"to",
"find",
"the",
"end",
"with",
"a",
"call",
"to",
"`",
"getLastRowNum",
"`",
"in",
"Flix",
"code",
"seemed",
"error",
"prone",
"and",
"was",
"abandoned",
"as",
"a",
"strategy",
".",
"As",
"far",
"as",
"I",
"am",
"aware",
"the",
"whole",
"Sheet",
"is",
"read",
"into",
"memory",
"and",
"it",
"is",
"streamed",
"while",
"in",
"memory",
"-",
"this",
"module",
"does",
"not",
"implement",
"streaming",
"as",
"a",
"way",
"of",
"achieving",
"low",
"memory",
"usage",
"."
] | public class POIRowIterator {
private Iterator<Row> iter;
public POIRowIterator(Sheet sheet) throws Exception {
this.iter = sheet.rowIterator();
}
public boolean hasNext() {
return this.iter.hasNext();
}
public Row next() throws Exception { return this.iter.next(); }
} | [
"public",
"class",
"POIRowIterator",
"{",
"private",
"Iterator",
"<",
"Row",
">",
"iter",
";",
"public",
"POIRowIterator",
"(",
"Sheet",
"sheet",
")",
"throws",
"Exception",
"{",
"this",
".",
"iter",
"=",
"sheet",
".",
"rowIterator",
"(",
")",
";",
"}",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"this",
".",
"iter",
".",
"hasNext",
"(",
")",
";",
"}",
"public",
"Row",
"next",
"(",
")",
"throws",
"Exception",
"{",
"return",
"this",
".",
"iter",
".",
"next",
"(",
")",
";",
"}",
"}"
] | Note - this class iterates the rows of org.apache.poi.ss.usermodel.Sheet. | [
"Note",
"-",
"this",
"class",
"iterates",
"the",
"rows",
"of",
"org",
".",
"apache",
".",
"poi",
".",
"ss",
".",
"usermodel",
".",
"Sheet",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0727b743fce6bc7b8391ec196fc03b37dda54eb3 | javiosyc/flickster | app/src/main/java/javio/com/flickster/models/Movie.java | [
"Apache-2.0"
] | Java | Movie | /**
* Created by javiosyc on 2017/2/14.
*/ | Created by javiosyc on 2017/2/14. | [
"Created",
"by",
"javiosyc",
"on",
"2017",
"/",
"2",
"/",
"14",
"."
] | public class Movie implements Serializable {
private final Long id;
private final String posterPath;
private final String originalTitle;
private final String overview;
private final String backDropPath;
private final String releaseDate;
private final Double voteAverage;
public Movie(JSONObject jsonObject) throws JSONException {
this.id = jsonObject.getLong("id");
this.posterPath = jsonObject.getString("poster_path");
this.originalTitle = jsonObject.getString("original_title");
this.overview = jsonObject.getString("overview");
this.backDropPath = jsonObject.getString("backdrop_path");
this.voteAverage = jsonObject.getDouble("vote_average");
this.releaseDate = jsonObject.getString("release_date");
}
protected Movie(Parcel in) {
this.id = in.readLong();
this.posterPath = in.readString();
this.originalTitle = in.readString();
this.overview = in.readString();
this.backDropPath = in.readString();
this.releaseDate = in.readString();
this.voteAverage = in.readDouble();
}
public String getPosterPath() {
return MovieUtils.getPosterUrl(posterPath);
}
public String getBackDropPath() {
return MovieUtils.getBackDropUrl(posterPath);
}
public String getReleaseDate() {
return releaseDate;
}
public Double getVoteAverage() {
return voteAverage;
}
public String getOriginalTitle() {
return originalTitle;
}
public String getOverview() {
return overview;
}
public Long getId() {
return id;
}
@Override
public String toString() {
return "Movie{" +
"id=" + id +
", posterPath='" + posterPath + '\'' +
", originalTitle='" + originalTitle + '\'' +
", overview='" + overview + '\'' +
", backDropPath='" + backDropPath + '\'' +
", releaseDate='" + releaseDate + '\'' +
", voteAverage=" + voteAverage +
'}';
}
} | [
"public",
"class",
"Movie",
"implements",
"Serializable",
"{",
"private",
"final",
"Long",
"id",
";",
"private",
"final",
"String",
"posterPath",
";",
"private",
"final",
"String",
"originalTitle",
";",
"private",
"final",
"String",
"overview",
";",
"private",
"final",
"String",
"backDropPath",
";",
"private",
"final",
"String",
"releaseDate",
";",
"private",
"final",
"Double",
"voteAverage",
";",
"public",
"Movie",
"(",
"JSONObject",
"jsonObject",
")",
"throws",
"JSONException",
"{",
"this",
".",
"id",
"=",
"jsonObject",
".",
"getLong",
"(",
"\"",
"id",
"\"",
")",
";",
"this",
".",
"posterPath",
"=",
"jsonObject",
".",
"getString",
"(",
"\"",
"poster_path",
"\"",
")",
";",
"this",
".",
"originalTitle",
"=",
"jsonObject",
".",
"getString",
"(",
"\"",
"original_title",
"\"",
")",
";",
"this",
".",
"overview",
"=",
"jsonObject",
".",
"getString",
"(",
"\"",
"overview",
"\"",
")",
";",
"this",
".",
"backDropPath",
"=",
"jsonObject",
".",
"getString",
"(",
"\"",
"backdrop_path",
"\"",
")",
";",
"this",
".",
"voteAverage",
"=",
"jsonObject",
".",
"getDouble",
"(",
"\"",
"vote_average",
"\"",
")",
";",
"this",
".",
"releaseDate",
"=",
"jsonObject",
".",
"getString",
"(",
"\"",
"release_date",
"\"",
")",
";",
"}",
"protected",
"Movie",
"(",
"Parcel",
"in",
")",
"{",
"this",
".",
"id",
"=",
"in",
".",
"readLong",
"(",
")",
";",
"this",
".",
"posterPath",
"=",
"in",
".",
"readString",
"(",
")",
";",
"this",
".",
"originalTitle",
"=",
"in",
".",
"readString",
"(",
")",
";",
"this",
".",
"overview",
"=",
"in",
".",
"readString",
"(",
")",
";",
"this",
".",
"backDropPath",
"=",
"in",
".",
"readString",
"(",
")",
";",
"this",
".",
"releaseDate",
"=",
"in",
".",
"readString",
"(",
")",
";",
"this",
".",
"voteAverage",
"=",
"in",
".",
"readDouble",
"(",
")",
";",
"}",
"public",
"String",
"getPosterPath",
"(",
")",
"{",
"return",
"MovieUtils",
".",
"getPosterUrl",
"(",
"posterPath",
")",
";",
"}",
"public",
"String",
"getBackDropPath",
"(",
")",
"{",
"return",
"MovieUtils",
".",
"getBackDropUrl",
"(",
"posterPath",
")",
";",
"}",
"public",
"String",
"getReleaseDate",
"(",
")",
"{",
"return",
"releaseDate",
";",
"}",
"public",
"Double",
"getVoteAverage",
"(",
")",
"{",
"return",
"voteAverage",
";",
"}",
"public",
"String",
"getOriginalTitle",
"(",
")",
"{",
"return",
"originalTitle",
";",
"}",
"public",
"String",
"getOverview",
"(",
")",
"{",
"return",
"overview",
";",
"}",
"public",
"Long",
"getId",
"(",
")",
"{",
"return",
"id",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"Movie{",
"\"",
"+",
"\"",
"id=",
"\"",
"+",
"id",
"+",
"\"",
", posterPath='",
"\"",
"+",
"posterPath",
"+",
"'\\''",
"+",
"\"",
", originalTitle='",
"\"",
"+",
"originalTitle",
"+",
"'\\''",
"+",
"\"",
", overview='",
"\"",
"+",
"overview",
"+",
"'\\''",
"+",
"\"",
", backDropPath='",
"\"",
"+",
"backDropPath",
"+",
"'\\''",
"+",
"\"",
", releaseDate='",
"\"",
"+",
"releaseDate",
"+",
"'\\''",
"+",
"\"",
", voteAverage=",
"\"",
"+",
"voteAverage",
"+",
"'}'",
";",
"}",
"}"
] | Created by javiosyc on 2017/2/14. | [
"Created",
"by",
"javiosyc",
"on",
"2017",
"/",
"2",
"/",
"14",
"."
] | [] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072c620761e895389340b4ba62c9bf941aaf467c | error-404-unlam/jrpg-2017b-cliente-UNI | src/main/java/edu/unlam/wome/frames/MenuRegistro.java | [
"MIT"
] | Java | MenuRegistro | /**
* Clase encargada del registro del usuario.
* @author Miguel
*/ | Clase encargada del registro del usuario.
@author Miguel | [
"Clase",
"encargada",
"del",
"registro",
"del",
"usuario",
".",
"@author",
"Miguel"
] | public class MenuRegistro extends JFrame {
private JTextField txtUsuario;
private JPasswordField pwPassword;
//USUARIO
private static final int POS_X_USER = 199;
private static final int POS_Y_USER = 69;
private static final int ANCHO_USER = 118;
private static final int ALTO_USER = 20;
private static final int COLUMNS_USER = 10;
//PASSWORD
private static final int POS_X_PASSWORD = 199;
private static final int POS_Y_PASSWORD = 120;
private static final int ANCHO_PASSWORD = 118;
private static final int ALTO_PASSWORD = 20;
//BACKGROUND
private static final int POS_X_BACKGROUND = 0;
private static final int POS_Y_BACKGROUND = 0;
private static final int ANCHO_BACKGROUND = 444;
private static final int ALTO_BACKGROUND = 271;
//LABEL REGISTRARSE
private static final int POS_X_LABEL_REGISTRARSE = 186;
private static final int POS_Y_LABEL_REGISTRARSE = 182;
private static final int ANCHO_LABEL_REGISTRARSE = 82;
private static final int ALTO_LABEL_REGISTRARSE = 23;
private static final int TAM_FUENTE_LABEL_REGISTRARSE = 15;
//BOTON REGISTRARSE
private static final int POS_X_BOTON_REGISTRARSE = 143;
private static final int POS_Y_BOTON_REGISTRARSE = 182;
private static final int ANCHO_BOTON_REGISTRARSE = 153;
private static final int ALTO_BOTON_REGISTRARSE = 23;
//VENTANA
private static final int POS_X_VENTANA = 100;
private static final int POS_Y_VENTANA = 100;
private static final int ANCHO_VENTANA = 450;
private static final int ALTO_VENTANA = 300;
//LAYERED PANE
private static final int POS_X_LAYERED_PANE = 0;
private static final int POS_Y_LAYERED_PANE = 0;
private static final int ANCHO_LAYERED_PANE = 444;
private static final int ALTO_LAYERED_PANE = 271;
//LABEL USUARIO
private static final int POS_X_LABEL_USUARIO = 113;
private static final int POS_Y_LABEL_USUARIO = 70;
private static final int ANCHO_LABEL_USUARIO = 57;
private static final int ALTO_LABEL_USUARIO = 19;
private static final int TAM_FUENTE_LABEL_USUARIO = 15;
//LABEL PASSWORD
private static final int POS_X_LABEL_PASSWORD = 113;
private static final int POS_Y_LABEL_PASSWORD = 121;
private static final int ANCHO_LABEL_PASSWORD = 65;
private static final int ALTO_LABEL_PASSWORD = 17;
private static final int TAM_FUENTE_LABEL_PASSWORD = 15;
/**
* Constructor Menu Registro
* @param cliente Cliente actual
*/
public MenuRegistro(final Cliente cliente) {
// Se inicializa ícono y cursor
setIconImage(Toolkit.getDefaultToolkit()
.getImage("src/main/java/edu/unlam/wome/frames/IconoWome.png"));
setCursor(
Toolkit.getDefaultToolkit().createCustomCursor(
new ImageIcon(
MenuJugar.class.getResource("/cursor.png")).
getImage(), new Point(0, 0), "custom cursor"));
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(final WindowEvent e) {
synchronized (cliente) {
cliente.setAccion(Comando.SALIR);
cliente.notify();
}
dispose();
}
});
setTitle("WOME - Registrarse");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setResizable(false);
setBounds(
POS_X_VENTANA,
POS_Y_VENTANA,
ANCHO_VENTANA,
ALTO_VENTANA);
getContentPane().setLayout(null);
setLocationRelativeTo(null);
JLayeredPane layeredPane = new JLayeredPane();
layeredPane.setBounds(
POS_X_LAYERED_PANE,
POS_Y_LAYERED_PANE,
ANCHO_LAYERED_PANE,
ALTO_LAYERED_PANE);
getContentPane().add(layeredPane);
JLabel lblUsuario = new JLabel("Usuario");
lblUsuario.setBounds(
POS_X_LABEL_USUARIO,
POS_Y_LABEL_USUARIO,
ANCHO_LABEL_USUARIO,
ALTO_LABEL_USUARIO);
layeredPane.add(lblUsuario, new Integer(1));
lblUsuario.setForeground(Color.WHITE);
lblUsuario.setFont(new Font(
"Tahoma",
Font.PLAIN,
TAM_FUENTE_LABEL_USUARIO));
JLabel lblPassword = new JLabel("Password");
lblPassword.setBounds(
POS_X_LABEL_PASSWORD,
POS_Y_LABEL_PASSWORD,
ANCHO_LABEL_PASSWORD,
ALTO_LABEL_PASSWORD);
layeredPane.add(lblPassword, new Integer(1));
lblPassword.setForeground(Color.WHITE);
lblPassword.setFont(new Font(
"Tahoma",
Font.PLAIN,
TAM_FUENTE_LABEL_PASSWORD));
JLabel lblRegistrarse = new JLabel("Registrarse");
lblRegistrarse.setBounds(
POS_X_LABEL_REGISTRARSE,
POS_Y_LABEL_REGISTRARSE,
ANCHO_LABEL_REGISTRARSE,
ALTO_LABEL_REGISTRARSE);
layeredPane.add(lblRegistrarse, new Integer(2));
lblRegistrarse.setForeground(Color.WHITE);
lblRegistrarse.setFont(new Font(
"Tahoma", Font.PLAIN,
TAM_FUENTE_LABEL_REGISTRARSE));
JButton btnRegistrarse = new JButton("");
btnRegistrarse.setBounds(
POS_X_BOTON_REGISTRARSE,
POS_Y_BOTON_REGISTRARSE,
ANCHO_BOTON_REGISTRARSE,
ALTO_BOTON_REGISTRARSE);
layeredPane.add(btnRegistrarse, new Integer(1));
btnRegistrarse.setFocusable(false);
btnRegistrarse.setIcon(new ImageIcon(MenuRegistro.class
.getResource("/edu/unlam/wome/frames/BotonMenu.png")));
pwPassword = new JPasswordField();
pwPassword.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
logIn(cliente);
dispose();
}
});
pwPassword.setBounds(
POS_X_PASSWORD,
POS_Y_PASSWORD,
ANCHO_PASSWORD,
ALTO_PASSWORD);
layeredPane.add(pwPassword, new Integer(1));
txtUsuario = new JTextField();
txtUsuario.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
logIn(cliente);
dispose();
}
});
txtUsuario.setBounds(
POS_X_USER,
POS_Y_USER,
ANCHO_USER,
ALTO_USER);
layeredPane.add(txtUsuario, new Integer(1));
txtUsuario.setColumns(COLUMNS_USER);
JLabel labelBackground = new JLabel("");
labelBackground.setBounds(
POS_X_BACKGROUND,
POS_Y_BACKGROUND,
ANCHO_BACKGROUND,
ALTO_BACKGROUND);
layeredPane.add(labelBackground, new Integer(0));
labelBackground.setIcon(new ImageIcon(MenuRegistro.class
.getResource("/edu/unlam/wome/frames/menuBackground.jpg")));
btnRegistrarse.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
logIn(cliente);
dispose();
}
});
}
/**
* Devuelve el campo del usuario
* @return JTextField
*/
public JTextField gettxtUsuario() {
return txtUsuario;
}
/**
* Setea el usuario
* @param usuario campo de texto del usuario
*/
public void settxtUsuario(final JTextField usuario) {
this.txtUsuario = usuario;
}
/**
* Devuelve la contraseña
* @return JPasswordField
*/
public JPasswordField getPasswordField() {
return pwPassword;
}
/**
* Setea la contraseña del usuario
* @param password campo de contraseña
*/
public void setPasswordField(final JPasswordField password) {
this.pwPassword = password;
}
/**
* Setea el usuario y la contraseña
* @param cliente cliente actual
*/
private void logIn(final Cliente cliente) {
synchronized (cliente) {
cliente.getPaqueteUsuario().setUsername(txtUsuario.getText());
cliente.getPaqueteUsuario().setPassword(String.valueOf(pwPassword.getPassword()));
cliente.setAccion(Comando.REGISTRO);
cliente.notify();
}
}
} | [
"public",
"class",
"MenuRegistro",
"extends",
"JFrame",
"{",
"private",
"JTextField",
"txtUsuario",
";",
"private",
"JPasswordField",
"pwPassword",
";",
"private",
"static",
"final",
"int",
"POS_X_USER",
"=",
"199",
";",
"private",
"static",
"final",
"int",
"POS_Y_USER",
"=",
"69",
";",
"private",
"static",
"final",
"int",
"ANCHO_USER",
"=",
"118",
";",
"private",
"static",
"final",
"int",
"ALTO_USER",
"=",
"20",
";",
"private",
"static",
"final",
"int",
"COLUMNS_USER",
"=",
"10",
";",
"private",
"static",
"final",
"int",
"POS_X_PASSWORD",
"=",
"199",
";",
"private",
"static",
"final",
"int",
"POS_Y_PASSWORD",
"=",
"120",
";",
"private",
"static",
"final",
"int",
"ANCHO_PASSWORD",
"=",
"118",
";",
"private",
"static",
"final",
"int",
"ALTO_PASSWORD",
"=",
"20",
";",
"private",
"static",
"final",
"int",
"POS_X_BACKGROUND",
"=",
"0",
";",
"private",
"static",
"final",
"int",
"POS_Y_BACKGROUND",
"=",
"0",
";",
"private",
"static",
"final",
"int",
"ANCHO_BACKGROUND",
"=",
"444",
";",
"private",
"static",
"final",
"int",
"ALTO_BACKGROUND",
"=",
"271",
";",
"private",
"static",
"final",
"int",
"POS_X_LABEL_REGISTRARSE",
"=",
"186",
";",
"private",
"static",
"final",
"int",
"POS_Y_LABEL_REGISTRARSE",
"=",
"182",
";",
"private",
"static",
"final",
"int",
"ANCHO_LABEL_REGISTRARSE",
"=",
"82",
";",
"private",
"static",
"final",
"int",
"ALTO_LABEL_REGISTRARSE",
"=",
"23",
";",
"private",
"static",
"final",
"int",
"TAM_FUENTE_LABEL_REGISTRARSE",
"=",
"15",
";",
"private",
"static",
"final",
"int",
"POS_X_BOTON_REGISTRARSE",
"=",
"143",
";",
"private",
"static",
"final",
"int",
"POS_Y_BOTON_REGISTRARSE",
"=",
"182",
";",
"private",
"static",
"final",
"int",
"ANCHO_BOTON_REGISTRARSE",
"=",
"153",
";",
"private",
"static",
"final",
"int",
"ALTO_BOTON_REGISTRARSE",
"=",
"23",
";",
"private",
"static",
"final",
"int",
"POS_X_VENTANA",
"=",
"100",
";",
"private",
"static",
"final",
"int",
"POS_Y_VENTANA",
"=",
"100",
";",
"private",
"static",
"final",
"int",
"ANCHO_VENTANA",
"=",
"450",
";",
"private",
"static",
"final",
"int",
"ALTO_VENTANA",
"=",
"300",
";",
"private",
"static",
"final",
"int",
"POS_X_LAYERED_PANE",
"=",
"0",
";",
"private",
"static",
"final",
"int",
"POS_Y_LAYERED_PANE",
"=",
"0",
";",
"private",
"static",
"final",
"int",
"ANCHO_LAYERED_PANE",
"=",
"444",
";",
"private",
"static",
"final",
"int",
"ALTO_LAYERED_PANE",
"=",
"271",
";",
"private",
"static",
"final",
"int",
"POS_X_LABEL_USUARIO",
"=",
"113",
";",
"private",
"static",
"final",
"int",
"POS_Y_LABEL_USUARIO",
"=",
"70",
";",
"private",
"static",
"final",
"int",
"ANCHO_LABEL_USUARIO",
"=",
"57",
";",
"private",
"static",
"final",
"int",
"ALTO_LABEL_USUARIO",
"=",
"19",
";",
"private",
"static",
"final",
"int",
"TAM_FUENTE_LABEL_USUARIO",
"=",
"15",
";",
"private",
"static",
"final",
"int",
"POS_X_LABEL_PASSWORD",
"=",
"113",
";",
"private",
"static",
"final",
"int",
"POS_Y_LABEL_PASSWORD",
"=",
"121",
";",
"private",
"static",
"final",
"int",
"ANCHO_LABEL_PASSWORD",
"=",
"65",
";",
"private",
"static",
"final",
"int",
"ALTO_LABEL_PASSWORD",
"=",
"17",
";",
"private",
"static",
"final",
"int",
"TAM_FUENTE_LABEL_PASSWORD",
"=",
"15",
";",
"/**\n\t * Constructor Menu Registro\n\t * @param cliente Cliente actual\n\t */",
"public",
"MenuRegistro",
"(",
"final",
"Cliente",
"cliente",
")",
"{",
"setIconImage",
"(",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"getImage",
"(",
"\"",
"src/main/java/edu/unlam/wome/frames/IconoWome.png",
"\"",
")",
")",
";",
"setCursor",
"(",
"Toolkit",
".",
"getDefaultToolkit",
"(",
")",
".",
"createCustomCursor",
"(",
"new",
"ImageIcon",
"(",
"MenuJugar",
".",
"class",
".",
"getResource",
"(",
"\"",
"/cursor.png",
"\"",
")",
")",
".",
"getImage",
"(",
")",
",",
"new",
"Point",
"(",
"0",
",",
"0",
")",
",",
"\"",
"custom cursor",
"\"",
")",
")",
";",
"addWindowListener",
"(",
"new",
"WindowAdapter",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"windowClosing",
"(",
"final",
"WindowEvent",
"e",
")",
"{",
"synchronized",
"(",
"cliente",
")",
"{",
"cliente",
".",
"setAccion",
"(",
"Comando",
".",
"SALIR",
")",
";",
"cliente",
".",
"notify",
"(",
")",
";",
"}",
"dispose",
"(",
")",
";",
"}",
"}",
")",
";",
"setTitle",
"(",
"\"",
"WOME - Registrarse",
"\"",
")",
";",
"setDefaultCloseOperation",
"(",
"JFrame",
".",
"EXIT_ON_CLOSE",
")",
";",
"setResizable",
"(",
"false",
")",
";",
"setBounds",
"(",
"POS_X_VENTANA",
",",
"POS_Y_VENTANA",
",",
"ANCHO_VENTANA",
",",
"ALTO_VENTANA",
")",
";",
"getContentPane",
"(",
")",
".",
"setLayout",
"(",
"null",
")",
";",
"setLocationRelativeTo",
"(",
"null",
")",
";",
"JLayeredPane",
"layeredPane",
"=",
"new",
"JLayeredPane",
"(",
")",
";",
"layeredPane",
".",
"setBounds",
"(",
"POS_X_LAYERED_PANE",
",",
"POS_Y_LAYERED_PANE",
",",
"ANCHO_LAYERED_PANE",
",",
"ALTO_LAYERED_PANE",
")",
";",
"getContentPane",
"(",
")",
".",
"add",
"(",
"layeredPane",
")",
";",
"JLabel",
"lblUsuario",
"=",
"new",
"JLabel",
"(",
"\"",
"Usuario",
"\"",
")",
";",
"lblUsuario",
".",
"setBounds",
"(",
"POS_X_LABEL_USUARIO",
",",
"POS_Y_LABEL_USUARIO",
",",
"ANCHO_LABEL_USUARIO",
",",
"ALTO_LABEL_USUARIO",
")",
";",
"layeredPane",
".",
"add",
"(",
"lblUsuario",
",",
"new",
"Integer",
"(",
"1",
")",
")",
";",
"lblUsuario",
".",
"setForeground",
"(",
"Color",
".",
"WHITE",
")",
";",
"lblUsuario",
".",
"setFont",
"(",
"new",
"Font",
"(",
"\"",
"Tahoma",
"\"",
",",
"Font",
".",
"PLAIN",
",",
"TAM_FUENTE_LABEL_USUARIO",
")",
")",
";",
"JLabel",
"lblPassword",
"=",
"new",
"JLabel",
"(",
"\"",
"Password",
"\"",
")",
";",
"lblPassword",
".",
"setBounds",
"(",
"POS_X_LABEL_PASSWORD",
",",
"POS_Y_LABEL_PASSWORD",
",",
"ANCHO_LABEL_PASSWORD",
",",
"ALTO_LABEL_PASSWORD",
")",
";",
"layeredPane",
".",
"add",
"(",
"lblPassword",
",",
"new",
"Integer",
"(",
"1",
")",
")",
";",
"lblPassword",
".",
"setForeground",
"(",
"Color",
".",
"WHITE",
")",
";",
"lblPassword",
".",
"setFont",
"(",
"new",
"Font",
"(",
"\"",
"Tahoma",
"\"",
",",
"Font",
".",
"PLAIN",
",",
"TAM_FUENTE_LABEL_PASSWORD",
")",
")",
";",
"JLabel",
"lblRegistrarse",
"=",
"new",
"JLabel",
"(",
"\"",
"Registrarse",
"\"",
")",
";",
"lblRegistrarse",
".",
"setBounds",
"(",
"POS_X_LABEL_REGISTRARSE",
",",
"POS_Y_LABEL_REGISTRARSE",
",",
"ANCHO_LABEL_REGISTRARSE",
",",
"ALTO_LABEL_REGISTRARSE",
")",
";",
"layeredPane",
".",
"add",
"(",
"lblRegistrarse",
",",
"new",
"Integer",
"(",
"2",
")",
")",
";",
"lblRegistrarse",
".",
"setForeground",
"(",
"Color",
".",
"WHITE",
")",
";",
"lblRegistrarse",
".",
"setFont",
"(",
"new",
"Font",
"(",
"\"",
"Tahoma",
"\"",
",",
"Font",
".",
"PLAIN",
",",
"TAM_FUENTE_LABEL_REGISTRARSE",
")",
")",
";",
"JButton",
"btnRegistrarse",
"=",
"new",
"JButton",
"(",
"\"",
"\"",
")",
";",
"btnRegistrarse",
".",
"setBounds",
"(",
"POS_X_BOTON_REGISTRARSE",
",",
"POS_Y_BOTON_REGISTRARSE",
",",
"ANCHO_BOTON_REGISTRARSE",
",",
"ALTO_BOTON_REGISTRARSE",
")",
";",
"layeredPane",
".",
"add",
"(",
"btnRegistrarse",
",",
"new",
"Integer",
"(",
"1",
")",
")",
";",
"btnRegistrarse",
".",
"setFocusable",
"(",
"false",
")",
";",
"btnRegistrarse",
".",
"setIcon",
"(",
"new",
"ImageIcon",
"(",
"MenuRegistro",
".",
"class",
".",
"getResource",
"(",
"\"",
"/edu/unlam/wome/frames/BotonMenu.png",
"\"",
")",
")",
")",
";",
"pwPassword",
"=",
"new",
"JPasswordField",
"(",
")",
";",
"pwPassword",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"final",
"ActionEvent",
"e",
")",
"{",
"logIn",
"(",
"cliente",
")",
";",
"dispose",
"(",
")",
";",
"}",
"}",
")",
";",
"pwPassword",
".",
"setBounds",
"(",
"POS_X_PASSWORD",
",",
"POS_Y_PASSWORD",
",",
"ANCHO_PASSWORD",
",",
"ALTO_PASSWORD",
")",
";",
"layeredPane",
".",
"add",
"(",
"pwPassword",
",",
"new",
"Integer",
"(",
"1",
")",
")",
";",
"txtUsuario",
"=",
"new",
"JTextField",
"(",
")",
";",
"txtUsuario",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"final",
"ActionEvent",
"e",
")",
"{",
"logIn",
"(",
"cliente",
")",
";",
"dispose",
"(",
")",
";",
"}",
"}",
")",
";",
"txtUsuario",
".",
"setBounds",
"(",
"POS_X_USER",
",",
"POS_Y_USER",
",",
"ANCHO_USER",
",",
"ALTO_USER",
")",
";",
"layeredPane",
".",
"add",
"(",
"txtUsuario",
",",
"new",
"Integer",
"(",
"1",
")",
")",
";",
"txtUsuario",
".",
"setColumns",
"(",
"COLUMNS_USER",
")",
";",
"JLabel",
"labelBackground",
"=",
"new",
"JLabel",
"(",
"\"",
"\"",
")",
";",
"labelBackground",
".",
"setBounds",
"(",
"POS_X_BACKGROUND",
",",
"POS_Y_BACKGROUND",
",",
"ANCHO_BACKGROUND",
",",
"ALTO_BACKGROUND",
")",
";",
"layeredPane",
".",
"add",
"(",
"labelBackground",
",",
"new",
"Integer",
"(",
"0",
")",
")",
";",
"labelBackground",
".",
"setIcon",
"(",
"new",
"ImageIcon",
"(",
"MenuRegistro",
".",
"class",
".",
"getResource",
"(",
"\"",
"/edu/unlam/wome/frames/menuBackground.jpg",
"\"",
")",
")",
")",
";",
"btnRegistrarse",
".",
"addActionListener",
"(",
"new",
"ActionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"final",
"ActionEvent",
"e",
")",
"{",
"logIn",
"(",
"cliente",
")",
";",
"dispose",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"/**\n\t * Devuelve el campo del usuario\n\t * @return JTextField\n\t */",
"public",
"JTextField",
"gettxtUsuario",
"(",
")",
"{",
"return",
"txtUsuario",
";",
"}",
"/**\n\t * Setea el usuario\n\t * @param usuario campo de texto del usuario\n\t */",
"public",
"void",
"settxtUsuario",
"(",
"final",
"JTextField",
"usuario",
")",
"{",
"this",
".",
"txtUsuario",
"=",
"usuario",
";",
"}",
"/**\n\t * Devuelve la contraseña\n\t * @return JPasswordField\n\t */",
"public",
"JPasswordField",
"getPasswordField",
"(",
")",
"{",
"return",
"pwPassword",
";",
"}",
"/**\n\t * Setea la contraseña del usuario\n\t * @param password campo de contraseña\n\t */",
"public",
"void",
"setPasswordField",
"(",
"final",
"JPasswordField",
"password",
")",
"{",
"this",
".",
"pwPassword",
"=",
"password",
";",
"}",
"/**\n\t * Setea el usuario y la contraseña\n\t * @param cliente cliente actual\n\t */",
"private",
"void",
"logIn",
"(",
"final",
"Cliente",
"cliente",
")",
"{",
"synchronized",
"(",
"cliente",
")",
"{",
"cliente",
".",
"getPaqueteUsuario",
"(",
")",
".",
"setUsername",
"(",
"txtUsuario",
".",
"getText",
"(",
")",
")",
";",
"cliente",
".",
"getPaqueteUsuario",
"(",
")",
".",
"setPassword",
"(",
"String",
".",
"valueOf",
"(",
"pwPassword",
".",
"getPassword",
"(",
")",
")",
")",
";",
"cliente",
".",
"setAccion",
"(",
"Comando",
".",
"REGISTRO",
")",
";",
"cliente",
".",
"notify",
"(",
")",
";",
"}",
"}",
"}"
] | Clase encargada del registro del usuario. | [
"Clase",
"encargada",
"del",
"registro",
"del",
"usuario",
"."
] | [
"//USUARIO",
"//PASSWORD",
"//BACKGROUND",
"//LABEL REGISTRARSE",
"//BOTON REGISTRARSE",
"//VENTANA",
"//LAYERED PANE",
"//LABEL USUARIO",
"//LABEL PASSWORD",
"// Se inicializa ícono y cursor"
] | [
{
"param": "JFrame",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "JFrame",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072cab0508753580f1622bd0c09230cc78ef29fa | yjdwbj/BleReadTool | app/src/main/java/bt/lcy/btread/WebClient.java | [
"Apache-2.0"
] | Java | WebClient | /*
* Create by michael on 6/19/18
*/ | Create by michael on 6/19/18 | [
"Create",
"by",
"michael",
"on",
"6",
"/",
"19",
"/",
"18"
] | public class WebClient extends AppCompatActivity {
private WebView webView;
private static final String url = "https://github.com/yjdwbj";
private final static String TAG = WebClient.class.getSimpleName();
private ProgressBar progressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getSupportActionBar().setTitle(R.string.title);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
setContentView(R.layout.webclient);
webView = (WebView) findViewById(R.id.webclient_view);
// webView.setWebViewClient(new WebViewClient());
webView.setWebChromeClient(new WebChromeClient());
webView.setWebViewClient(new MyWebClient());
webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
webView.setHorizontalScrollBarEnabled(true);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setSupportZoom(true);
webSettings.setLoadWithOverviewMode(true);
webSettings.setBuiltInZoomControls(true);
webSettings.setDisplayZoomControls(false);
webSettings.setCacheMode(WebSettings.LOAD_DEFAULT);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setAppCacheEnabled(true);
webSettings.setAllowFileAccess(true);
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
webSettings.setUseWideViewPort(true);
webSettings.setLoadsImagesAutomatically(true);
webSettings.setDefaultTextEncodingName("utf-8");
if (Build.VERSION.SDK_INT >= 21) {
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); // https要加.
}
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// webView.setWebContentsDebuggingEnabled(true);
// }
webView.loadUrl(url);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: {
onBackPressed();
return true;
}
}
return super.onOptionsItemSelected(item);
}
private class MyWebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
// return super.shouldOverrideUrlLoading(view, url);
view.loadUrl(url);
return true;
}
@Override
public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
super.onReceivedClientCertRequest(view, request);
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
super.onReceivedSslError(view, handler, error);
}
}
} | [
"public",
"class",
"WebClient",
"extends",
"AppCompatActivity",
"{",
"private",
"WebView",
"webView",
";",
"private",
"static",
"final",
"String",
"url",
"=",
"\"",
"https://github.com/yjdwbj",
"\"",
";",
"private",
"final",
"static",
"String",
"TAG",
"=",
"WebClient",
".",
"class",
".",
"getSimpleName",
"(",
")",
";",
"private",
"ProgressBar",
"progressBar",
";",
"@",
"Override",
"public",
"void",
"onCreate",
"(",
"Bundle",
"savedInstanceState",
")",
"{",
"super",
".",
"onCreate",
"(",
"savedInstanceState",
")",
";",
"getSupportActionBar",
"(",
")",
".",
"setTitle",
"(",
"R",
".",
"string",
".",
"title",
")",
";",
"getSupportActionBar",
"(",
")",
".",
"setDisplayHomeAsUpEnabled",
"(",
"true",
")",
";",
"setContentView",
"(",
"R",
".",
"layout",
".",
"webclient",
")",
";",
"webView",
"=",
"(",
"WebView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"webclient_view",
")",
";",
"webView",
".",
"setWebChromeClient",
"(",
"new",
"WebChromeClient",
"(",
")",
")",
";",
"webView",
".",
"setWebViewClient",
"(",
"new",
"MyWebClient",
"(",
")",
")",
";",
"webView",
".",
"setLayerType",
"(",
"View",
".",
"LAYER_TYPE_SOFTWARE",
",",
"null",
")",
";",
"webView",
".",
"setScrollBarStyle",
"(",
"WebView",
".",
"SCROLLBARS_OUTSIDE_OVERLAY",
")",
";",
"webView",
".",
"setHorizontalScrollBarEnabled",
"(",
"true",
")",
";",
"WebSettings",
"webSettings",
"=",
"webView",
".",
"getSettings",
"(",
")",
";",
"webSettings",
".",
"setJavaScriptEnabled",
"(",
"true",
")",
";",
"webSettings",
".",
"setDomStorageEnabled",
"(",
"true",
")",
";",
"webSettings",
".",
"setSupportZoom",
"(",
"true",
")",
";",
"webSettings",
".",
"setLoadWithOverviewMode",
"(",
"true",
")",
";",
"webSettings",
".",
"setBuiltInZoomControls",
"(",
"true",
")",
";",
"webSettings",
".",
"setDisplayZoomControls",
"(",
"false",
")",
";",
"webSettings",
".",
"setCacheMode",
"(",
"WebSettings",
".",
"LOAD_DEFAULT",
")",
";",
"webSettings",
".",
"setJavaScriptCanOpenWindowsAutomatically",
"(",
"true",
")",
";",
"webSettings",
".",
"setAppCacheEnabled",
"(",
"true",
")",
";",
"webSettings",
".",
"setAllowFileAccess",
"(",
"true",
")",
";",
"webSettings",
".",
"setLayoutAlgorithm",
"(",
"WebSettings",
".",
"LayoutAlgorithm",
".",
"NARROW_COLUMNS",
")",
";",
"webSettings",
".",
"setUseWideViewPort",
"(",
"true",
")",
";",
"webSettings",
".",
"setLoadsImagesAutomatically",
"(",
"true",
")",
";",
"webSettings",
".",
"setDefaultTextEncodingName",
"(",
"\"",
"utf-8",
"\"",
")",
";",
"if",
"(",
"Build",
".",
"VERSION",
".",
"SDK_INT",
">=",
"21",
")",
"{",
"webSettings",
".",
"setMixedContentMode",
"(",
"WebSettings",
".",
"MIXED_CONTENT_ALWAYS_ALLOW",
")",
";",
"}",
"webView",
".",
"loadUrl",
"(",
"url",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onOptionsItemSelected",
"(",
"MenuItem",
"item",
")",
"{",
"switch",
"(",
"item",
".",
"getItemId",
"(",
")",
")",
"{",
"case",
"android",
".",
"R",
".",
"id",
".",
"home",
":",
"{",
"onBackPressed",
"(",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"super",
".",
"onOptionsItemSelected",
"(",
"item",
")",
";",
"}",
"private",
"class",
"MyWebClient",
"extends",
"WebViewClient",
"{",
"@",
"Override",
"public",
"boolean",
"shouldOverrideUrlLoading",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"view",
".",
"loadUrl",
"(",
"url",
")",
";",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedClientCertRequest",
"(",
"WebView",
"view",
",",
"ClientCertRequest",
"request",
")",
"{",
"super",
".",
"onReceivedClientCertRequest",
"(",
"view",
",",
"request",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedSslError",
"(",
"WebView",
"view",
",",
"SslErrorHandler",
"handler",
",",
"SslError",
"error",
")",
"{",
"handler",
".",
"proceed",
"(",
")",
";",
"super",
".",
"onReceivedSslError",
"(",
"view",
",",
"handler",
",",
"error",
")",
";",
"}",
"}",
"}"
] | Create by michael on 6/19/18 | [
"Create",
"by",
"michael",
"on",
"6",
"/",
"19",
"/",
"18"
] | [
"// webView.setWebViewClient(new WebViewClient());",
"// https要加.",
"// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {",
"// webView.setWebContentsDebuggingEnabled(true);",
"// }",
"// return super.shouldOverrideUrlLoading(view, url);"
] | [
{
"param": "AppCompatActivity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AppCompatActivity",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072e56d44348dc822d04907eade0df2c06d7c263 | joansmith2/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/core/variable/value/PrimitiveTypeValueImpl.java | [
"Apache-2.0"
] | Java | PrimitiveTypeValueImpl | /**
* @author Daniel Meyer
*
*/ | @author Daniel Meyer | [
"@author",
"Daniel",
"Meyer"
] | public class PrimitiveTypeValueImpl<T> extends AbstractTypedValue<T> implements PrimitiveValue<T> {
private static final long serialVersionUID = 1L;
public PrimitiveTypeValueImpl(T value, PrimitiveValueType type) {
super(value, type);
}
public PrimitiveValueType getType() {
return (PrimitiveValueType) super.getType();
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((type == null) ? 0 : type.hashCode());
result = prime * result + ((value == null) ? 0 : value.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
PrimitiveTypeValueImpl other = (PrimitiveTypeValueImpl) obj;
if (type == null) {
if (other.type != null)
return false;
} else if (!type.equals(other.type))
return false;
if (value == null) {
if (other.value != null)
return false;
} else if (!value.equals(other.value))
return false;
return true;
}
// value type implemenations ////////////////////////////////////
public static class BooleanValueImpl extends PrimitiveTypeValueImpl<Boolean> implements BooleanValue {
private static final long serialVersionUID = 1L;
public BooleanValueImpl(Boolean value) {
super(value, ValueType.BOOLEAN);
}
}
public static class BytesValueImpl extends PrimitiveTypeValueImpl<byte[]> implements BytesValue {
private static final long serialVersionUID = 1L;
public BytesValueImpl(byte[] value) {
super(value, ValueType.BYTES);
}
}
public static class DateValueImpl extends PrimitiveTypeValueImpl<Date> implements DateValue {
private static final long serialVersionUID = 1L;
public DateValueImpl(Date value) {
super(value, ValueType.DATE);
}
}
public static class DoubleValueImpl extends PrimitiveTypeValueImpl<Double> implements DoubleValue {
private static final long serialVersionUID = 1L;
public DoubleValueImpl(Double value) {
super(value, ValueType.DOUBLE);
}
}
public static class IntegerValueImpl extends PrimitiveTypeValueImpl<Integer> implements IntegerValue {
private static final long serialVersionUID = 1L;
public IntegerValueImpl(Integer value) {
super(value, ValueType.INTEGER);
}
}
public static class LongValueImpl extends PrimitiveTypeValueImpl<Long> implements LongValue {
private static final long serialVersionUID = 1L;
public LongValueImpl(Long value) {
super(value, ValueType.LONG);
}
}
public static class ShortValueImpl extends PrimitiveTypeValueImpl<Short> implements ShortValue {
private static final long serialVersionUID = 1L;
public ShortValueImpl(Short value) {
super(value, ValueType.SHORT);
}
}
public static class StringValueImpl extends PrimitiveTypeValueImpl<String> implements StringValue {
private static final long serialVersionUID = 1L;
public StringValueImpl(String value) {
super(value, ValueType.STRING);
}
}
public static class NumberValueImpl extends PrimitiveTypeValueImpl<Number> implements NumberValue {
private static final long serialVersionUID = 1L;
public NumberValueImpl(Number value) {
super(value, ValueType.NUMBER);
}
}
} | [
"public",
"class",
"PrimitiveTypeValueImpl",
"<",
"T",
">",
"extends",
"AbstractTypedValue",
"<",
"T",
">",
"implements",
"PrimitiveValue",
"<",
"T",
">",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"PrimitiveTypeValueImpl",
"(",
"T",
"value",
",",
"PrimitiveValueType",
"type",
")",
"{",
"super",
"(",
"value",
",",
"type",
")",
";",
"}",
"public",
"PrimitiveValueType",
"getType",
"(",
")",
"{",
"return",
"(",
"PrimitiveValueType",
")",
"super",
".",
"getType",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"final",
"int",
"prime",
"=",
"31",
";",
"int",
"result",
"=",
"1",
";",
"result",
"=",
"prime",
"*",
"result",
"+",
"(",
"(",
"type",
"==",
"null",
")",
"?",
"0",
":",
"type",
".",
"hashCode",
"(",
")",
")",
";",
"result",
"=",
"prime",
"*",
"result",
"+",
"(",
"(",
"value",
"==",
"null",
")",
"?",
"0",
":",
"value",
".",
"hashCode",
"(",
")",
")",
";",
"return",
"result",
";",
"}",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"if",
"(",
"this",
"==",
"obj",
")",
"return",
"true",
";",
"if",
"(",
"obj",
"==",
"null",
")",
"return",
"false",
";",
"if",
"(",
"getClass",
"(",
")",
"!=",
"obj",
".",
"getClass",
"(",
")",
")",
"return",
"false",
";",
"PrimitiveTypeValueImpl",
"other",
"=",
"(",
"PrimitiveTypeValueImpl",
")",
"obj",
";",
"if",
"(",
"type",
"==",
"null",
")",
"{",
"if",
"(",
"other",
".",
"type",
"!=",
"null",
")",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"type",
".",
"equals",
"(",
"other",
".",
"type",
")",
")",
"return",
"false",
";",
"if",
"(",
"value",
"==",
"null",
")",
"{",
"if",
"(",
"other",
".",
"value",
"!=",
"null",
")",
"return",
"false",
";",
"}",
"else",
"if",
"(",
"!",
"value",
".",
"equals",
"(",
"other",
".",
"value",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}",
"public",
"static",
"class",
"BooleanValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Boolean",
">",
"implements",
"BooleanValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"BooleanValueImpl",
"(",
"Boolean",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"BOOLEAN",
")",
";",
"}",
"}",
"public",
"static",
"class",
"BytesValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"byte",
"[",
"]",
">",
"implements",
"BytesValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"BytesValueImpl",
"(",
"byte",
"[",
"]",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"BYTES",
")",
";",
"}",
"}",
"public",
"static",
"class",
"DateValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Date",
">",
"implements",
"DateValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"DateValueImpl",
"(",
"Date",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"DATE",
")",
";",
"}",
"}",
"public",
"static",
"class",
"DoubleValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Double",
">",
"implements",
"DoubleValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"DoubleValueImpl",
"(",
"Double",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"DOUBLE",
")",
";",
"}",
"}",
"public",
"static",
"class",
"IntegerValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Integer",
">",
"implements",
"IntegerValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"IntegerValueImpl",
"(",
"Integer",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"INTEGER",
")",
";",
"}",
"}",
"public",
"static",
"class",
"LongValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Long",
">",
"implements",
"LongValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"LongValueImpl",
"(",
"Long",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"LONG",
")",
";",
"}",
"}",
"public",
"static",
"class",
"ShortValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Short",
">",
"implements",
"ShortValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"ShortValueImpl",
"(",
"Short",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"SHORT",
")",
";",
"}",
"}",
"public",
"static",
"class",
"StringValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"String",
">",
"implements",
"StringValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"StringValueImpl",
"(",
"String",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"STRING",
")",
";",
"}",
"}",
"public",
"static",
"class",
"NumberValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Number",
">",
"implements",
"NumberValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"NumberValueImpl",
"(",
"Number",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"NUMBER",
")",
";",
"}",
"}",
"}"
] | @author Daniel Meyer | [
"@author",
"Daniel",
"Meyer"
] | [
"// value type implemenations ////////////////////////////////////"
] | [
{
"param": "PrimitiveValue<T>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "PrimitiveValue<T>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072e56d44348dc822d04907eade0df2c06d7c263 | joansmith2/camunda-bpm-platform | engine/src/main/java/org/camunda/bpm/engine/impl/core/variable/value/PrimitiveTypeValueImpl.java | [
"Apache-2.0"
] | Java | BooleanValueImpl | // value type implemenations //////////////////////////////////// | value type implemenations | [
"value",
"type",
"implemenations"
] | public static class BooleanValueImpl extends PrimitiveTypeValueImpl<Boolean> implements BooleanValue {
private static final long serialVersionUID = 1L;
public BooleanValueImpl(Boolean value) {
super(value, ValueType.BOOLEAN);
}
} | [
"public",
"static",
"class",
"BooleanValueImpl",
"extends",
"PrimitiveTypeValueImpl",
"<",
"Boolean",
">",
"implements",
"BooleanValue",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"BooleanValueImpl",
"(",
"Boolean",
"value",
")",
"{",
"super",
"(",
"value",
",",
"ValueType",
".",
"BOOLEAN",
")",
";",
"}",
"}"
] | value type implemenations | [
"value",
"type",
"implemenations"
] | [] | [
{
"param": "BooleanValue",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BooleanValue",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072ed63626238850a0c7ea4e5dcf9f8a1c7dd523 | 4everalone/nano | sample/webservice/eBayDemoApp/src/com/ebay/trading/api/ConfirmIdentityRequestType.java | [
"Apache-2.0"
] | Java | ConfirmIdentityRequestType | /**
*
* Returns the ID of a user who has gone through an application's consent flow
* process for obtaining an authorization token.
*
*/ | Returns the ID of a user who has gone through an application's consent flow
process for obtaining an authorization token. | [
"Returns",
"the",
"ID",
"of",
"a",
"user",
"who",
"has",
"gone",
"through",
"an",
"application",
"'",
"s",
"consent",
"flow",
"process",
"for",
"obtaining",
"an",
"authorization",
"token",
"."
] | @RootElement(name = "ConfirmIdentityRequest", namespace = "urn:ebay:apis:eBLBaseComponents")
public class ConfirmIdentityRequestType extends AbstractRequestType implements Serializable {
private static final long serialVersionUID = -1L;
@Element(name = "SessionID")
@Order(value=0)
public String sessionID;
} | [
"@",
"RootElement",
"(",
"name",
"=",
"\"",
"ConfirmIdentityRequest",
"\"",
",",
"namespace",
"=",
"\"",
"urn:ebay:apis:eBLBaseComponents",
"\"",
")",
"public",
"class",
"ConfirmIdentityRequestType",
"extends",
"AbstractRequestType",
"implements",
"Serializable",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"-",
"1L",
";",
"@",
"Element",
"(",
"name",
"=",
"\"",
"SessionID",
"\"",
")",
"@",
"Order",
"(",
"value",
"=",
"0",
")",
"public",
"String",
"sessionID",
";",
"}"
] | Returns the ID of a user who has gone through an application's consent flow
process for obtaining an authorization token. | [
"Returns",
"the",
"ID",
"of",
"a",
"user",
"who",
"has",
"gone",
"through",
"an",
"application",
"'",
"s",
"consent",
"flow",
"process",
"for",
"obtaining",
"an",
"authorization",
"token",
"."
] | [] | [
{
"param": "AbstractRequestType",
"type": null
},
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractRequestType",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072f0d0fa5bd5265e7177afbad0df5ce9acb7c3b | tiegan/as1 | src/app/src/main/java/com/example/tiegan_habittracker/HabitViewer.java | [
"Apache-2.0"
] | Java | HabitViewer | /**
* In this activity, the content of the selected habit from ViewHabits is viewed in detail by
* showing the name, date given, days to be completed, number of completions and whether it not it
* has been completed for that day. The user can also click to add a completion for that habit, and
* view the days the habit was completed on by clicking the second button and going into another
* activity.
*
* Design rationale was to output the info necessary from the habit. Make sure it was all outputted,
* make sure it updated. Make it clean, make it simple. Don't make it complex. That's all I wanted
* to do.
*
* Other than needing some cleaning up the code, no real issues here.
*
* References:
* 1) http://stackoverflow.com/questions/7074097/how-to-pass-integer-from-one-activity-to-another
* (Author: Paresh Mayani)
*/ | In this activity, the content of the selected habit from ViewHabits is viewed in detail by
showing the name, date given, days to be completed, number of completions and whether it not it
has been completed for that day. The user can also click to add a completion for that habit, and
view the days the habit was completed on by clicking the second button and going into another
activity.
Design rationale was to output the info necessary from the habit. Make sure it was all outputted,
make sure it updated. Make it clean, make it simple. Don't make it complex. That's all I wanted
to do.
Other than needing some cleaning up the code, no real issues here.
| [
"In",
"this",
"activity",
"the",
"content",
"of",
"the",
"selected",
"habit",
"from",
"ViewHabits",
"is",
"viewed",
"in",
"detail",
"by",
"showing",
"the",
"name",
"date",
"given",
"days",
"to",
"be",
"completed",
"number",
"of",
"completions",
"and",
"whether",
"it",
"not",
"it",
"has",
"been",
"completed",
"for",
"that",
"day",
".",
"The",
"user",
"can",
"also",
"click",
"to",
"add",
"a",
"completion",
"for",
"that",
"habit",
"and",
"view",
"the",
"days",
"the",
"habit",
"was",
"completed",
"on",
"by",
"clicking",
"the",
"second",
"button",
"and",
"going",
"into",
"another",
"activity",
".",
"Design",
"rationale",
"was",
"to",
"output",
"the",
"info",
"necessary",
"from",
"the",
"habit",
".",
"Make",
"sure",
"it",
"was",
"all",
"outputted",
"make",
"sure",
"it",
"updated",
".",
"Make",
"it",
"clean",
"make",
"it",
"simple",
".",
"Don",
"'",
"t",
"make",
"it",
"complex",
".",
"That",
"'",
"s",
"all",
"I",
"wanted",
"to",
"do",
".",
"Other",
"than",
"needing",
"some",
"cleaning",
"up",
"the",
"code",
"no",
"real",
"issues",
"here",
"."
] | public class HabitViewer extends Activity {
private static final String FILENAME = "HabitTrackerData.sav";
private TextView nameView;
private TextView dateView;
private TextView daysView;
private TextView countView;
private TextView completionView;
private int index;
private Habit habit;
private HabitList habitList;
private CompletionList completionList;
private String weekday;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.habit_viewer);
//from reference 1
Intent intent = getIntent();
index = intent.getIntExtra("givenHabit", 0);
//end from reference 1
nameView = (TextView) findViewById(R.id.HabitName);
dateView = (TextView) findViewById(R.id.DateGiven);
daysView = (TextView) findViewById(R.id.DaysGiven);
countView = (TextView) findViewById(R.id.CurrentCount);
completionView = (TextView) findViewById(R.id.isCompleted);
Button addButton = (Button) findViewById(R.id.addCount);
Button viewButton = (Button) findViewById(R.id.viewCount);
Button returnButton = (Button) findViewById(R.id.returnToList);
addButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
checkDates();
if(!habit.returnStatus()) {
habit.setCompletions(new Date());
habit.setStatus(true);
completionList.increaseCompletion();
}
else {
completionList.increaseCompletion();
}
showCount(completionList.returnTotalCompletions());
showCompletionStatus();
saveInFile();
}
});
viewButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//from reference 1
Intent intent = new Intent(HabitViewer.this, CompletionViewer.class);
intent.putExtra("givenHabit", index);
startActivity(intent);
//end from reference 1
}
});
returnButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
finish();
}
});
}
//Loads all values from habitList into the textViews.
@Override
protected void onStart() {
super.onStart();
loadFromFile();
habit = habitList.getHabit(index);
completionList = habit.returnCompletionList();
checkDates();
showName(habit.toString());
showDate(habit.returnDate());
showDays(habit.returnDaysList());
showCount(completionList.returnTotalCompletions());
showCompletionStatus();
}
//Comes back from CompletionViewer. Only activity where this is necessary.
@Override
protected void onResume() {
super.onResume();
loadFromFile();
habit = habitList.getHabit(index);
completionList = habit.returnCompletionList();
checkDates();
showCount(completionList.returnTotalCompletions());
showCompletionStatus();
}
private void showName(String name) {
nameView.setText(name);
nameView.setTextSize(16);
}
private void showDate(Date date) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateView.setText(dateFormat.format(date));
dateView.setTextSize(16);
}
private void showDays(DaysList days) {
String text = "";
for(int i = 0; i < days.returnCount(); i++) {
Day day = days.returnDay(i);
text = text + day.getName() + " ";
}
daysView.setText(text);
daysView.setTextSize(16);
}
private void showCount(int count) {
String text = Integer.toString(completionList.returnSize()) + " day(s) (" +
Integer.toString(completionList.returnTotalCompletions()) + " total completion(s))";
countView.setText(text);
countView.setTextSize(16);
}
//Three options for showCompletionStatus since what if they aren't supposed to complete the
//habit that day?
private void showCompletionStatus() {
weekday = new SimpleDateFormat("EEEE").format(new Date());
if(habit.returnDaysList().hasDay(weekday) && habit.returnStatus()) {
completionView.setText("Yes");
}
else if (habit.returnDaysList().hasDay(weekday) && !habit.returnStatus()) {
completionView.setText("No");
}
else{
completionView.setText("n/a");
}
completionView.setTextSize(16);
}
//Makes sure the status is correct.
private void checkDates() {
String date;
try {
date = new SimpleDateFormat("yyyy-MM-dd").format(completionList.returnLastCheckedDay());
} catch (NullPointerException e) {
date = "";
}
String date2 = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
if(!date.equals(date2)) {
habit.setStatus(false);
}
}
private void loadFromFile() {
try {
FileInputStream fis = openFileInput(FILENAME);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
Gson gson = new Gson();
Type listType = new TypeToken<HabitList>() {}.getType();
habitList = gson.fromJson(in, listType);
} catch (FileNotFoundException e) {
// from reference 3
Toast.makeText(getApplicationContext(), "File Not Found", Toast.LENGTH_SHORT).show();
finish();
} catch (IOException e) {
// from reference 3
Toast.makeText(getApplicationContext(), "IO Error", Toast.LENGTH_SHORT).show();
finish();
}
}
private void saveInFile() {
try {
FileOutputStream fos = openFileOutput(FILENAME, 0);
OutputStreamWriter writer = new OutputStreamWriter(fos);
Gson gson = new Gson();
gson.toJson(habitList, writer);
writer.flush();
} catch (FileNotFoundException e) {
// from reference 3
Toast.makeText(getApplicationContext(), "File Not Found", Toast.LENGTH_SHORT).show();
finish();
} catch (IOException e) {
// from reference 3
Toast.makeText(getApplicationContext(), "IO Error", Toast.LENGTH_SHORT).show();
finish();
}
}
} | [
"public",
"class",
"HabitViewer",
"extends",
"Activity",
"{",
"private",
"static",
"final",
"String",
"FILENAME",
"=",
"\"",
"HabitTrackerData.sav",
"\"",
";",
"private",
"TextView",
"nameView",
";",
"private",
"TextView",
"dateView",
";",
"private",
"TextView",
"daysView",
";",
"private",
"TextView",
"countView",
";",
"private",
"TextView",
"completionView",
";",
"private",
"int",
"index",
";",
"private",
"Habit",
"habit",
";",
"private",
"HabitList",
"habitList",
";",
"private",
"CompletionList",
"completionList",
";",
"private",
"String",
"weekday",
";",
"@",
"Override",
"protected",
"void",
"onCreate",
"(",
"Bundle",
"savedInstanceState",
")",
"{",
"super",
".",
"onCreate",
"(",
"savedInstanceState",
")",
";",
"setContentView",
"(",
"R",
".",
"layout",
".",
"habit_viewer",
")",
";",
"Intent",
"intent",
"=",
"getIntent",
"(",
")",
";",
"index",
"=",
"intent",
".",
"getIntExtra",
"(",
"\"",
"givenHabit",
"\"",
",",
"0",
")",
";",
"nameView",
"=",
"(",
"TextView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"HabitName",
")",
";",
"dateView",
"=",
"(",
"TextView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"DateGiven",
")",
";",
"daysView",
"=",
"(",
"TextView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"DaysGiven",
")",
";",
"countView",
"=",
"(",
"TextView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"CurrentCount",
")",
";",
"completionView",
"=",
"(",
"TextView",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"isCompleted",
")",
";",
"Button",
"addButton",
"=",
"(",
"Button",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"addCount",
")",
";",
"Button",
"viewButton",
"=",
"(",
"Button",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"viewCount",
")",
";",
"Button",
"returnButton",
"=",
"(",
"Button",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"returnToList",
")",
";",
"addButton",
".",
"setOnClickListener",
"(",
"new",
"View",
".",
"OnClickListener",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"View",
"v",
")",
"{",
"checkDates",
"(",
")",
";",
"if",
"(",
"!",
"habit",
".",
"returnStatus",
"(",
")",
")",
"{",
"habit",
".",
"setCompletions",
"(",
"new",
"Date",
"(",
")",
")",
";",
"habit",
".",
"setStatus",
"(",
"true",
")",
";",
"completionList",
".",
"increaseCompletion",
"(",
")",
";",
"}",
"else",
"{",
"completionList",
".",
"increaseCompletion",
"(",
")",
";",
"}",
"showCount",
"(",
"completionList",
".",
"returnTotalCompletions",
"(",
")",
")",
";",
"showCompletionStatus",
"(",
")",
";",
"saveInFile",
"(",
")",
";",
"}",
"}",
")",
";",
"viewButton",
".",
"setOnClickListener",
"(",
"new",
"View",
".",
"OnClickListener",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"View",
"v",
")",
"{",
"Intent",
"intent",
"=",
"new",
"Intent",
"(",
"HabitViewer",
".",
"this",
",",
"CompletionViewer",
".",
"class",
")",
";",
"intent",
".",
"putExtra",
"(",
"\"",
"givenHabit",
"\"",
",",
"index",
")",
";",
"startActivity",
"(",
"intent",
")",
";",
"}",
"}",
")",
";",
"returnButton",
".",
"setOnClickListener",
"(",
"new",
"View",
".",
"OnClickListener",
"(",
")",
"{",
"public",
"void",
"onClick",
"(",
"View",
"v",
")",
"{",
"finish",
"(",
")",
";",
"}",
"}",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onStart",
"(",
")",
"{",
"super",
".",
"onStart",
"(",
")",
";",
"loadFromFile",
"(",
")",
";",
"habit",
"=",
"habitList",
".",
"getHabit",
"(",
"index",
")",
";",
"completionList",
"=",
"habit",
".",
"returnCompletionList",
"(",
")",
";",
"checkDates",
"(",
")",
";",
"showName",
"(",
"habit",
".",
"toString",
"(",
")",
")",
";",
"showDate",
"(",
"habit",
".",
"returnDate",
"(",
")",
")",
";",
"showDays",
"(",
"habit",
".",
"returnDaysList",
"(",
")",
")",
";",
"showCount",
"(",
"completionList",
".",
"returnTotalCompletions",
"(",
")",
")",
";",
"showCompletionStatus",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onResume",
"(",
")",
"{",
"super",
".",
"onResume",
"(",
")",
";",
"loadFromFile",
"(",
")",
";",
"habit",
"=",
"habitList",
".",
"getHabit",
"(",
"index",
")",
";",
"completionList",
"=",
"habit",
".",
"returnCompletionList",
"(",
")",
";",
"checkDates",
"(",
")",
";",
"showCount",
"(",
"completionList",
".",
"returnTotalCompletions",
"(",
")",
")",
";",
"showCompletionStatus",
"(",
")",
";",
"}",
"private",
"void",
"showName",
"(",
"String",
"name",
")",
"{",
"nameView",
".",
"setText",
"(",
"name",
")",
";",
"nameView",
".",
"setTextSize",
"(",
"16",
")",
";",
"}",
"private",
"void",
"showDate",
"(",
"Date",
"date",
")",
"{",
"SimpleDateFormat",
"dateFormat",
"=",
"new",
"SimpleDateFormat",
"(",
"\"",
"yyyy-MM-dd",
"\"",
")",
";",
"dateView",
".",
"setText",
"(",
"dateFormat",
".",
"format",
"(",
"date",
")",
")",
";",
"dateView",
".",
"setTextSize",
"(",
"16",
")",
";",
"}",
"private",
"void",
"showDays",
"(",
"DaysList",
"days",
")",
"{",
"String",
"text",
"=",
"\"",
"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"days",
".",
"returnCount",
"(",
")",
";",
"i",
"++",
")",
"{",
"Day",
"day",
"=",
"days",
".",
"returnDay",
"(",
"i",
")",
";",
"text",
"=",
"text",
"+",
"day",
".",
"getName",
"(",
")",
"+",
"\"",
" ",
"\"",
";",
"}",
"daysView",
".",
"setText",
"(",
"text",
")",
";",
"daysView",
".",
"setTextSize",
"(",
"16",
")",
";",
"}",
"private",
"void",
"showCount",
"(",
"int",
"count",
")",
"{",
"String",
"text",
"=",
"Integer",
".",
"toString",
"(",
"completionList",
".",
"returnSize",
"(",
")",
")",
"+",
"\"",
" day(s) (",
"\"",
"+",
"Integer",
".",
"toString",
"(",
"completionList",
".",
"returnTotalCompletions",
"(",
")",
")",
"+",
"\"",
" total completion(s))",
"\"",
";",
"countView",
".",
"setText",
"(",
"text",
")",
";",
"countView",
".",
"setTextSize",
"(",
"16",
")",
";",
"}",
"private",
"void",
"showCompletionStatus",
"(",
")",
"{",
"weekday",
"=",
"new",
"SimpleDateFormat",
"(",
"\"",
"EEEE",
"\"",
")",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
";",
"if",
"(",
"habit",
".",
"returnDaysList",
"(",
")",
".",
"hasDay",
"(",
"weekday",
")",
"&&",
"habit",
".",
"returnStatus",
"(",
")",
")",
"{",
"completionView",
".",
"setText",
"(",
"\"",
"Yes",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"habit",
".",
"returnDaysList",
"(",
")",
".",
"hasDay",
"(",
"weekday",
")",
"&&",
"!",
"habit",
".",
"returnStatus",
"(",
")",
")",
"{",
"completionView",
".",
"setText",
"(",
"\"",
"No",
"\"",
")",
";",
"}",
"else",
"{",
"completionView",
".",
"setText",
"(",
"\"",
"n/a",
"\"",
")",
";",
"}",
"completionView",
".",
"setTextSize",
"(",
"16",
")",
";",
"}",
"private",
"void",
"checkDates",
"(",
")",
"{",
"String",
"date",
";",
"try",
"{",
"date",
"=",
"new",
"SimpleDateFormat",
"(",
"\"",
"yyyy-MM-dd",
"\"",
")",
".",
"format",
"(",
"completionList",
".",
"returnLastCheckedDay",
"(",
")",
")",
";",
"}",
"catch",
"(",
"NullPointerException",
"e",
")",
"{",
"date",
"=",
"\"",
"\"",
";",
"}",
"String",
"date2",
"=",
"new",
"SimpleDateFormat",
"(",
"\"",
"yyyy-MM-dd",
"\"",
")",
".",
"format",
"(",
"new",
"Date",
"(",
")",
")",
";",
"if",
"(",
"!",
"date",
".",
"equals",
"(",
"date2",
")",
")",
"{",
"habit",
".",
"setStatus",
"(",
"false",
")",
";",
"}",
"}",
"private",
"void",
"loadFromFile",
"(",
")",
"{",
"try",
"{",
"FileInputStream",
"fis",
"=",
"openFileInput",
"(",
"FILENAME",
")",
";",
"BufferedReader",
"in",
"=",
"new",
"BufferedReader",
"(",
"new",
"InputStreamReader",
"(",
"fis",
")",
")",
";",
"Gson",
"gson",
"=",
"new",
"Gson",
"(",
")",
";",
"Type",
"listType",
"=",
"new",
"TypeToken",
"<",
"HabitList",
">",
"(",
")",
"{",
"}",
".",
"getType",
"(",
")",
";",
"habitList",
"=",
"gson",
".",
"fromJson",
"(",
"in",
",",
"listType",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"Toast",
".",
"makeText",
"(",
"getApplicationContext",
"(",
")",
",",
"\"",
"File Not Found",
"\"",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"finish",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Toast",
".",
"makeText",
"(",
"getApplicationContext",
"(",
")",
",",
"\"",
"IO Error",
"\"",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"finish",
"(",
")",
";",
"}",
"}",
"private",
"void",
"saveInFile",
"(",
")",
"{",
"try",
"{",
"FileOutputStream",
"fos",
"=",
"openFileOutput",
"(",
"FILENAME",
",",
"0",
")",
";",
"OutputStreamWriter",
"writer",
"=",
"new",
"OutputStreamWriter",
"(",
"fos",
")",
";",
"Gson",
"gson",
"=",
"new",
"Gson",
"(",
")",
";",
"gson",
".",
"toJson",
"(",
"habitList",
",",
"writer",
")",
";",
"writer",
".",
"flush",
"(",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"Toast",
".",
"makeText",
"(",
"getApplicationContext",
"(",
")",
",",
"\"",
"File Not Found",
"\"",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"finish",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"Toast",
".",
"makeText",
"(",
"getApplicationContext",
"(",
")",
",",
"\"",
"IO Error",
"\"",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"finish",
"(",
")",
";",
"}",
"}",
"}"
] | In this activity, the content of the selected habit from ViewHabits is viewed in detail by
showing the name, date given, days to be completed, number of completions and whether it not it
has been completed for that day. | [
"In",
"this",
"activity",
"the",
"content",
"of",
"the",
"selected",
"habit",
"from",
"ViewHabits",
"is",
"viewed",
"in",
"detail",
"by",
"showing",
"the",
"name",
"date",
"given",
"days",
"to",
"be",
"completed",
"number",
"of",
"completions",
"and",
"whether",
"it",
"not",
"it",
"has",
"been",
"completed",
"for",
"that",
"day",
"."
] | [
"//from reference 1\r",
"//end from reference 1\r",
"//from reference 1\r",
"//end from reference 1\r",
"//Loads all values from habitList into the textViews.\r",
"//Comes back from CompletionViewer. Only activity where this is necessary.\r",
"//Three options for showCompletionStatus since what if they aren't supposed to complete the\r",
"//habit that day?\r",
"//Makes sure the status is correct.\r",
"// from reference 3\r",
"// from reference 3\r",
"// from reference 3\r",
"// from reference 3\r"
] | [
{
"param": "Activity",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Activity",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
072f32c27195531b3b5e462eab27ae696bbc716e | Zutubi/pulse | com.zutubi.pulse.master/src/java/com/zutubi/pulse/master/tove/config/project/reports/ColourValidator.java | [
"Apache-2.0"
] | Java | ColourValidator | /**
* Validates custom colour values for report series.
*/ | Validates custom colour values for report series. | [
"Validates",
"custom",
"colour",
"values",
"for",
"report",
"series",
"."
] | public class ColourValidator extends FieldValidatorSupport
{
protected void validateField(Object value) throws ValidationException
{
if (value instanceof String)
{
String s = (String) value;
if (StringUtils.stringSet(s))
{
try
{
parseColour(s);
}
catch (IllegalArgumentException e)
{
throw new ValidationException(e.getMessage());
}
}
}
}
/**
* Parses a string to a colour instance. The string can be either a
* numerical RGB value (hex is easiest, e.g. 0xffbb80), or a constant name
* from {@link java.awt.Color}.
*
* @param colour the colour string to parse
* @return a corresponing Color instance
* @throws IllegalArgumentException if the string cannot be resolved to a
* Color
*/
public static Color parseColour(final String colour) throws IllegalArgumentException
{
// Adapted from code in jcommon (part of JFreeChart).
try
{
// Get colour by hex or octal value
return Color.decode(colour);
}
catch (NumberFormatException nfe)
{
try
{
// Try to get a color by name using reflection
// black is used for an instance and not for the color itself
final Field f = Color.class.getField(colour);
return (Color) f.get(null);
}
catch (Exception ce)
{
throw new IllegalArgumentException("Unrecognised colour '" + colour + "'");
}
}
}
} | [
"public",
"class",
"ColourValidator",
"extends",
"FieldValidatorSupport",
"{",
"protected",
"void",
"validateField",
"(",
"Object",
"value",
")",
"throws",
"ValidationException",
"{",
"if",
"(",
"value",
"instanceof",
"String",
")",
"{",
"String",
"s",
"=",
"(",
"String",
")",
"value",
";",
"if",
"(",
"StringUtils",
".",
"stringSet",
"(",
"s",
")",
")",
"{",
"try",
"{",
"parseColour",
"(",
"s",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"ValidationException",
"(",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"/**\n * Parses a string to a colour instance. The string can be either a\n * numerical RGB value (hex is easiest, e.g. 0xffbb80), or a constant name\n * from {@link java.awt.Color}.\n *\n * @param colour the colour string to parse\n * @return a corresponing Color instance\n * @throws IllegalArgumentException if the string cannot be resolved to a\n * Color\n */",
"public",
"static",
"Color",
"parseColour",
"(",
"final",
"String",
"colour",
")",
"throws",
"IllegalArgumentException",
"{",
"try",
"{",
"return",
"Color",
".",
"decode",
"(",
"colour",
")",
";",
"}",
"catch",
"(",
"NumberFormatException",
"nfe",
")",
"{",
"try",
"{",
"final",
"Field",
"f",
"=",
"Color",
".",
"class",
".",
"getField",
"(",
"colour",
")",
";",
"return",
"(",
"Color",
")",
"f",
".",
"get",
"(",
"null",
")",
";",
"}",
"catch",
"(",
"Exception",
"ce",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Unrecognised colour '",
"\"",
"+",
"colour",
"+",
"\"",
"'",
"\"",
")",
";",
"}",
"}",
"}",
"}"
] | Validates custom colour values for report series. | [
"Validates",
"custom",
"colour",
"values",
"for",
"report",
"series",
"."
] | [
"// Adapted from code in jcommon (part of JFreeChart).",
"// Get colour by hex or octal value",
"// Try to get a color by name using reflection",
"// black is used for an instance and not for the color itself"
] | [
{
"param": "FieldValidatorSupport",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "FieldValidatorSupport",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07307655877b2afe6b5bc0b5d712b11e3380a735 | ugermann/MMT | src/core/src/main/java/eu/modernmt/engine/Engine.java | [
"Apache-2.0"
] | Java | Engine | /**
* Created by davide on 19/04/16.
*/ | Created by davide on 19/04/16. | [
"Created",
"by",
"davide",
"on",
"19",
"/",
"04",
"/",
"16",
"."
] | public class Engine implements Closeable {
static {
initialize();
}
public static void initialize() {
TextProcessingModels.setPath(FileConst.getResourcePath());
}
public static final String ENGINE_CONFIG_PATH = "engine.xconf";
public static File getRootPath(String engine) {
return FileConst.getEngineRoot(engine);
}
public static File getConfigFile(String engine) {
return new File(FileConst.getEngineRoot(engine), ENGINE_CONFIG_PATH);
}
private final File root;
private final File runtime;
private final File models;
private final File logs;
private final String name;
private final Locale sourceLanguage;
private final Locale targetLanguage;
private final Decoder decoder;
private final Aligner aligner;
private final Preprocessor sourcePreprocessor;
private final Preprocessor targetPreprocessor;
private final Postprocessor postprocessor;
private final ContextAnalyzer contextAnalyzer;
private final Vocabulary vocabulary;
public static Engine load(EngineConfig config) throws BootstrapException {
try {
return new Engine(config);
} catch (Exception e) {
throw new BootstrapException(e);
}
}
private Engine(EngineConfig config) throws IOException, PersistenceException {
this.name = config.getName();
this.sourceLanguage = config.getSourceLanguage();
this.targetLanguage = config.getTargetLanguage();
this.root = FileConst.getEngineRoot(name);
this.runtime = FileConst.getEngineRuntime(name);
this.models = Paths.join(this.root, "models");
this.logs = Paths.join(this.runtime, "logs");
this.vocabulary = new RocksDBVocabulary(Paths.join(this.models, "vocabulary"));
this.sourcePreprocessor = new Preprocessor(sourceLanguage, targetLanguage, vocabulary);
this.targetPreprocessor = new Preprocessor(targetLanguage, sourceLanguage, vocabulary);
this.postprocessor = new Postprocessor(sourceLanguage, targetLanguage, vocabulary);
this.aligner = new FastAlign(Paths.join(this.models, "align"));
this.contextAnalyzer = new LuceneAnalyzer(Paths.join(this.models, "context"), sourceLanguage);
DecoderConfig decoderConfig = config.getDecoderConfig();
if (decoderConfig.isEnabled())
this.decoder = new MosesDecoder(Paths.join(this.models, "decoder"), aligner, vocabulary,
decoderConfig.getThreads());
else
this.decoder = null;
}
public String getName() {
return name;
}
public Decoder getDecoder() {
if (decoder == null)
throw new UnsupportedOperationException("Decoder unavailable");
return decoder;
}
public Aligner getAligner() {
if (aligner == null)
throw new UnsupportedOperationException("Aligner unavailable");
return aligner;
}
public ContextAnalyzer getContextAnalyzer() {
if (contextAnalyzer == null)
throw new UnsupportedOperationException("Context Analyzer unavailable");
return contextAnalyzer;
}
public Preprocessor getSourcePreprocessor() {
return sourcePreprocessor;
}
public Preprocessor getTargetPreprocessor() {
return targetPreprocessor;
}
public Postprocessor getPostprocessor() {
return postprocessor;
}
public Vocabulary getVocabulary() {
return vocabulary;
}
public Locale getSourceLanguage() {
return sourceLanguage;
}
public Locale getTargetLanguage() {
return targetLanguage;
}
public File getRootPath() {
return root;
}
public File getModelsPath() {
return models;
}
public File getRuntimeFolder(String folderName, boolean ensure) throws IOException {
File folder = new File(this.runtime, folderName);
if (ensure) {
FileUtils.deleteDirectory(folder);
FileUtils.forceMkdir(folder);
}
return folder;
}
public File getLogFile(String name) {
return new File(this.logs, name);
}
@Override
public void close() {
IOUtils.closeQuietly(sourcePreprocessor);
IOUtils.closeQuietly(targetPreprocessor);
IOUtils.closeQuietly(postprocessor);
IOUtils.closeQuietly(decoder);
IOUtils.closeQuietly(aligner);
IOUtils.closeQuietly(contextAnalyzer);
IOUtils.closeQuietly(vocabulary);
}
} | [
"public",
"class",
"Engine",
"implements",
"Closeable",
"{",
"static",
"{",
"initialize",
"(",
")",
";",
"}",
"public",
"static",
"void",
"initialize",
"(",
")",
"{",
"TextProcessingModels",
".",
"setPath",
"(",
"FileConst",
".",
"getResourcePath",
"(",
")",
")",
";",
"}",
"public",
"static",
"final",
"String",
"ENGINE_CONFIG_PATH",
"=",
"\"",
"engine.xconf",
"\"",
";",
"public",
"static",
"File",
"getRootPath",
"(",
"String",
"engine",
")",
"{",
"return",
"FileConst",
".",
"getEngineRoot",
"(",
"engine",
")",
";",
"}",
"public",
"static",
"File",
"getConfigFile",
"(",
"String",
"engine",
")",
"{",
"return",
"new",
"File",
"(",
"FileConst",
".",
"getEngineRoot",
"(",
"engine",
")",
",",
"ENGINE_CONFIG_PATH",
")",
";",
"}",
"private",
"final",
"File",
"root",
";",
"private",
"final",
"File",
"runtime",
";",
"private",
"final",
"File",
"models",
";",
"private",
"final",
"File",
"logs",
";",
"private",
"final",
"String",
"name",
";",
"private",
"final",
"Locale",
"sourceLanguage",
";",
"private",
"final",
"Locale",
"targetLanguage",
";",
"private",
"final",
"Decoder",
"decoder",
";",
"private",
"final",
"Aligner",
"aligner",
";",
"private",
"final",
"Preprocessor",
"sourcePreprocessor",
";",
"private",
"final",
"Preprocessor",
"targetPreprocessor",
";",
"private",
"final",
"Postprocessor",
"postprocessor",
";",
"private",
"final",
"ContextAnalyzer",
"contextAnalyzer",
";",
"private",
"final",
"Vocabulary",
"vocabulary",
";",
"public",
"static",
"Engine",
"load",
"(",
"EngineConfig",
"config",
")",
"throws",
"BootstrapException",
"{",
"try",
"{",
"return",
"new",
"Engine",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"BootstrapException",
"(",
"e",
")",
";",
"}",
"}",
"private",
"Engine",
"(",
"EngineConfig",
"config",
")",
"throws",
"IOException",
",",
"PersistenceException",
"{",
"this",
".",
"name",
"=",
"config",
".",
"getName",
"(",
")",
";",
"this",
".",
"sourceLanguage",
"=",
"config",
".",
"getSourceLanguage",
"(",
")",
";",
"this",
".",
"targetLanguage",
"=",
"config",
".",
"getTargetLanguage",
"(",
")",
";",
"this",
".",
"root",
"=",
"FileConst",
".",
"getEngineRoot",
"(",
"name",
")",
";",
"this",
".",
"runtime",
"=",
"FileConst",
".",
"getEngineRuntime",
"(",
"name",
")",
";",
"this",
".",
"models",
"=",
"Paths",
".",
"join",
"(",
"this",
".",
"root",
",",
"\"",
"models",
"\"",
")",
";",
"this",
".",
"logs",
"=",
"Paths",
".",
"join",
"(",
"this",
".",
"runtime",
",",
"\"",
"logs",
"\"",
")",
";",
"this",
".",
"vocabulary",
"=",
"new",
"RocksDBVocabulary",
"(",
"Paths",
".",
"join",
"(",
"this",
".",
"models",
",",
"\"",
"vocabulary",
"\"",
")",
")",
";",
"this",
".",
"sourcePreprocessor",
"=",
"new",
"Preprocessor",
"(",
"sourceLanguage",
",",
"targetLanguage",
",",
"vocabulary",
")",
";",
"this",
".",
"targetPreprocessor",
"=",
"new",
"Preprocessor",
"(",
"targetLanguage",
",",
"sourceLanguage",
",",
"vocabulary",
")",
";",
"this",
".",
"postprocessor",
"=",
"new",
"Postprocessor",
"(",
"sourceLanguage",
",",
"targetLanguage",
",",
"vocabulary",
")",
";",
"this",
".",
"aligner",
"=",
"new",
"FastAlign",
"(",
"Paths",
".",
"join",
"(",
"this",
".",
"models",
",",
"\"",
"align",
"\"",
")",
")",
";",
"this",
".",
"contextAnalyzer",
"=",
"new",
"LuceneAnalyzer",
"(",
"Paths",
".",
"join",
"(",
"this",
".",
"models",
",",
"\"",
"context",
"\"",
")",
",",
"sourceLanguage",
")",
";",
"DecoderConfig",
"decoderConfig",
"=",
"config",
".",
"getDecoderConfig",
"(",
")",
";",
"if",
"(",
"decoderConfig",
".",
"isEnabled",
"(",
")",
")",
"this",
".",
"decoder",
"=",
"new",
"MosesDecoder",
"(",
"Paths",
".",
"join",
"(",
"this",
".",
"models",
",",
"\"",
"decoder",
"\"",
")",
",",
"aligner",
",",
"vocabulary",
",",
"decoderConfig",
".",
"getThreads",
"(",
")",
")",
";",
"else",
"this",
".",
"decoder",
"=",
"null",
";",
"}",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"Decoder",
"getDecoder",
"(",
")",
"{",
"if",
"(",
"decoder",
"==",
"null",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"",
"Decoder unavailable",
"\"",
")",
";",
"return",
"decoder",
";",
"}",
"public",
"Aligner",
"getAligner",
"(",
")",
"{",
"if",
"(",
"aligner",
"==",
"null",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"",
"Aligner unavailable",
"\"",
")",
";",
"return",
"aligner",
";",
"}",
"public",
"ContextAnalyzer",
"getContextAnalyzer",
"(",
")",
"{",
"if",
"(",
"contextAnalyzer",
"==",
"null",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"",
"Context Analyzer unavailable",
"\"",
")",
";",
"return",
"contextAnalyzer",
";",
"}",
"public",
"Preprocessor",
"getSourcePreprocessor",
"(",
")",
"{",
"return",
"sourcePreprocessor",
";",
"}",
"public",
"Preprocessor",
"getTargetPreprocessor",
"(",
")",
"{",
"return",
"targetPreprocessor",
";",
"}",
"public",
"Postprocessor",
"getPostprocessor",
"(",
")",
"{",
"return",
"postprocessor",
";",
"}",
"public",
"Vocabulary",
"getVocabulary",
"(",
")",
"{",
"return",
"vocabulary",
";",
"}",
"public",
"Locale",
"getSourceLanguage",
"(",
")",
"{",
"return",
"sourceLanguage",
";",
"}",
"public",
"Locale",
"getTargetLanguage",
"(",
")",
"{",
"return",
"targetLanguage",
";",
"}",
"public",
"File",
"getRootPath",
"(",
")",
"{",
"return",
"root",
";",
"}",
"public",
"File",
"getModelsPath",
"(",
")",
"{",
"return",
"models",
";",
"}",
"public",
"File",
"getRuntimeFolder",
"(",
"String",
"folderName",
",",
"boolean",
"ensure",
")",
"throws",
"IOException",
"{",
"File",
"folder",
"=",
"new",
"File",
"(",
"this",
".",
"runtime",
",",
"folderName",
")",
";",
"if",
"(",
"ensure",
")",
"{",
"FileUtils",
".",
"deleteDirectory",
"(",
"folder",
")",
";",
"FileUtils",
".",
"forceMkdir",
"(",
"folder",
")",
";",
"}",
"return",
"folder",
";",
"}",
"public",
"File",
"getLogFile",
"(",
"String",
"name",
")",
"{",
"return",
"new",
"File",
"(",
"this",
".",
"logs",
",",
"name",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"{",
"IOUtils",
".",
"closeQuietly",
"(",
"sourcePreprocessor",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"targetPreprocessor",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"postprocessor",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"decoder",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"aligner",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"contextAnalyzer",
")",
";",
"IOUtils",
".",
"closeQuietly",
"(",
"vocabulary",
")",
";",
"}",
"}"
] | Created by davide on 19/04/16. | [
"Created",
"by",
"davide",
"on",
"19",
"/",
"04",
"/",
"16",
"."
] | [] | [
{
"param": "Closeable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Closeable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07346d09616a547ff2c5c4eb1607fee9cf45a251 | vlad-bondarenko/sym-ads | sym-ads-service/src/main/java/sym/ads/service/ServiceServer.java | [
"Apache-2.0"
] | Java | ServiceServer | /**
* Created by vbondarenko on 16.05.2020.
*/ | Created by vbondarenko on 16.05.2020. | [
"Created",
"by",
"vbondarenko",
"on",
"16",
".",
"05",
".",
"2020",
"."
] | public class ServiceServer extends HttpServer {
private static final Logger log = getLogger(ServiceServer.class);
private static final AtomicBoolean IS_RUNNING = new AtomicBoolean(true);
private final ConfigHandler configHandler;
// private final PaymentHandler paymentHandler;
public ServiceServer(HttpServerConfig config) throws Exception {
super(config);
ShutdownHookHandler.getInstance().addShutdownHook(() -> {
IS_RUNNING.set(false);
log.info("Terminate HTTP-server");
stop();
}, true);
StateService.getInstance().init();
configHandler = StateService.getInstance().getConfigHandler();
// paymentHandler = StateService.getInstance().getPaymentHandler();
}
/*
@Path("/payment")
@RequestMethod(METHOD_POST)
public void payment(
@Param(value = "serverId", required = true) String serverId,
@Param(value = "adId", required = true) String adId,
@Param(value = "recipient", required = true) String recipient,
@Param(value = "amount", required = true) long amount,
@Param(value = "publicKey", required = true) String publicKey,
HttpSession session,
Request request) throws Exception {
log.debug("POST: {}, {}, {}", request.getPath(), Utf8.toString(request.getBody()), request.getHeaders());
session.sendResponse(paymentHandler.payment(serverId, adId, recipient, amount, publicKey));
}
*/
@Path({"/admin/", "/admin"})
@RequestMethod(METHOD_GET)
public void adminRoot(HttpSession session) throws Exception {
session.sendResponse(Response.redirect("/admin/index.html"));
}
@Path("/admin/configs.html")
public void adminConfigs(HttpSession session) throws Exception {
session.sendResponse(configHandler.adminConfigs());
}
@Path("/admin/config.html")
@RequestMethod(METHOD_POST)
public void adminConfig(HttpSession session, Request request) throws Exception {
String body = Utf8.toString(request.getBody());
log.debug("POST: {}, {}, {}", request.getPath(), body, request.getHeaders());
session.sendResponse(configHandler.adminConfig(body));
}
@Override
public void handleRequest(Request request, HttpSession session) throws IOException {
try {
super.handleRequest(request, session);
} catch (Exception e) {
log.error(e.toString(), e);
session.sendError(INTERNAL_ERROR, INTERNAL_ERROR);
}
}
@Override
public void handleDefault(Request request, HttpSession session) throws IOException {
java.nio.file.Path path = Paths.get(WEB_ROOT, request.getPath());
if (Files.exists(path) && !Files.isDirectory(path)) {
session.sendResponse(Response.ok(Files.readAllBytes(path)));
return;
}
session.sendError(BAD_REQUEST, BAD_REQUEST);
}
public static void main(String[] args) {
try {
HttpServerConfig httpServerConfig = ConfigParser.parse(read(ServiceServer.class.getResource("/http.yml")), HttpServerConfig.class);
ServiceServer serviceServer = new ServiceServer(httpServerConfig);
log.info("Start HTTP-serviceServer, {}:{}", httpServerConfig.acceptors[0].address, httpServerConfig.acceptors[0].port);
serviceServer.start();
} catch (Exception e) {
log.error(e.toString(), e);
System.exit(-1);
}
}
} | [
"public",
"class",
"ServiceServer",
"extends",
"HttpServer",
"{",
"private",
"static",
"final",
"Logger",
"log",
"=",
"getLogger",
"(",
"ServiceServer",
".",
"class",
")",
";",
"private",
"static",
"final",
"AtomicBoolean",
"IS_RUNNING",
"=",
"new",
"AtomicBoolean",
"(",
"true",
")",
";",
"private",
"final",
"ConfigHandler",
"configHandler",
";",
"public",
"ServiceServer",
"(",
"HttpServerConfig",
"config",
")",
"throws",
"Exception",
"{",
"super",
"(",
"config",
")",
";",
"ShutdownHookHandler",
".",
"getInstance",
"(",
")",
".",
"addShutdownHook",
"(",
"(",
")",
"->",
"{",
"IS_RUNNING",
".",
"set",
"(",
"false",
")",
";",
"log",
".",
"info",
"(",
"\"",
"Terminate HTTP-server",
"\"",
")",
";",
"stop",
"(",
")",
";",
"}",
",",
"true",
")",
";",
"StateService",
".",
"getInstance",
"(",
")",
".",
"init",
"(",
")",
";",
"configHandler",
"=",
"StateService",
".",
"getInstance",
"(",
")",
".",
"getConfigHandler",
"(",
")",
";",
"}",
"/*\n @Path(\"/payment\")\n @RequestMethod(METHOD_POST)\n public void payment(\n @Param(value = \"serverId\", required = true) String serverId,\n @Param(value = \"adId\", required = true) String adId,\n @Param(value = \"recipient\", required = true) String recipient,\n @Param(value = \"amount\", required = true) long amount,\n @Param(value = \"publicKey\", required = true) String publicKey,\n\n HttpSession session,\n Request request) throws Exception {\n log.debug(\"POST: {}, {}, {}\", request.getPath(), Utf8.toString(request.getBody()), request.getHeaders());\n\n session.sendResponse(paymentHandler.payment(serverId, adId, recipient, amount, publicKey));\n }\n*/",
"@",
"Path",
"(",
"{",
"\"",
"/admin/",
"\"",
",",
"\"",
"/admin",
"\"",
"}",
")",
"@",
"RequestMethod",
"(",
"METHOD_GET",
")",
"public",
"void",
"adminRoot",
"(",
"HttpSession",
"session",
")",
"throws",
"Exception",
"{",
"session",
".",
"sendResponse",
"(",
"Response",
".",
"redirect",
"(",
"\"",
"/admin/index.html",
"\"",
")",
")",
";",
"}",
"@",
"Path",
"(",
"\"",
"/admin/configs.html",
"\"",
")",
"public",
"void",
"adminConfigs",
"(",
"HttpSession",
"session",
")",
"throws",
"Exception",
"{",
"session",
".",
"sendResponse",
"(",
"configHandler",
".",
"adminConfigs",
"(",
")",
")",
";",
"}",
"@",
"Path",
"(",
"\"",
"/admin/config.html",
"\"",
")",
"@",
"RequestMethod",
"(",
"METHOD_POST",
")",
"public",
"void",
"adminConfig",
"(",
"HttpSession",
"session",
",",
"Request",
"request",
")",
"throws",
"Exception",
"{",
"String",
"body",
"=",
"Utf8",
".",
"toString",
"(",
"request",
".",
"getBody",
"(",
")",
")",
";",
"log",
".",
"debug",
"(",
"\"",
"POST: {}, {}, {}",
"\"",
",",
"request",
".",
"getPath",
"(",
")",
",",
"body",
",",
"request",
".",
"getHeaders",
"(",
")",
")",
";",
"session",
".",
"sendResponse",
"(",
"configHandler",
".",
"adminConfig",
"(",
"body",
")",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"handleRequest",
"(",
"Request",
"request",
",",
"HttpSession",
"session",
")",
"throws",
"IOException",
"{",
"try",
"{",
"super",
".",
"handleRequest",
"(",
"request",
",",
"session",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"session",
".",
"sendError",
"(",
"INTERNAL_ERROR",
",",
"INTERNAL_ERROR",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"handleDefault",
"(",
"Request",
"request",
",",
"HttpSession",
"session",
")",
"throws",
"IOException",
"{",
"java",
".",
"nio",
".",
"file",
".",
"Path",
"path",
"=",
"Paths",
".",
"get",
"(",
"WEB_ROOT",
",",
"request",
".",
"getPath",
"(",
")",
")",
";",
"if",
"(",
"Files",
".",
"exists",
"(",
"path",
")",
"&&",
"!",
"Files",
".",
"isDirectory",
"(",
"path",
")",
")",
"{",
"session",
".",
"sendResponse",
"(",
"Response",
".",
"ok",
"(",
"Files",
".",
"readAllBytes",
"(",
"path",
")",
")",
")",
";",
"return",
";",
"}",
"session",
".",
"sendError",
"(",
"BAD_REQUEST",
",",
"BAD_REQUEST",
")",
";",
"}",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"try",
"{",
"HttpServerConfig",
"httpServerConfig",
"=",
"ConfigParser",
".",
"parse",
"(",
"read",
"(",
"ServiceServer",
".",
"class",
".",
"getResource",
"(",
"\"",
"/http.yml",
"\"",
")",
")",
",",
"HttpServerConfig",
".",
"class",
")",
";",
"ServiceServer",
"serviceServer",
"=",
"new",
"ServiceServer",
"(",
"httpServerConfig",
")",
";",
"log",
".",
"info",
"(",
"\"",
"Start HTTP-serviceServer, {}:{}",
"\"",
",",
"httpServerConfig",
".",
"acceptors",
"[",
"0",
"]",
".",
"address",
",",
"httpServerConfig",
".",
"acceptors",
"[",
"0",
"]",
".",
"port",
")",
";",
"serviceServer",
".",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"error",
"(",
"e",
".",
"toString",
"(",
")",
",",
"e",
")",
";",
"System",
".",
"exit",
"(",
"-",
"1",
")",
";",
"}",
"}",
"}"
] | Created by vbondarenko on 16.05.2020. | [
"Created",
"by",
"vbondarenko",
"on",
"16",
".",
"05",
".",
"2020",
"."
] | [
"// private final PaymentHandler paymentHandler;",
"// paymentHandler = StateService.getInstance().getPaymentHandler();"
] | [
{
"param": "HttpServer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "HttpServer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0738ad7b423dbc16b38cad83ab1d43fa4d671013 | Azquelt/cdi-tck | impl/src/main/java/org/jboss/cdi/tck/util/BeanLookupUtils.java | [
"Apache-2.0"
] | Java | BeanLookupUtils | /**
* Simple helper class for contextual reference lookup.
*
* @author Martin Kouba
*/ | Simple helper class for contextual reference lookup.
@author Martin Kouba | [
"Simple",
"helper",
"class",
"for",
"contextual",
"reference",
"lookup",
".",
"@author",
"Martin",
"Kouba"
] | public final class BeanLookupUtils {
private static final SimpleLogger logger = new SimpleLogger(BeanLookupUtils.class);
private BeanLookupUtils() {
}
/**
*
* @param beanManager
* @param beanType
* @param qualifiers
* @return
*/
public static <T> T getContextualReference(BeanManager beanManager, Class<T> beanType, Annotation... qualifiers) {
Set<Bean<?>> beans = getBeans(beanManager, beanType, qualifiers);
return BeanLookupUtils.<T>getContextualReference(beanManager, beanType, beans);
}
/**
*
* @param beanManager
* @param beanTypeLiteral
* @param qualifiers
* @return
*/
public static <T> T getContextualReference(BeanManager beanManager, TypeLiteral<T> beanTypeLiteral,
Annotation... qualifiers) {
Type beanType = beanTypeLiteral.getType();
Set<Bean<?>> beans = getBeans(beanManager, beanType, qualifiers);
return BeanLookupUtils.<T>getContextualReference(beanManager, beanType, beans);
}
/**
*
* @param beanManager
* @param beanType
* @param name
* @return
*/
public static <T> T getContextualReference(BeanManager beanManager, String name, Class<T> beanType) {
Set<Bean<?>> beans = beanManager.getBeans(name);
if (beans == null || beans.isEmpty()) {
return null;
}
return BeanLookupUtils.<T>getContextualReference(beanManager, beanType, beans);
}
private static Set<Bean<?>> getBeans(BeanManager beanManager, Type beanType, Annotation... qualifiers) {
Set<Bean<?>> beans = beanManager.getBeans(beanType, qualifiers);
if (beans == null || beans.isEmpty()) {
throw new UnsatisfiedResolutionException(String.format(
"No bean matches required type %s and required qualifiers %s", beanType, Arrays.toString(qualifiers)));
}
return beans;
}
@SuppressWarnings("unchecked")
private static <T> T getContextualReference(BeanManager beanManager, Type beanType, Set<Bean<?>> beans) {
Bean<?> bean = beanManager.resolve(beans);
if (bean.getScope().equals(Dependent.class)) {
logger.log("Dependent contextual instance cannot be properly destroyed!");
}
CreationalContext<?> creationalContext = beanManager.createCreationalContext(bean);
return ((T) beanManager.getReference(bean, beanType, creationalContext));
}
} | [
"public",
"final",
"class",
"BeanLookupUtils",
"{",
"private",
"static",
"final",
"SimpleLogger",
"logger",
"=",
"new",
"SimpleLogger",
"(",
"BeanLookupUtils",
".",
"class",
")",
";",
"private",
"BeanLookupUtils",
"(",
")",
"{",
"}",
"/**\n *\n * @param beanManager\n * @param beanType\n * @param qualifiers\n * @return\n */",
"public",
"static",
"<",
"T",
">",
"T",
"getContextualReference",
"(",
"BeanManager",
"beanManager",
",",
"Class",
"<",
"T",
">",
"beanType",
",",
"Annotation",
"...",
"qualifiers",
")",
"{",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
"=",
"getBeans",
"(",
"beanManager",
",",
"beanType",
",",
"qualifiers",
")",
";",
"return",
"BeanLookupUtils",
".",
"<",
"T",
">",
"getContextualReference",
"(",
"beanManager",
",",
"beanType",
",",
"beans",
")",
";",
"}",
"/**\n *\n * @param beanManager\n * @param beanTypeLiteral\n * @param qualifiers\n * @return\n */",
"public",
"static",
"<",
"T",
">",
"T",
"getContextualReference",
"(",
"BeanManager",
"beanManager",
",",
"TypeLiteral",
"<",
"T",
">",
"beanTypeLiteral",
",",
"Annotation",
"...",
"qualifiers",
")",
"{",
"Type",
"beanType",
"=",
"beanTypeLiteral",
".",
"getType",
"(",
")",
";",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
"=",
"getBeans",
"(",
"beanManager",
",",
"beanType",
",",
"qualifiers",
")",
";",
"return",
"BeanLookupUtils",
".",
"<",
"T",
">",
"getContextualReference",
"(",
"beanManager",
",",
"beanType",
",",
"beans",
")",
";",
"}",
"/**\n *\n * @param beanManager\n * @param beanType\n * @param name\n * @return\n */",
"public",
"static",
"<",
"T",
">",
"T",
"getContextualReference",
"(",
"BeanManager",
"beanManager",
",",
"String",
"name",
",",
"Class",
"<",
"T",
">",
"beanType",
")",
"{",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
"=",
"beanManager",
".",
"getBeans",
"(",
"name",
")",
";",
"if",
"(",
"beans",
"==",
"null",
"||",
"beans",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"BeanLookupUtils",
".",
"<",
"T",
">",
"getContextualReference",
"(",
"beanManager",
",",
"beanType",
",",
"beans",
")",
";",
"}",
"private",
"static",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"getBeans",
"(",
"BeanManager",
"beanManager",
",",
"Type",
"beanType",
",",
"Annotation",
"...",
"qualifiers",
")",
"{",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
"=",
"beanManager",
".",
"getBeans",
"(",
"beanType",
",",
"qualifiers",
")",
";",
"if",
"(",
"beans",
"==",
"null",
"||",
"beans",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"UnsatisfiedResolutionException",
"(",
"String",
".",
"format",
"(",
"\"",
"No bean matches required type %s and required qualifiers %s",
"\"",
",",
"beanType",
",",
"Arrays",
".",
"toString",
"(",
"qualifiers",
")",
")",
")",
";",
"}",
"return",
"beans",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"private",
"static",
"<",
"T",
">",
"T",
"getContextualReference",
"(",
"BeanManager",
"beanManager",
",",
"Type",
"beanType",
",",
"Set",
"<",
"Bean",
"<",
"?",
">",
">",
"beans",
")",
"{",
"Bean",
"<",
"?",
">",
"bean",
"=",
"beanManager",
".",
"resolve",
"(",
"beans",
")",
";",
"if",
"(",
"bean",
".",
"getScope",
"(",
")",
".",
"equals",
"(",
"Dependent",
".",
"class",
")",
")",
"{",
"logger",
".",
"log",
"(",
"\"",
"Dependent contextual instance cannot be properly destroyed!",
"\"",
")",
";",
"}",
"CreationalContext",
"<",
"?",
">",
"creationalContext",
"=",
"beanManager",
".",
"createCreationalContext",
"(",
"bean",
")",
";",
"return",
"(",
"(",
"T",
")",
"beanManager",
".",
"getReference",
"(",
"bean",
",",
"beanType",
",",
"creationalContext",
")",
")",
";",
"}",
"}"
] | Simple helper class for contextual reference lookup. | [
"Simple",
"helper",
"class",
"for",
"contextual",
"reference",
"lookup",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
073b188a0716fa100216b9c0969560a7d928fc18 | landsc2pe/P2 | app/src/main/java/com/jayjaylab/lesson/gallery/fragment/FragmentTab4.java | [
"Apache-2.0"
] | Java | FragmentTab4 | /**
* Created by jjkim on 2016. 7. 19..
*/ | Created by jjkim on 2016. 7. 19 | [
"Created",
"by",
"jjkim",
"on",
"2016",
".",
"7",
".",
"19"
] | public class FragmentTab4 extends Fragment {
public static final String TAG = FragmentTab4.class.getSimpleName();
@BindView(R.id.webview) WebView webView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.layout_fragment_tab4, container, false);
init();
return rootView;
}
void init() {
setWebView();
testThreadPool();
}
void testThreadPool() {
// 3 : core pool size
// 5 : maximum pool size
ExecutorService threadPool = new ThreadPoolExecutor(1, 1, 3, TimeUnit.SECONDS,
new ArrayBlockingQueue<Runnable>(100));
threadPool.submit(new Runnable() {
@Override
public void run() {
}
});
threadPool.execute(new Runnable() {
@Override
public void run() {
}
});
}
void setWebView() {
if(LogTag.DEBUG) Log.d(TAG, "setWebView()");
webView.loadUrl("http://m.naver.com/");
webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT);
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
return super.shouldOverrideUrlLoading(view, url);
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
@Override
public void onLoadResource(WebView view, String url) {
super.onLoadResource(view, url);
}
@Override
public void onPageCommitVisible(WebView view, String url) {
super.onPageCommitVisible(view, url);
}
@Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
}
@Override
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
super.onReceivedHttpError(view, request, errorResponse);
}
@Override
public void onFormResubmission(WebView view, Message dontResend, Message resend) {
super.onFormResubmission(view, dontResend, resend);
}
@Override
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
super.doUpdateVisitedHistory(view, url, isReload);
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
}
@Override
public void onReceivedClientCertRequest(WebView view, ClientCertRequest request) {
super.onReceivedClientCertRequest(view, request);
}
@Override
public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
super.onReceivedHttpAuthRequest(view, handler, host, realm);
}
@Override
public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
return super.shouldOverrideKeyEvent(view, event);
}
@Override
public void onUnhandledInputEvent(WebView view, InputEvent event) {
super.onUnhandledInputEvent(view, event);
}
@Override
public void onScaleChanged(WebView view, float oldScale, float newScale) {
super.onScaleChanged(view, oldScale, newScale);
}
@Override
public void onReceivedLoginRequest(WebView view, String realm, String account, String args) {
super.onReceivedLoginRequest(view, realm, account, args);
}
});
webView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
}
@Override
public void onCloseWindow(WebView window) {
super.onCloseWindow(window);
}
@Override
public void onRequestFocus(WebView view) {
super.onRequestFocus(view);
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
return super.onJsConfirm(view, url, message, result);
}
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
return super.onJsPrompt(view, url, message, defaultValue, result);
}
@Override
public boolean onJsBeforeUnload(WebView view, String url, String message, JsResult result) {
return super.onJsBeforeUnload(view, url, message, result);
}
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
return super.onJsAlert(view, url, message, result);
}
});
}
} | [
"public",
"class",
"FragmentTab4",
"extends",
"Fragment",
"{",
"public",
"static",
"final",
"String",
"TAG",
"=",
"FragmentTab4",
".",
"class",
".",
"getSimpleName",
"(",
")",
";",
"@",
"BindView",
"(",
"R",
".",
"id",
".",
"webview",
")",
"WebView",
"webView",
";",
"@",
"Nullable",
"@",
"Override",
"public",
"View",
"onCreateView",
"(",
"LayoutInflater",
"inflater",
",",
"@",
"Nullable",
"ViewGroup",
"container",
",",
"@",
"Nullable",
"Bundle",
"savedInstanceState",
")",
"{",
"View",
"rootView",
"=",
"inflater",
".",
"inflate",
"(",
"R",
".",
"layout",
".",
"layout_fragment_tab4",
",",
"container",
",",
"false",
")",
";",
"init",
"(",
")",
";",
"return",
"rootView",
";",
"}",
"void",
"init",
"(",
")",
"{",
"setWebView",
"(",
")",
";",
"testThreadPool",
"(",
")",
";",
"}",
"void",
"testThreadPool",
"(",
")",
"{",
"ExecutorService",
"threadPool",
"=",
"new",
"ThreadPoolExecutor",
"(",
"1",
",",
"1",
",",
"3",
",",
"TimeUnit",
".",
"SECONDS",
",",
"new",
"ArrayBlockingQueue",
"<",
"Runnable",
">",
"(",
"100",
")",
")",
";",
"threadPool",
".",
"submit",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"}",
"}",
")",
";",
"threadPool",
".",
"execute",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"}",
"}",
")",
";",
"}",
"void",
"setWebView",
"(",
")",
"{",
"if",
"(",
"LogTag",
".",
"DEBUG",
")",
"Log",
".",
"d",
"(",
"TAG",
",",
"\"",
"setWebView()",
"\"",
")",
";",
"webView",
".",
"loadUrl",
"(",
"\"",
"http://m.naver.com/",
"\"",
")",
";",
"webView",
".",
"getSettings",
"(",
")",
".",
"setCacheMode",
"(",
"WebSettings",
".",
"LOAD_DEFAULT",
")",
";",
"webView",
".",
"setWebViewClient",
"(",
"new",
"WebViewClient",
"(",
")",
"{",
"@",
"Override",
"public",
"boolean",
"shouldOverrideUrlLoading",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"return",
"super",
".",
"shouldOverrideUrlLoading",
"(",
"view",
",",
"url",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onPageStarted",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"Bitmap",
"favicon",
")",
"{",
"super",
".",
"onPageStarted",
"(",
"view",
",",
"url",
",",
"favicon",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onPageFinished",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"super",
".",
"onPageFinished",
"(",
"view",
",",
"url",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onLoadResource",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"super",
".",
"onLoadResource",
"(",
"view",
",",
"url",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onPageCommitVisible",
"(",
"WebView",
"view",
",",
"String",
"url",
")",
"{",
"super",
".",
"onPageCommitVisible",
"(",
"view",
",",
"url",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedError",
"(",
"WebView",
"view",
",",
"WebResourceRequest",
"request",
",",
"WebResourceError",
"error",
")",
"{",
"super",
".",
"onReceivedError",
"(",
"view",
",",
"request",
",",
"error",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedHttpError",
"(",
"WebView",
"view",
",",
"WebResourceRequest",
"request",
",",
"WebResourceResponse",
"errorResponse",
")",
"{",
"super",
".",
"onReceivedHttpError",
"(",
"view",
",",
"request",
",",
"errorResponse",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onFormResubmission",
"(",
"WebView",
"view",
",",
"Message",
"dontResend",
",",
"Message",
"resend",
")",
"{",
"super",
".",
"onFormResubmission",
"(",
"view",
",",
"dontResend",
",",
"resend",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"doUpdateVisitedHistory",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"boolean",
"isReload",
")",
"{",
"super",
".",
"doUpdateVisitedHistory",
"(",
"view",
",",
"url",
",",
"isReload",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedSslError",
"(",
"WebView",
"view",
",",
"SslErrorHandler",
"handler",
",",
"SslError",
"error",
")",
"{",
"super",
".",
"onReceivedSslError",
"(",
"view",
",",
"handler",
",",
"error",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedClientCertRequest",
"(",
"WebView",
"view",
",",
"ClientCertRequest",
"request",
")",
"{",
"super",
".",
"onReceivedClientCertRequest",
"(",
"view",
",",
"request",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedHttpAuthRequest",
"(",
"WebView",
"view",
",",
"HttpAuthHandler",
"handler",
",",
"String",
"host",
",",
"String",
"realm",
")",
"{",
"super",
".",
"onReceivedHttpAuthRequest",
"(",
"view",
",",
"handler",
",",
"host",
",",
"realm",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"shouldOverrideKeyEvent",
"(",
"WebView",
"view",
",",
"KeyEvent",
"event",
")",
"{",
"return",
"super",
".",
"shouldOverrideKeyEvent",
"(",
"view",
",",
"event",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onUnhandledInputEvent",
"(",
"WebView",
"view",
",",
"InputEvent",
"event",
")",
"{",
"super",
".",
"onUnhandledInputEvent",
"(",
"view",
",",
"event",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onScaleChanged",
"(",
"WebView",
"view",
",",
"float",
"oldScale",
",",
"float",
"newScale",
")",
"{",
"super",
".",
"onScaleChanged",
"(",
"view",
",",
"oldScale",
",",
"newScale",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onReceivedLoginRequest",
"(",
"WebView",
"view",
",",
"String",
"realm",
",",
"String",
"account",
",",
"String",
"args",
")",
"{",
"super",
".",
"onReceivedLoginRequest",
"(",
"view",
",",
"realm",
",",
"account",
",",
"args",
")",
";",
"}",
"}",
")",
";",
"webView",
".",
"setWebChromeClient",
"(",
"new",
"WebChromeClient",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"onProgressChanged",
"(",
"WebView",
"view",
",",
"int",
"newProgress",
")",
"{",
"super",
".",
"onProgressChanged",
"(",
"view",
",",
"newProgress",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onCloseWindow",
"(",
"WebView",
"window",
")",
"{",
"super",
".",
"onCloseWindow",
"(",
"window",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"onRequestFocus",
"(",
"WebView",
"view",
")",
"{",
"super",
".",
"onRequestFocus",
"(",
"view",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onJsConfirm",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"String",
"message",
",",
"JsResult",
"result",
")",
"{",
"return",
"super",
".",
"onJsConfirm",
"(",
"view",
",",
"url",
",",
"message",
",",
"result",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onJsPrompt",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"String",
"message",
",",
"String",
"defaultValue",
",",
"JsPromptResult",
"result",
")",
"{",
"return",
"super",
".",
"onJsPrompt",
"(",
"view",
",",
"url",
",",
"message",
",",
"defaultValue",
",",
"result",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onJsBeforeUnload",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"String",
"message",
",",
"JsResult",
"result",
")",
"{",
"return",
"super",
".",
"onJsBeforeUnload",
"(",
"view",
",",
"url",
",",
"message",
",",
"result",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onJsAlert",
"(",
"WebView",
"view",
",",
"String",
"url",
",",
"String",
"message",
",",
"JsResult",
"result",
")",
"{",
"return",
"super",
".",
"onJsAlert",
"(",
"view",
",",
"url",
",",
"message",
",",
"result",
")",
";",
"}",
"}",
")",
";",
"}",
"}"
] | Created by jjkim on 2016. | [
"Created",
"by",
"jjkim",
"on",
"2016",
"."
] | [
"// 3 : core pool size",
"// 5 : maximum pool size"
] | [
{
"param": "Fragment",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Fragment",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
073b9cc1b4cbe516c0bb87addad7cff2cd92896b | Xceptance/XCMailr | xcmailr_testsuite/src/modules/pages/account/login/VAccount_Login_validateIsLogin.java | [
"Apache-2.0"
] | Java | VAccount_Login_validateIsLogin | /**
* <p>Validate if user login.</p>
*/ | Validate if user login. | [
"Validate",
"if",
"user",
"login",
"."
] | public class VAccount_Login_validateIsLogin
{
/**
* <p>Validate if user login.</p>
*
*/
public static void execute()
{
assertText("css=.editAccount", "Edit Profile");
}
} | [
"public",
"class",
"VAccount_Login_validateIsLogin",
"{",
"/**\n * <p>Validate if user login.</p>\n *\n */",
"public",
"static",
"void",
"execute",
"(",
")",
"{",
"assertText",
"(",
"\"",
"css=.editAccount",
"\"",
",",
"\"",
"Edit Profile",
"\"",
")",
";",
"}",
"}"
] | <p>Validate if user login.</p> | [
"<p",
">",
"Validate",
"if",
"user",
"login",
".",
"<",
"/",
"p",
">"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
073c5aec7e826d101214df676c21b911c0168baa | anchorimageanalysis/anchor | anchor-core/src/main/java/org/anchoranalysis/core/system/path/ResolvePathAbsolute.java | [
"MIT"
] | Java | ResolvePathAbsolute | /**
* More advanced implementation of {@link Path#resolve}.
*
* <p>It will always return an absolute-path.
*
* <p>If the base-path is a file, rather than a directory, it will consider only the directory
* component, and otherwise proceed.
*
* @author Owen Feehan
*/ | More advanced implementation of Path#resolve.
It will always return an absolute-path.
If the base-path is a file, rather than a directory, it will consider only the directory
component, and otherwise proceed.
@author Owen Feehan | [
"More",
"advanced",
"implementation",
"of",
"Path#resolve",
".",
"It",
"will",
"always",
"return",
"an",
"absolute",
"-",
"path",
".",
"If",
"the",
"base",
"-",
"path",
"is",
"a",
"file",
"rather",
"than",
"a",
"directory",
"it",
"will",
"consider",
"only",
"the",
"directory",
"component",
"and",
"otherwise",
"proceed",
".",
"@author",
"Owen",
"Feehan"
] | @NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ResolvePathAbsolute {
/**
* Like {@link Path#resolve} but with some additional quirks.
*
* <p>Please see the class-description.
*
* @param basePath the base path onto which {@code relativePathToJoin} is joined. It it's a path
* to a file, only the directory component is used.
* @param toJoin normally a relative-path (relative to {@code basePath} but it can also be an
* absolute-path.
* @return an absolute-path to a combination of {@code basePath} and {@code toJoin}, or {@code
* toJoin} alone if it's absolute.
*/
public static Path resolve(Path basePath, Path toJoin) {
// Then we assume it's not a relative-path, take it on its own
if (toJoin.isAbsolute()) {
return toJoin;
}
// If our existing path isn't absolutely, we make it absolute now
if (!basePath.isAbsolute()) {
basePath = basePath.toAbsolutePath();
}
// Otherwise it's a relative path and we combine it
Path totalPath = getPathWithoutFileName(basePath.toString()).resolve(toJoin);
assert totalPath != null;
return totalPath.normalize();
}
private static Path getPathWithoutFileName(String in) {
int index = lastIndexOfEither(in, '/', '\\');
if (index == -1) {
throw new IllegalArgumentException("There is no path without the filename");
}
return Paths.get(in.substring(0, index));
}
private static int lastIndexOfEither(String str, char c1, char c2) {
return Math.max(str.lastIndexOf(c1), str.lastIndexOf(c2));
}
} | [
"@",
"NoArgsConstructor",
"(",
"access",
"=",
"AccessLevel",
".",
"PRIVATE",
")",
"public",
"class",
"ResolvePathAbsolute",
"{",
"/**\n * Like {@link Path#resolve} but with some additional quirks.\n *\n * <p>Please see the class-description.\n *\n * @param basePath the base path onto which {@code relativePathToJoin} is joined. It it's a path\n * to a file, only the directory component is used.\n * @param toJoin normally a relative-path (relative to {@code basePath} but it can also be an\n * absolute-path.\n * @return an absolute-path to a combination of {@code basePath} and {@code toJoin}, or {@code\n * toJoin} alone if it's absolute.\n */",
"public",
"static",
"Path",
"resolve",
"(",
"Path",
"basePath",
",",
"Path",
"toJoin",
")",
"{",
"if",
"(",
"toJoin",
".",
"isAbsolute",
"(",
")",
")",
"{",
"return",
"toJoin",
";",
"}",
"if",
"(",
"!",
"basePath",
".",
"isAbsolute",
"(",
")",
")",
"{",
"basePath",
"=",
"basePath",
".",
"toAbsolutePath",
"(",
")",
";",
"}",
"Path",
"totalPath",
"=",
"getPathWithoutFileName",
"(",
"basePath",
".",
"toString",
"(",
")",
")",
".",
"resolve",
"(",
"toJoin",
")",
";",
"assert",
"totalPath",
"!=",
"null",
";",
"return",
"totalPath",
".",
"normalize",
"(",
")",
";",
"}",
"private",
"static",
"Path",
"getPathWithoutFileName",
"(",
"String",
"in",
")",
"{",
"int",
"index",
"=",
"lastIndexOfEither",
"(",
"in",
",",
"'/'",
",",
"'\\\\'",
")",
";",
"if",
"(",
"index",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"There is no path without the filename",
"\"",
")",
";",
"}",
"return",
"Paths",
".",
"get",
"(",
"in",
".",
"substring",
"(",
"0",
",",
"index",
")",
")",
";",
"}",
"private",
"static",
"int",
"lastIndexOfEither",
"(",
"String",
"str",
",",
"char",
"c1",
",",
"char",
"c2",
")",
"{",
"return",
"Math",
".",
"max",
"(",
"str",
".",
"lastIndexOf",
"(",
"c1",
")",
",",
"str",
".",
"lastIndexOf",
"(",
"c2",
")",
")",
";",
"}",
"}"
] | More advanced implementation of {@link Path#resolve}. | [
"More",
"advanced",
"implementation",
"of",
"{",
"@link",
"Path#resolve",
"}",
"."
] | [
"// Then we assume it's not a relative-path, take it on its own",
"// If our existing path isn't absolutely, we make it absolute now",
"// Otherwise it's a relative path and we combine it"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0743a30e13c7196adc9a4e339b7ad517635326b7 | harikishore-amzur/OpenADR | OpenADRServerVTNCommon/src/main/java/com/avob/openadr/server/common/vtn/VtnConfig.java | [
"Apache-2.0"
] | Java | VtnConfig | /**
* Load vtn configuration from application.properties file
*
* @author bzanni
*
*/ | Load vtn configuration from application.properties file
@author bzanni | [
"Load",
"vtn",
"configuration",
"from",
"application",
".",
"properties",
"file",
"@author",
"bzanni"
] | @Configuration
public class VtnConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(VtnConfig.class);
public static final String CONTEXT_PATH_CONF = "oadr.server.context_path";
public static final String PORT_CONF = "oadr.server.port";
public static final String TRUSTED_CERTIFICATES_CONF = "oadr.security.ven.trustcertificate";
public static final String PRIVATE_KEY_CONF = "oadr.security.vtn.key";
public static final String CERTIFICATE_CONF = "oadr.security.vtn.cert";
public static final String XMPP_PRIVATE_KEY_CONF = "oadr.security.vtn.xmpp.key";
public static final String XMPP_CERTIFICATE_CONF = "oadr.security.vtn.xmpp.cert";
public static final String SUPPORT_PUSH_CONF = "oadr.supportPush";
public static final String SUPPORT_UNSECURED_PHTTP_PUSH_CONF = "oadr.supportUnsecuredHttpPush";
public static final String PULL_FREQUENCY_SECONDS_CONF = "oadr.pullFrequencySeconds";
public static final String HOST_CONF = "oadr.server.host";
public static final String VALIDATE_OADR_PAYLOAD_XSD_CONF = "oadr.validateOadrPayloadAgainstXsd";
public static final String VALIDATE_OADR_PAYLOAD_XSD_FILEPATH_CONF = "oadr.security.validateOadrPayloadAgainstXsdFilePath";
public static final String VTN_ID_CONF = "oadr.vtnid";
public static final String SAVE_VEN_UPDATE_REPORT_CONF = "oadr.saveVenData";
public static final String REPLAY_PROTECTACCEPTED_DELAY_SECONDS_CONF = "oadr.security.replayProtectAcceptedDelaySecond";
public static final String CA_KEY_CONF = "oadr.security.ca.key";
public static final String CA_CERT_CONF = "oadr.security.ca.cert";
public static final String BROKER_USER_CONF = "oadr.broker.user";
public static final String BROKER_PASS_CONF = "oadr.broker.password";
public static final String BROKER_PORT_CONF = "oadr.broker.port";
public static final String BROKER_HOST_CONF = "oadr.broker.host";
public static final String BROKER_SSL_HOST_CONF = "oadr.broker.ssl.host";
public static final String BROKER_SSL_PORT_CONF = "oadr.broker.ssl.port";
public static final String XMPP_HOST_CONF = "oadr.xmpp.host";
public static final String XMPP_PORT_CONF = "oadr.xmpp.port";
public static final String XMPP_DOMAIN_CONF = "oadr.xmpp.domain";
@Value("${" + CONTEXT_PATH_CONF + ":#{null}}")
private String contextPath;
@Value("${" + PORT_CONF + ":#{8443}}")
private int port;
@Value("${" + TRUSTED_CERTIFICATES_CONF + ":#{null}}")
private String trustCertificatesStr;
private List<String> trustCertificates = null;
@Value("${" + PRIVATE_KEY_CONF + ":#{null}}")
private String key;
@Value("${" + CERTIFICATE_CONF + ":#{null}}")
private String cert;
@Value("${" + XMPP_CERTIFICATE_CONF + ":#{null}}")
private String xmppCert;
@Value("${" + XMPP_PRIVATE_KEY_CONF + ":#{null}}")
private String xmppKey;
public String getXmppCert() {
return xmppCert;
}
public String getXmppKey() {
return xmppKey;
}
public SSLContext getXmppSslContext() {
return xmppSslContext;
}
@Value("${" + SUPPORT_PUSH_CONF + ":#{null}}")
private Boolean supportPush;
@Value("${" + SUPPORT_UNSECURED_PHTTP_PUSH_CONF + ":#{false}}")
private Boolean supportUnsecuredHttpPush;
@Value("${" + PULL_FREQUENCY_SECONDS_CONF + ":#{null}}")
private Long pullFrequencySeconds;
@Value("${" + VALIDATE_OADR_PAYLOAD_XSD_CONF + ":#{false}}")
private Boolean validateOadrPayloadAgainstXsd;
@Value("${" + VALIDATE_OADR_PAYLOAD_XSD_FILEPATH_CONF + ":#{null}}")
private String validateOadrPayloadAgainstXsdFilePath;
@Value("${" + VTN_ID_CONF + ":#{null}}")
private String vtnId;
@Value("${" + REPLAY_PROTECTACCEPTED_DELAY_SECONDS_CONF + ":#{1200}}")
private Long replayProtectAcceptedDelaySecond;
@Value("${" + CA_KEY_CONF + ":#{null}}")
private String caKey;
@Value("${" + CA_CERT_CONF + ":#{null}}")
private String caCert;
@Value("${" + BROKER_HOST_CONF + ":localhost}")
private String brokerHost;
@Value("${" + BROKER_PORT_CONF + ":#{null}}")
private Integer brokerPort;
@Value("${" + BROKER_USER_CONF + ":#{null}}")
private String brokerUser;
@Value("${" + BROKER_PASS_CONF + ":#{null}}")
private String brokerPass;
@Value("${" + BROKER_SSL_PORT_CONF + ":#{null}}")
private Integer brokerSslPort;
@Value("${" + BROKER_SSL_HOST_CONF + ":localhost}")
private String brokerSslHost;
@Value("${" + XMPP_HOST_CONF + ":#{null}}")
private String xmppHost;
@Value("${" + XMPP_PORT_CONF + ":#{null}}")
private Integer xmppPort;
@Value("${" + XMPP_DOMAIN_CONF + ":#{null}}")
private String xmppDomain;
@Autowired
private ConfigurableEnvironment env;
private KeyManagerFactory keyManagerFactory;
private TrustManagerFactory trustManagerFactory;
private SSLContext sslContext;
private String oadr20bFingerprint;
private String oadr20aFingerprint;
private KeyManagerFactory xmppKeyManagerFactory;
public KeyManagerFactory getXmppKeyManagerFactory() {
return xmppKeyManagerFactory;
}
public TrustManagerFactory getXmppTrustManagerFactory() {
return xmppTrustManagerFactory;
}
public String getXmppOadr20bFingerprint() {
return xmppOadr20bFingerprint;
}
public String getXmppOadr20aFingerprint() {
return xmppOadr20aFingerprint;
}
private TrustManagerFactory xmppTrustManagerFactory;
private SSLContext xmppSslContext;
private String xmppOadr20bFingerprint;
private String xmppOadr20aFingerprint;
private String brokerUrl;
private String sslBrokerUrl;
@PostConstruct
public void init() {
// load coma separated trust certificate list
if (trustCertificatesStr != null) {
trustCertificates = Arrays.asList(trustCertificatesStr.split(","));
} else {
trustCertificates = new ArrayList<>();
}
// no VTN key/cert conf might be given when using HTTP only transport
if (this.getCert() != null && this.getKey() != null) {
String keystorePassword = UUID.randomUUID().toString();
try {
// get VTN fingerprints
oadr20aFingerprint = OadrFingerprintSecurity.getOadr20aFingerprint(this.getCert());
oadr20bFingerprint = OadrFingerprintSecurity.getOadr20bFingerprint(this.getCert());
trustManagerFactory = OadrPKISecurity.createTrustManagerFactory(trustCertificates);
keyManagerFactory = OadrPKISecurity.createKeyManagerFactory(this.getKey(), this.getCert(),
keystorePassword);
// SSL Context Factory
sslContext = SSLContext.getInstance("TLS");
// init ssl context
String seed = UUID.randomUUID().toString();
getSslContext().init(keyManagerFactory.getKeyManagers(), trustManagerFactory.getTrustManagers(),
new SecureRandom(seed.getBytes()));
// sslContext = OadrPKISecurity.createSSLContext(clientPrivateKeyPemFilePath, clientCertificatePemFilePath, trustCertificates, password)
// init ssl context
} catch (OadrSecurityException | NoSuchAlgorithmException | KeyManagementException e) {
throw new OadrVTNInitializationException(e);
}
} else {
LOGGER.warn(
"VTN " + PRIVATE_KEY_CONF + " or " + CERTIFICATE_CONF + " not given - no HTTP SSL transport supported");
}
if (this.getXmppCert() != null && this.getXmppKey() != null) {
String keystorePassword = UUID.randomUUID().toString();
try {
// get VTN fingerprints
xmppOadr20aFingerprint = OadrFingerprintSecurity.getOadr20aFingerprint(this.getXmppCert());
xmppOadr20bFingerprint = OadrFingerprintSecurity.getOadr20bFingerprint(this.getXmppCert());
xmppTrustManagerFactory = OadrPKISecurity.createTrustManagerFactory(trustCertificates);
xmppKeyManagerFactory = OadrPKISecurity.createKeyManagerFactory(this.getXmppKey(), this.getXmppCert(),
keystorePassword);
// SSL Context Factory
xmppSslContext = SSLContext.getInstance("TLS");
// init ssl context
String seed = UUID.randomUUID().toString();
getXmppSslContext().init(xmppKeyManagerFactory.getKeyManagers(), xmppTrustManagerFactory.getTrustManagers(),
new SecureRandom(seed.getBytes()));
// init ssl context
} catch (OadrSecurityException | NoSuchAlgorithmException | KeyManagementException e) {
throw new OadrVTNInitializationException(e);
}
} else {
LOGGER.warn(
"VTN " + PRIVATE_KEY_CONF + " or " + CERTIFICATE_CONF + " not given - no XMPP transport supported");
}
if (getBrokerPort() == null) {
brokerPort = SocketUtils.findAvailableTcpPort();
}
if (brokerSslPort == null) {
brokerSslPort = SocketUtils.findAvailableTcpPort();
}
brokerUrl = "tcp://" + getBrokerHost() + ":" + getBrokerPort();
sslBrokerUrl = "ssl://" + brokerSslHost + ":" + brokerSslPort;
}
public boolean hasExternalRabbitMQBroker() {
List<String> profiles = Arrays.asList(env.getActiveProfiles());
return profiles.contains("rabbitmq-broker") || profiles.contains("external");
}
public boolean hasInMemoryBroker() {
return !this.hasExternalRabbitMQBroker();
}
public String getContextPath() {
return contextPath;
}
public int getPort() {
return port;
}
public void setPort(int port) {
this.port = port;
}
public List<String> getTrustCertificates() {
return trustCertificates;
}
public String getKey() {
return key;
}
public String getCert() {
return cert;
}
public Boolean getSupportPush() {
return supportPush;
}
public Boolean getSupportUnsecuredHttpPush() {
return supportUnsecuredHttpPush;
}
public Long getPullFrequencySeconds() {
return pullFrequencySeconds;
}
public Boolean getValidateOadrPayloadAgainstXsd() {
return validateOadrPayloadAgainstXsd;
}
public String getVtnId() {
return vtnId;
}
public Long getReplayProtectAcceptedDelaySecond() {
return replayProtectAcceptedDelaySecond;
}
public String getCaKey() {
return caKey;
}
public String getCaCert() {
return caCert;
}
public KeyManagerFactory getKeyManagerFactory() {
return keyManagerFactory;
}
public TrustManagerFactory getTrustManagerFactory() {
return trustManagerFactory;
}
public String getOadr20bFingerprint() {
return oadr20bFingerprint;
}
public String getOadr20aFingerprint() {
return oadr20aFingerprint;
}
public String getBrokerUrl() {
return brokerUrl;
}
public String getSslBrokerUrl() {
return sslBrokerUrl;
}
public String getBrokerUser() {
return brokerUser;
}
public String getBrokerPass() {
return brokerPass;
}
public String getBrokerHost() {
return brokerHost;
}
public Integer getBrokerPort() {
return brokerPort;
}
public String getXmppHost() {
return xmppHost;
}
public Integer getXmppPort() {
return xmppPort;
}
public String getXmppDomain() {
return xmppDomain;
}
public SSLContext getSslContext() {
return sslContext;
}
public String getValidateOadrPayloadAgainstXsdFilePath() {
return validateOadrPayloadAgainstXsdFilePath;
}
} | [
"@",
"Configuration",
"public",
"class",
"VtnConfig",
"{",
"private",
"static",
"final",
"Logger",
"LOGGER",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"VtnConfig",
".",
"class",
")",
";",
"public",
"static",
"final",
"String",
"CONTEXT_PATH_CONF",
"=",
"\"",
"oadr.server.context_path",
"\"",
";",
"public",
"static",
"final",
"String",
"PORT_CONF",
"=",
"\"",
"oadr.server.port",
"\"",
";",
"public",
"static",
"final",
"String",
"TRUSTED_CERTIFICATES_CONF",
"=",
"\"",
"oadr.security.ven.trustcertificate",
"\"",
";",
"public",
"static",
"final",
"String",
"PRIVATE_KEY_CONF",
"=",
"\"",
"oadr.security.vtn.key",
"\"",
";",
"public",
"static",
"final",
"String",
"CERTIFICATE_CONF",
"=",
"\"",
"oadr.security.vtn.cert",
"\"",
";",
"public",
"static",
"final",
"String",
"XMPP_PRIVATE_KEY_CONF",
"=",
"\"",
"oadr.security.vtn.xmpp.key",
"\"",
";",
"public",
"static",
"final",
"String",
"XMPP_CERTIFICATE_CONF",
"=",
"\"",
"oadr.security.vtn.xmpp.cert",
"\"",
";",
"public",
"static",
"final",
"String",
"SUPPORT_PUSH_CONF",
"=",
"\"",
"oadr.supportPush",
"\"",
";",
"public",
"static",
"final",
"String",
"SUPPORT_UNSECURED_PHTTP_PUSH_CONF",
"=",
"\"",
"oadr.supportUnsecuredHttpPush",
"\"",
";",
"public",
"static",
"final",
"String",
"PULL_FREQUENCY_SECONDS_CONF",
"=",
"\"",
"oadr.pullFrequencySeconds",
"\"",
";",
"public",
"static",
"final",
"String",
"HOST_CONF",
"=",
"\"",
"oadr.server.host",
"\"",
";",
"public",
"static",
"final",
"String",
"VALIDATE_OADR_PAYLOAD_XSD_CONF",
"=",
"\"",
"oadr.validateOadrPayloadAgainstXsd",
"\"",
";",
"public",
"static",
"final",
"String",
"VALIDATE_OADR_PAYLOAD_XSD_FILEPATH_CONF",
"=",
"\"",
"oadr.security.validateOadrPayloadAgainstXsdFilePath",
"\"",
";",
"public",
"static",
"final",
"String",
"VTN_ID_CONF",
"=",
"\"",
"oadr.vtnid",
"\"",
";",
"public",
"static",
"final",
"String",
"SAVE_VEN_UPDATE_REPORT_CONF",
"=",
"\"",
"oadr.saveVenData",
"\"",
";",
"public",
"static",
"final",
"String",
"REPLAY_PROTECTACCEPTED_DELAY_SECONDS_CONF",
"=",
"\"",
"oadr.security.replayProtectAcceptedDelaySecond",
"\"",
";",
"public",
"static",
"final",
"String",
"CA_KEY_CONF",
"=",
"\"",
"oadr.security.ca.key",
"\"",
";",
"public",
"static",
"final",
"String",
"CA_CERT_CONF",
"=",
"\"",
"oadr.security.ca.cert",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_USER_CONF",
"=",
"\"",
"oadr.broker.user",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_PASS_CONF",
"=",
"\"",
"oadr.broker.password",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_PORT_CONF",
"=",
"\"",
"oadr.broker.port",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_HOST_CONF",
"=",
"\"",
"oadr.broker.host",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_SSL_HOST_CONF",
"=",
"\"",
"oadr.broker.ssl.host",
"\"",
";",
"public",
"static",
"final",
"String",
"BROKER_SSL_PORT_CONF",
"=",
"\"",
"oadr.broker.ssl.port",
"\"",
";",
"public",
"static",
"final",
"String",
"XMPP_HOST_CONF",
"=",
"\"",
"oadr.xmpp.host",
"\"",
";",
"public",
"static",
"final",
"String",
"XMPP_PORT_CONF",
"=",
"\"",
"oadr.xmpp.port",
"\"",
";",
"public",
"static",
"final",
"String",
"XMPP_DOMAIN_CONF",
"=",
"\"",
"oadr.xmpp.domain",
"\"",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"CONTEXT_PATH_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"contextPath",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"PORT_CONF",
"+",
"\"",
":#{8443}}",
"\"",
")",
"private",
"int",
"port",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"TRUSTED_CERTIFICATES_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"trustCertificatesStr",
";",
"private",
"List",
"<",
"String",
">",
"trustCertificates",
"=",
"null",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"PRIVATE_KEY_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"key",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"CERTIFICATE_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"cert",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"XMPP_CERTIFICATE_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"xmppCert",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"XMPP_PRIVATE_KEY_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"xmppKey",
";",
"public",
"String",
"getXmppCert",
"(",
")",
"{",
"return",
"xmppCert",
";",
"}",
"public",
"String",
"getXmppKey",
"(",
")",
"{",
"return",
"xmppKey",
";",
"}",
"public",
"SSLContext",
"getXmppSslContext",
"(",
")",
"{",
"return",
"xmppSslContext",
";",
"}",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"SUPPORT_PUSH_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"Boolean",
"supportPush",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"SUPPORT_UNSECURED_PHTTP_PUSH_CONF",
"+",
"\"",
":#{false}}",
"\"",
")",
"private",
"Boolean",
"supportUnsecuredHttpPush",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"PULL_FREQUENCY_SECONDS_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"Long",
"pullFrequencySeconds",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"VALIDATE_OADR_PAYLOAD_XSD_CONF",
"+",
"\"",
":#{false}}",
"\"",
")",
"private",
"Boolean",
"validateOadrPayloadAgainstXsd",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"VALIDATE_OADR_PAYLOAD_XSD_FILEPATH_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"validateOadrPayloadAgainstXsdFilePath",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"VTN_ID_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"vtnId",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"REPLAY_PROTECTACCEPTED_DELAY_SECONDS_CONF",
"+",
"\"",
":#{1200}}",
"\"",
")",
"private",
"Long",
"replayProtectAcceptedDelaySecond",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"CA_KEY_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"caKey",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"CA_CERT_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"caCert",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_HOST_CONF",
"+",
"\"",
":localhost}",
"\"",
")",
"private",
"String",
"brokerHost",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_PORT_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"Integer",
"brokerPort",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_USER_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"brokerUser",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_PASS_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"brokerPass",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_SSL_PORT_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"Integer",
"brokerSslPort",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"BROKER_SSL_HOST_CONF",
"+",
"\"",
":localhost}",
"\"",
")",
"private",
"String",
"brokerSslHost",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"XMPP_HOST_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"xmppHost",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"XMPP_PORT_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"Integer",
"xmppPort",
";",
"@",
"Value",
"(",
"\"",
"${",
"\"",
"+",
"XMPP_DOMAIN_CONF",
"+",
"\"",
":#{null}}",
"\"",
")",
"private",
"String",
"xmppDomain",
";",
"@",
"Autowired",
"private",
"ConfigurableEnvironment",
"env",
";",
"private",
"KeyManagerFactory",
"keyManagerFactory",
";",
"private",
"TrustManagerFactory",
"trustManagerFactory",
";",
"private",
"SSLContext",
"sslContext",
";",
"private",
"String",
"oadr20bFingerprint",
";",
"private",
"String",
"oadr20aFingerprint",
";",
"private",
"KeyManagerFactory",
"xmppKeyManagerFactory",
";",
"public",
"KeyManagerFactory",
"getXmppKeyManagerFactory",
"(",
")",
"{",
"return",
"xmppKeyManagerFactory",
";",
"}",
"public",
"TrustManagerFactory",
"getXmppTrustManagerFactory",
"(",
")",
"{",
"return",
"xmppTrustManagerFactory",
";",
"}",
"public",
"String",
"getXmppOadr20bFingerprint",
"(",
")",
"{",
"return",
"xmppOadr20bFingerprint",
";",
"}",
"public",
"String",
"getXmppOadr20aFingerprint",
"(",
")",
"{",
"return",
"xmppOadr20aFingerprint",
";",
"}",
"private",
"TrustManagerFactory",
"xmppTrustManagerFactory",
";",
"private",
"SSLContext",
"xmppSslContext",
";",
"private",
"String",
"xmppOadr20bFingerprint",
";",
"private",
"String",
"xmppOadr20aFingerprint",
";",
"private",
"String",
"brokerUrl",
";",
"private",
"String",
"sslBrokerUrl",
";",
"@",
"PostConstruct",
"public",
"void",
"init",
"(",
")",
"{",
"if",
"(",
"trustCertificatesStr",
"!=",
"null",
")",
"{",
"trustCertificates",
"=",
"Arrays",
".",
"asList",
"(",
"trustCertificatesStr",
".",
"split",
"(",
"\"",
",",
"\"",
")",
")",
";",
"}",
"else",
"{",
"trustCertificates",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"}",
"if",
"(",
"this",
".",
"getCert",
"(",
")",
"!=",
"null",
"&&",
"this",
".",
"getKey",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"keystorePassword",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"try",
"{",
"oadr20aFingerprint",
"=",
"OadrFingerprintSecurity",
".",
"getOadr20aFingerprint",
"(",
"this",
".",
"getCert",
"(",
")",
")",
";",
"oadr20bFingerprint",
"=",
"OadrFingerprintSecurity",
".",
"getOadr20bFingerprint",
"(",
"this",
".",
"getCert",
"(",
")",
")",
";",
"trustManagerFactory",
"=",
"OadrPKISecurity",
".",
"createTrustManagerFactory",
"(",
"trustCertificates",
")",
";",
"keyManagerFactory",
"=",
"OadrPKISecurity",
".",
"createKeyManagerFactory",
"(",
"this",
".",
"getKey",
"(",
")",
",",
"this",
".",
"getCert",
"(",
")",
",",
"keystorePassword",
")",
";",
"sslContext",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"",
"TLS",
"\"",
")",
";",
"String",
"seed",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"getSslContext",
"(",
")",
".",
"init",
"(",
"keyManagerFactory",
".",
"getKeyManagers",
"(",
")",
",",
"trustManagerFactory",
".",
"getTrustManagers",
"(",
")",
",",
"new",
"SecureRandom",
"(",
"seed",
".",
"getBytes",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"OadrSecurityException",
"|",
"NoSuchAlgorithmException",
"|",
"KeyManagementException",
"e",
")",
"{",
"throw",
"new",
"OadrVTNInitializationException",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"",
"VTN ",
"\"",
"+",
"PRIVATE_KEY_CONF",
"+",
"\"",
" or ",
"\"",
"+",
"CERTIFICATE_CONF",
"+",
"\"",
" not given - no HTTP SSL transport supported",
"\"",
")",
";",
"}",
"if",
"(",
"this",
".",
"getXmppCert",
"(",
")",
"!=",
"null",
"&&",
"this",
".",
"getXmppKey",
"(",
")",
"!=",
"null",
")",
"{",
"String",
"keystorePassword",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"try",
"{",
"xmppOadr20aFingerprint",
"=",
"OadrFingerprintSecurity",
".",
"getOadr20aFingerprint",
"(",
"this",
".",
"getXmppCert",
"(",
")",
")",
";",
"xmppOadr20bFingerprint",
"=",
"OadrFingerprintSecurity",
".",
"getOadr20bFingerprint",
"(",
"this",
".",
"getXmppCert",
"(",
")",
")",
";",
"xmppTrustManagerFactory",
"=",
"OadrPKISecurity",
".",
"createTrustManagerFactory",
"(",
"trustCertificates",
")",
";",
"xmppKeyManagerFactory",
"=",
"OadrPKISecurity",
".",
"createKeyManagerFactory",
"(",
"this",
".",
"getXmppKey",
"(",
")",
",",
"this",
".",
"getXmppCert",
"(",
")",
",",
"keystorePassword",
")",
";",
"xmppSslContext",
"=",
"SSLContext",
".",
"getInstance",
"(",
"\"",
"TLS",
"\"",
")",
";",
"String",
"seed",
"=",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
";",
"getXmppSslContext",
"(",
")",
".",
"init",
"(",
"xmppKeyManagerFactory",
".",
"getKeyManagers",
"(",
")",
",",
"xmppTrustManagerFactory",
".",
"getTrustManagers",
"(",
")",
",",
"new",
"SecureRandom",
"(",
"seed",
".",
"getBytes",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"OadrSecurityException",
"|",
"NoSuchAlgorithmException",
"|",
"KeyManagementException",
"e",
")",
"{",
"throw",
"new",
"OadrVTNInitializationException",
"(",
"e",
")",
";",
"}",
"}",
"else",
"{",
"LOGGER",
".",
"warn",
"(",
"\"",
"VTN ",
"\"",
"+",
"PRIVATE_KEY_CONF",
"+",
"\"",
" or ",
"\"",
"+",
"CERTIFICATE_CONF",
"+",
"\"",
" not given - no XMPP transport supported",
"\"",
")",
";",
"}",
"if",
"(",
"getBrokerPort",
"(",
")",
"==",
"null",
")",
"{",
"brokerPort",
"=",
"SocketUtils",
".",
"findAvailableTcpPort",
"(",
")",
";",
"}",
"if",
"(",
"brokerSslPort",
"==",
"null",
")",
"{",
"brokerSslPort",
"=",
"SocketUtils",
".",
"findAvailableTcpPort",
"(",
")",
";",
"}",
"brokerUrl",
"=",
"\"",
"tcp://",
"\"",
"+",
"getBrokerHost",
"(",
")",
"+",
"\"",
":",
"\"",
"+",
"getBrokerPort",
"(",
")",
";",
"sslBrokerUrl",
"=",
"\"",
"ssl://",
"\"",
"+",
"brokerSslHost",
"+",
"\"",
":",
"\"",
"+",
"brokerSslPort",
";",
"}",
"public",
"boolean",
"hasExternalRabbitMQBroker",
"(",
")",
"{",
"List",
"<",
"String",
">",
"profiles",
"=",
"Arrays",
".",
"asList",
"(",
"env",
".",
"getActiveProfiles",
"(",
")",
")",
";",
"return",
"profiles",
".",
"contains",
"(",
"\"",
"rabbitmq-broker",
"\"",
")",
"||",
"profiles",
".",
"contains",
"(",
"\"",
"external",
"\"",
")",
";",
"}",
"public",
"boolean",
"hasInMemoryBroker",
"(",
")",
"{",
"return",
"!",
"this",
".",
"hasExternalRabbitMQBroker",
"(",
")",
";",
"}",
"public",
"String",
"getContextPath",
"(",
")",
"{",
"return",
"contextPath",
";",
"}",
"public",
"int",
"getPort",
"(",
")",
"{",
"return",
"port",
";",
"}",
"public",
"void",
"setPort",
"(",
"int",
"port",
")",
"{",
"this",
".",
"port",
"=",
"port",
";",
"}",
"public",
"List",
"<",
"String",
">",
"getTrustCertificates",
"(",
")",
"{",
"return",
"trustCertificates",
";",
"}",
"public",
"String",
"getKey",
"(",
")",
"{",
"return",
"key",
";",
"}",
"public",
"String",
"getCert",
"(",
")",
"{",
"return",
"cert",
";",
"}",
"public",
"Boolean",
"getSupportPush",
"(",
")",
"{",
"return",
"supportPush",
";",
"}",
"public",
"Boolean",
"getSupportUnsecuredHttpPush",
"(",
")",
"{",
"return",
"supportUnsecuredHttpPush",
";",
"}",
"public",
"Long",
"getPullFrequencySeconds",
"(",
")",
"{",
"return",
"pullFrequencySeconds",
";",
"}",
"public",
"Boolean",
"getValidateOadrPayloadAgainstXsd",
"(",
")",
"{",
"return",
"validateOadrPayloadAgainstXsd",
";",
"}",
"public",
"String",
"getVtnId",
"(",
")",
"{",
"return",
"vtnId",
";",
"}",
"public",
"Long",
"getReplayProtectAcceptedDelaySecond",
"(",
")",
"{",
"return",
"replayProtectAcceptedDelaySecond",
";",
"}",
"public",
"String",
"getCaKey",
"(",
")",
"{",
"return",
"caKey",
";",
"}",
"public",
"String",
"getCaCert",
"(",
")",
"{",
"return",
"caCert",
";",
"}",
"public",
"KeyManagerFactory",
"getKeyManagerFactory",
"(",
")",
"{",
"return",
"keyManagerFactory",
";",
"}",
"public",
"TrustManagerFactory",
"getTrustManagerFactory",
"(",
")",
"{",
"return",
"trustManagerFactory",
";",
"}",
"public",
"String",
"getOadr20bFingerprint",
"(",
")",
"{",
"return",
"oadr20bFingerprint",
";",
"}",
"public",
"String",
"getOadr20aFingerprint",
"(",
")",
"{",
"return",
"oadr20aFingerprint",
";",
"}",
"public",
"String",
"getBrokerUrl",
"(",
")",
"{",
"return",
"brokerUrl",
";",
"}",
"public",
"String",
"getSslBrokerUrl",
"(",
")",
"{",
"return",
"sslBrokerUrl",
";",
"}",
"public",
"String",
"getBrokerUser",
"(",
")",
"{",
"return",
"brokerUser",
";",
"}",
"public",
"String",
"getBrokerPass",
"(",
")",
"{",
"return",
"brokerPass",
";",
"}",
"public",
"String",
"getBrokerHost",
"(",
")",
"{",
"return",
"brokerHost",
";",
"}",
"public",
"Integer",
"getBrokerPort",
"(",
")",
"{",
"return",
"brokerPort",
";",
"}",
"public",
"String",
"getXmppHost",
"(",
")",
"{",
"return",
"xmppHost",
";",
"}",
"public",
"Integer",
"getXmppPort",
"(",
")",
"{",
"return",
"xmppPort",
";",
"}",
"public",
"String",
"getXmppDomain",
"(",
")",
"{",
"return",
"xmppDomain",
";",
"}",
"public",
"SSLContext",
"getSslContext",
"(",
")",
"{",
"return",
"sslContext",
";",
"}",
"public",
"String",
"getValidateOadrPayloadAgainstXsdFilePath",
"(",
")",
"{",
"return",
"validateOadrPayloadAgainstXsdFilePath",
";",
"}",
"}"
] | Load vtn configuration from application.properties file | [
"Load",
"vtn",
"configuration",
"from",
"application",
".",
"properties",
"file"
] | [
"// load coma separated trust certificate list",
"// no VTN key/cert conf might be given when using HTTP only transport",
"// get VTN fingerprints",
"// SSL Context Factory",
"// init ssl context",
"//\t\t\t\tsslContext = OadrPKISecurity.createSSLContext(clientPrivateKeyPemFilePath, clientCertificatePemFilePath, trustCertificates, password)",
"// init ssl context",
"// get VTN fingerprints",
"// SSL Context Factory",
"// init ssl context",
"// init ssl context"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
07441699345ec1824decb64e9bd7f2e2caa83900 | joshua-gould/igv | src/main/java/org/broad/igv/ui/IGVContentPane.java | [
"MIT"
] | Java | IGVContentPane | /**
* The content pane for the IGV main window.
*/ | The content pane for the IGV main window. | [
"The",
"content",
"pane",
"for",
"the",
"IGV",
"main",
"window",
"."
] | public class IGVContentPane extends JPanel {
private static Logger log = Logger.getLogger(IGVContentPane.class);
private JPanel commandBarPanel;
private IGVCommandBar igvCommandBar;
private MainPanel mainPanel;
private ApplicationStatusBar statusBar;
private IGV igv;
/**
* Creates new form IGV
*/
public IGVContentPane(IGV igv) {
setOpaque(true); // Required by Swing
this.igv = igv;
// Create components
setLayout(new BorderLayout());
commandBarPanel = new JPanel();
BoxLayout layout = new BoxLayout(commandBarPanel, BoxLayout.PAGE_AXIS);
commandBarPanel.setLayout(layout);
add(commandBarPanel, BorderLayout.NORTH);
igvCommandBar = new IGVCommandBar();
igvCommandBar.setMinimumSize(new Dimension(250, 33));
igvCommandBar.setBorder(new BasicBorders.MenuBarBorder(Color.GRAY, Color.GRAY));
igvCommandBar.setAlignmentX(Component.BOTTOM_ALIGNMENT);
commandBarPanel.add(igvCommandBar);
mainPanel = new MainPanel(igv);
add(mainPanel, BorderLayout.CENTER);
statusBar = new ApplicationStatusBar();
statusBar.setDebugGraphicsOptions(javax.swing.DebugGraphics.NONE_OPTION);
add(statusBar, BorderLayout.SOUTH);
}
public void addCommandBar(JComponent component) {
component.setBorder(new BasicBorders.MenuBarBorder(Color.GRAY, Color.GRAY));
component.setAlignmentX(Component.BOTTOM_ALIGNMENT);
commandBarPanel.add(component);
commandBarPanel.invalidate();
}
@Override
public Dimension getPreferredSize() {
return UIConstants.preferredSize;
}
public void revalidateTrackPanels() {
for (TrackPanel tp : mainPanel.getTrackPanels()) {
tp.getScrollPane().getDataPanel().revalidate();
}
}
public void validateTrackPanels() {
for (TrackPanel tp : mainPanel.getTrackPanels()) {
tp.getScrollPane().getDataPanel().validate();
}
}
/**
* Reset the default status message, which is the number of tracks loaded.
*/
public void resetStatusMessage() {
statusBar.setMessage("" + igv.getVisibleTrackCount() + " tracks loaded");
}
public MainPanel getMainPanel() {
return mainPanel;
}
public IGVCommandBar getCommandBar() {
return igvCommandBar;
}
public ApplicationStatusBar getStatusBar() {
return statusBar;
}
} | [
"public",
"class",
"IGVContentPane",
"extends",
"JPanel",
"{",
"private",
"static",
"Logger",
"log",
"=",
"Logger",
".",
"getLogger",
"(",
"IGVContentPane",
".",
"class",
")",
";",
"private",
"JPanel",
"commandBarPanel",
";",
"private",
"IGVCommandBar",
"igvCommandBar",
";",
"private",
"MainPanel",
"mainPanel",
";",
"private",
"ApplicationStatusBar",
"statusBar",
";",
"private",
"IGV",
"igv",
";",
"/**\n * Creates new form IGV\n */",
"public",
"IGVContentPane",
"(",
"IGV",
"igv",
")",
"{",
"setOpaque",
"(",
"true",
")",
";",
"this",
".",
"igv",
"=",
"igv",
";",
"setLayout",
"(",
"new",
"BorderLayout",
"(",
")",
")",
";",
"commandBarPanel",
"=",
"new",
"JPanel",
"(",
")",
";",
"BoxLayout",
"layout",
"=",
"new",
"BoxLayout",
"(",
"commandBarPanel",
",",
"BoxLayout",
".",
"PAGE_AXIS",
")",
";",
"commandBarPanel",
".",
"setLayout",
"(",
"layout",
")",
";",
"add",
"(",
"commandBarPanel",
",",
"BorderLayout",
".",
"NORTH",
")",
";",
"igvCommandBar",
"=",
"new",
"IGVCommandBar",
"(",
")",
";",
"igvCommandBar",
".",
"setMinimumSize",
"(",
"new",
"Dimension",
"(",
"250",
",",
"33",
")",
")",
";",
"igvCommandBar",
".",
"setBorder",
"(",
"new",
"BasicBorders",
".",
"MenuBarBorder",
"(",
"Color",
".",
"GRAY",
",",
"Color",
".",
"GRAY",
")",
")",
";",
"igvCommandBar",
".",
"setAlignmentX",
"(",
"Component",
".",
"BOTTOM_ALIGNMENT",
")",
";",
"commandBarPanel",
".",
"add",
"(",
"igvCommandBar",
")",
";",
"mainPanel",
"=",
"new",
"MainPanel",
"(",
"igv",
")",
";",
"add",
"(",
"mainPanel",
",",
"BorderLayout",
".",
"CENTER",
")",
";",
"statusBar",
"=",
"new",
"ApplicationStatusBar",
"(",
")",
";",
"statusBar",
".",
"setDebugGraphicsOptions",
"(",
"javax",
".",
"swing",
".",
"DebugGraphics",
".",
"NONE_OPTION",
")",
";",
"add",
"(",
"statusBar",
",",
"BorderLayout",
".",
"SOUTH",
")",
";",
"}",
"public",
"void",
"addCommandBar",
"(",
"JComponent",
"component",
")",
"{",
"component",
".",
"setBorder",
"(",
"new",
"BasicBorders",
".",
"MenuBarBorder",
"(",
"Color",
".",
"GRAY",
",",
"Color",
".",
"GRAY",
")",
")",
";",
"component",
".",
"setAlignmentX",
"(",
"Component",
".",
"BOTTOM_ALIGNMENT",
")",
";",
"commandBarPanel",
".",
"add",
"(",
"component",
")",
";",
"commandBarPanel",
".",
"invalidate",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Dimension",
"getPreferredSize",
"(",
")",
"{",
"return",
"UIConstants",
".",
"preferredSize",
";",
"}",
"public",
"void",
"revalidateTrackPanels",
"(",
")",
"{",
"for",
"(",
"TrackPanel",
"tp",
":",
"mainPanel",
".",
"getTrackPanels",
"(",
")",
")",
"{",
"tp",
".",
"getScrollPane",
"(",
")",
".",
"getDataPanel",
"(",
")",
".",
"revalidate",
"(",
")",
";",
"}",
"}",
"public",
"void",
"validateTrackPanels",
"(",
")",
"{",
"for",
"(",
"TrackPanel",
"tp",
":",
"mainPanel",
".",
"getTrackPanels",
"(",
")",
")",
"{",
"tp",
".",
"getScrollPane",
"(",
")",
".",
"getDataPanel",
"(",
")",
".",
"validate",
"(",
")",
";",
"}",
"}",
"/**\n * Reset the default status message, which is the number of tracks loaded.\n */",
"public",
"void",
"resetStatusMessage",
"(",
")",
"{",
"statusBar",
".",
"setMessage",
"(",
"\"",
"\"",
"+",
"igv",
".",
"getVisibleTrackCount",
"(",
")",
"+",
"\"",
" tracks loaded",
"\"",
")",
";",
"}",
"public",
"MainPanel",
"getMainPanel",
"(",
")",
"{",
"return",
"mainPanel",
";",
"}",
"public",
"IGVCommandBar",
"getCommandBar",
"(",
")",
"{",
"return",
"igvCommandBar",
";",
"}",
"public",
"ApplicationStatusBar",
"getStatusBar",
"(",
")",
"{",
"return",
"statusBar",
";",
"}",
"}"
] | The content pane for the IGV main window. | [
"The",
"content",
"pane",
"for",
"the",
"IGV",
"main",
"window",
"."
] | [
"// Required by Swing",
"// Create components"
] | [
{
"param": "JPanel",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "JPanel",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
074525719ac2de2dcb049e8f508448c2f22e5361 | AcoliteSystem/Acolite | src/com/acolite/util/Sys.java | [
"MIT"
] | Java | Sys | /**
* TEEEEEEEEH
* <p>This class lets you determine which system your Java application runs on. Furthermore, it offers
* methods for cross-platform queries for certain paths such as the preferences folder. It is used as
* follows:
* <p><pre> if (Sys.isMacOSX())
* {
* // Mac OS X-specific code goes here...
* }
* else
* {
* // code for other systems
* }
*
* // store user's configuration data
* DataOutputStream out = new DataOutputStream(
* new BufferedOutputStream(
* new FileOutputStream(
* new File( Sys.getPrefsDirectory(), "config.dat" )
* )));
* //...</pre>
* <p>The latest Sys version can be found at
* <a href="http://www.muchsoft.com/java/">http://www.muchsoft.com/java/</a>.
* <p>Copyright 1998-2004 by Thomas Much, <a href="mailto:[email protected]">[email protected]</a>.
* <br>This class is free for commercial and non-commercial use,
* as long as you do not distribute modified versions of the source code.
* If you have any suggestions, bug reports or feature requests, let me know.
* <p><b>Version History:</b></p>
* <dl>
* <dt> 2004-10-13
* <dd> Added a new package, com.muchsoft.util.mac, and a new class, {@link Mac}.
* <dt> 2004-05-04
* <dd> isMacOSX() now matches <a href="http://developer.apple.com/technotes/tn2002/tn2110.html">http://developer.apple.com/technotes/tn2002/tn2110.html</a>
* <dt> 2003-12-02
* <dd> First public release.
* </dl>
*
* @author Thomas Much
* @version 2004-10-13
*/ | TEEEEEEEEH
This class lets you determine which system your Java application runs on. Furthermore, it offers
methods for cross-platform queries for certain paths such as the preferences folder. It is used as
follows:
if (Sys.isMacOSX())
{
Mac OS X-specific code goes here
}
else
{
code for other systems
}
@author Thomas Much
@version 2004-10-13 | [
"TEEEEEEEEH",
"This",
"class",
"lets",
"you",
"determine",
"which",
"system",
"your",
"Java",
"application",
"runs",
"on",
".",
"Furthermore",
"it",
"offers",
"methods",
"for",
"cross",
"-",
"platform",
"queries",
"for",
"certain",
"paths",
"such",
"as",
"the",
"preferences",
"folder",
".",
"It",
"is",
"used",
"as",
"follows",
":",
"if",
"(",
"Sys",
".",
"isMacOSX",
"()",
")",
"{",
"Mac",
"OS",
"X",
"-",
"specific",
"code",
"goes",
"here",
"}",
"else",
"{",
"code",
"for",
"other",
"systems",
"}",
"@author",
"Thomas",
"Much",
"@version",
"2004",
"-",
"10",
"-",
"13"
] | public class Sys {
private static final boolean ismacos;
private static final boolean ismacosx;
private static final boolean islinux;
private static final boolean iswindows;
private static final boolean isos2;
private static final String homeDir = System.getProperty("user.home");
private static final String workDir = System.getProperty("user.dir");
private static final String prefDir;
private static final String localPrefDir;
private static final String javaHome;
static {
String osname = System.getProperty("os.name");
String vendor = System.getProperty("java.vendor");
String jhome = System.getProperty("java.home");
ismacosx = osname.toLowerCase().startsWith("mac os x");
ismacos = (!ismacosx) && ((vendor.indexOf("Apple") >= 0) || (osname.indexOf("Mac OS") >= 0));
islinux = (osname.indexOf("Linux") >= 0);
iswindows = (osname.indexOf("Windows") >= 0);
isos2 = (osname.indexOf("OS/2") >= 0);
if (ismacosx)
{
String pref = homeDir + "/Library/Preferences";
String localPref = "/Library/Preferences";
/* // this way we'd do it ultra-correctly on Mac OS X / Java 1.4,
// but then all Java apps would get a menu bar, which might not
// be suitable for all situations
try
{
Class fileman = Class.forName("com.apple.eio.FileManager");
java.lang.reflect.Method findFolder =
fileman.getMethod("findFolder", new Class[] { short.class, int.class });
final int kPreferencesFolderType = 0x70726566;
final short kUserDomain = -32763;
final short kLocalDomain = -32765;
pref = (String)findFolder.invoke(null,
new Object[] { new Short(kUserDomain), new Integer(kPreferencesFolderType) });
localPref = (String)findFolder.invoke(null,
new Object[] { new Short(kLocalDomain), new Integer(kPreferencesFolderType) });
}
catch (Exception e) {} */
prefDir = pref;
localPrefDir = localPref;
if ((jhome == null) || (jhome.length() == 0))
{
jhome = "/Library/Java/Home";
}
}
else
{
prefDir = homeDir;
localPrefDir = (islinux) ? "/etc" : workDir;
}
javaHome = jhome;
}
private Sys() { }
/**
* @return <code>true</code>, if the application is running on Mac OS 8/9, <code>false</code> otherwise
*/
public static boolean isMacOS() {
return ismacos;
}
/**
* @return <code>true</code>, if the application is running on Mac OS X, <code>false</code> otherwise
*/
public static boolean isMacOSX() {
return ismacosx;
}
/**
* @return <code>true</code>, if the application is running on a Mac (OS 8, 9 or X), <code>false</code> otherwise
*/
public static boolean isAMac() {
return (ismacosx || ismacos);
}
/**
* @return <code>true</code>, if the application is running on Linux, <code>false</code> otherwise
*/
public static boolean isLinux() {
return islinux;
}
/**
* @return <code>true</code>, if the application is running on Windows, <code>false</code> otherwise
*/
public static boolean isWindows() {
return iswindows;
}
/**
* @return <code>true</code>, if the application is running on OS/2, <code>false</code> otherwise
*/
public static boolean isOS2() {
return isos2;
}
/**
* The home directory contains the user's data and applications. On UNIX systems this directory is denoted
* by <code>~</code> and can be queried through the system property <code>user.home</code>.
* @return the user's home directory without a trailing path separator
*/
public static String getHomeDirectory() {
return homeDir;
}
/**
* The directory from which the application was launched is called the working directory. Its path can
* be queried through the system property <code>user.dir</code>.
* @return the application's working directory without a trailing path separator
*/
public static String getWorkingDirectory() {
return workDir;
}
/**
* The preferences directory contains the user's configuration files. On Mac OS X, this method returns
* <code>~/Library/Preferences</code>, on all other systems the user's home directory is used.
* @return the user's preferences directory without a trailing path separator
*/
public static String getPrefsDirectory() {
return prefDir;
}
/**
* The local preferences directory contains configuration files that are shared by all users on the computer.
* On Mac OS X, this method returns <code>/Library/Preferences</code>, on Linux <code>/etc</code>. On all
* other systems the application's working directory is used.
* <i>Please note: There is no guarantee that your application has permission to use this directory!</i>
* @return the shared preferences directory (without a trailing path separator) of all users on a local computer
*/
public static String getLocalPrefsDirectory() {
return localPrefDir;
}
/**
* The Java home directory contains the <code>bin</code> subdirectory and is needed to invoke the Java tools
* at runtime. It is specified by the environment variable <code>$JAVA_HOME</code> and can be queried through
* the system property <code>java.home</code>. If the variable is not set properly, this method returns
* <code>/Library/Java/Home</code> on Mac OS X.
* @return the Java home directory without a trailing path separator
*/
public static String getJavaHome() {
return javaHome;
}
/**
* This is a small test case for all the methods in this class.
* On Mac OS X you can launch it by simply double-clicking the jar file (output goes to the Console).
* On other systems, you can start it with <code>java -classpath .:Sys.jar com.muchsoft.util.Sys</code>
* (or <code>java -jar Sys.jar</code>)
* @param args not used
*/
public static void main(String[] args) {
System.out.println();
System.out.println("** com.muchsoft.util.Sys version 2004-10-13");
System.out.println("**");
System.out.println("** JavaHome: " + getJavaHome());
System.out.println("** AppWork: " + getWorkingDirectory());
System.out.println("** UserHome: " + getHomeDirectory());
System.out.println("** UserPrefs: " + getPrefsDirectory());
System.out.println("** LocalPrefs: " + getLocalPrefsDirectory());
System.out.println("**");
System.out.print( "** System: ");
if (isMacOSX())
{
System.out.println("Mac OS X");
}
else if (isMacOS())
{
System.out.println("Mac OS 8/9");
}
else if (isLinux())
{
System.out.println("Linux");
}
else if (isWindows())
{
System.out.println("Windows");
}
else if (isOS2())
{
System.out.println("OS/2");
}
else
{
System.out.println("unknown");
}
System.out.println("** " + System.getProperty("os.name"));
System.out.println("** Java: " + System.getProperty("java.version"));
System.out.println("** " + System.getProperty("java.runtime.version"));
System.out.println("** " + System.getProperty("java.vm.version"));
System.out.println("** " + System.getProperty("java.vendor"));
System.out.println("** MRJ: " + System.getProperty("mrj.version"));
System.out.println();
}
} | [
"public",
"class",
"Sys",
"{",
"private",
"static",
"final",
"boolean",
"ismacos",
";",
"private",
"static",
"final",
"boolean",
"ismacosx",
";",
"private",
"static",
"final",
"boolean",
"islinux",
";",
"private",
"static",
"final",
"boolean",
"iswindows",
";",
"private",
"static",
"final",
"boolean",
"isos2",
";",
"private",
"static",
"final",
"String",
"homeDir",
"=",
"System",
".",
"getProperty",
"(",
"\"",
"user.home",
"\"",
")",
";",
"private",
"static",
"final",
"String",
"workDir",
"=",
"System",
".",
"getProperty",
"(",
"\"",
"user.dir",
"\"",
")",
";",
"private",
"static",
"final",
"String",
"prefDir",
";",
"private",
"static",
"final",
"String",
"localPrefDir",
";",
"private",
"static",
"final",
"String",
"javaHome",
";",
"static",
"{",
"String",
"osname",
"=",
"System",
".",
"getProperty",
"(",
"\"",
"os.name",
"\"",
")",
";",
"String",
"vendor",
"=",
"System",
".",
"getProperty",
"(",
"\"",
"java.vendor",
"\"",
")",
";",
"String",
"jhome",
"=",
"System",
".",
"getProperty",
"(",
"\"",
"java.home",
"\"",
")",
";",
"ismacosx",
"=",
"osname",
".",
"toLowerCase",
"(",
")",
".",
"startsWith",
"(",
"\"",
"mac os x",
"\"",
")",
";",
"ismacos",
"=",
"(",
"!",
"ismacosx",
")",
"&&",
"(",
"(",
"vendor",
".",
"indexOf",
"(",
"\"",
"Apple",
"\"",
")",
">=",
"0",
")",
"||",
"(",
"osname",
".",
"indexOf",
"(",
"\"",
"Mac OS",
"\"",
")",
">=",
"0",
")",
")",
";",
"islinux",
"=",
"(",
"osname",
".",
"indexOf",
"(",
"\"",
"Linux",
"\"",
")",
">=",
"0",
")",
";",
"iswindows",
"=",
"(",
"osname",
".",
"indexOf",
"(",
"\"",
"Windows",
"\"",
")",
">=",
"0",
")",
";",
"isos2",
"=",
"(",
"osname",
".",
"indexOf",
"(",
"\"",
"OS/2",
"\"",
")",
">=",
"0",
")",
";",
"if",
"(",
"ismacosx",
")",
"{",
"String",
"pref",
"=",
"homeDir",
"+",
"\"",
"/Library/Preferences",
"\"",
";",
"String",
"localPref",
"=",
"\"",
"/Library/Preferences",
"\"",
";",
"/*\t\t// this way we'd do it ultra-correctly on Mac OS X / Java 1.4,\n\t\t// but then all Java apps would get a menu bar, which might not\n\t\t// be suitable for all situations\n\n\t\ttry\n\t\t{\n\t\t\tClass fileman = Class.forName(\"com.apple.eio.FileManager\");\n\t\t\t\n\t\t\tjava.lang.reflect.Method findFolder =\n\t\t\t\t\tfileman.getMethod(\"findFolder\", new Class[] { short.class, int.class });\n\n\t\t\tfinal int kPreferencesFolderType = 0x70726566;\n\t\t\tfinal short kUserDomain = -32763;\n\t\t\tfinal short kLocalDomain = -32765;\n\t\t\t\n\t\t\tpref = (String)findFolder.invoke(null,\n\t\t\t\t\t\tnew Object[] { new Short(kUserDomain), new Integer(kPreferencesFolderType) });\n\n\t\t\tlocalPref = (String)findFolder.invoke(null,\n\t\t\t\t\t\tnew Object[] { new Short(kLocalDomain), new Integer(kPreferencesFolderType) });\n\t\t}\n\t\tcatch (Exception e) {} */",
"prefDir",
"=",
"pref",
";",
"localPrefDir",
"=",
"localPref",
";",
"if",
"(",
"(",
"jhome",
"==",
"null",
")",
"||",
"(",
"jhome",
".",
"length",
"(",
")",
"==",
"0",
")",
")",
"{",
"jhome",
"=",
"\"",
"/Library/Java/Home",
"\"",
";",
"}",
"}",
"else",
"{",
"prefDir",
"=",
"homeDir",
";",
"localPrefDir",
"=",
"(",
"islinux",
")",
"?",
"\"",
"/etc",
"\"",
":",
"workDir",
";",
"}",
"javaHome",
"=",
"jhome",
";",
"}",
"private",
"Sys",
"(",
")",
"{",
"}",
"/**\n * @return <code>true</code>, if the application is running on Mac OS 8/9, <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isMacOS",
"(",
")",
"{",
"return",
"ismacos",
";",
"}",
"/**\n * @return <code>true</code>, if the application is running on Mac OS X, <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isMacOSX",
"(",
")",
"{",
"return",
"ismacosx",
";",
"}",
"/**\n * @return <code>true</code>, if the application is running on a Mac (OS 8, 9 or X), <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isAMac",
"(",
")",
"{",
"return",
"(",
"ismacosx",
"||",
"ismacos",
")",
";",
"}",
"/**\n * @return <code>true</code>, if the application is running on Linux, <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isLinux",
"(",
")",
"{",
"return",
"islinux",
";",
"}",
"/**\n * @return <code>true</code>, if the application is running on Windows, <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isWindows",
"(",
")",
"{",
"return",
"iswindows",
";",
"}",
"/**\n * @return <code>true</code>, if the application is running on OS/2, <code>false</code> otherwise\n */",
"public",
"static",
"boolean",
"isOS2",
"(",
")",
"{",
"return",
"isos2",
";",
"}",
"/**\n * The home directory contains the user's data and applications. On UNIX systems this directory is denoted\n * by <code>~</code> and can be queried through the system property <code>user.home</code>.\n * @return the user's home directory without a trailing path separator\n */",
"public",
"static",
"String",
"getHomeDirectory",
"(",
")",
"{",
"return",
"homeDir",
";",
"}",
"/**\n * The directory from which the application was launched is called the working directory. Its path can\n * be queried through the system property <code>user.dir</code>.\n * @return the application's working directory without a trailing path separator\n */",
"public",
"static",
"String",
"getWorkingDirectory",
"(",
")",
"{",
"return",
"workDir",
";",
"}",
"/**\n * The preferences directory contains the user's configuration files. On Mac OS X, this method returns\n * <code>~/Library/Preferences</code>, on all other systems the user's home directory is used.\n * @return the user's preferences directory without a trailing path separator\n */",
"public",
"static",
"String",
"getPrefsDirectory",
"(",
")",
"{",
"return",
"prefDir",
";",
"}",
"/**\n * The local preferences directory contains configuration files that are shared by all users on the computer.\n * On Mac OS X, this method returns <code>/Library/Preferences</code>, on Linux <code>/etc</code>. On all\n * other systems the application's working directory is used.\n * <i>Please note: There is no guarantee that your application has permission to use this directory!</i>\n * @return the shared preferences directory (without a trailing path separator) of all users on a local computer\n */",
"public",
"static",
"String",
"getLocalPrefsDirectory",
"(",
")",
"{",
"return",
"localPrefDir",
";",
"}",
"/**\n * The Java home directory contains the <code>bin</code> subdirectory and is needed to invoke the Java tools\n * at runtime. It is specified by the environment variable <code>$JAVA_HOME</code> and can be queried through\n * the system property <code>java.home</code>. If the variable is not set properly, this method returns\n * <code>/Library/Java/Home</code> on Mac OS X.\n * @return the Java home directory without a trailing path separator\n */",
"public",
"static",
"String",
"getJavaHome",
"(",
")",
"{",
"return",
"javaHome",
";",
"}",
"/**\n * This is a small test case for all the methods in this class.\n * On Mac OS X you can launch it by simply double-clicking the jar file (output goes to the Console).\n * On other systems, you can start it with <code>java -classpath .:Sys.jar com.muchsoft.util.Sys</code>\n * (or <code>java -jar Sys.jar</code>)\n * @param args not used\n */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** com.muchsoft.util.Sys version 2004-10-13",
"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"**",
"\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** JavaHome: ",
"\"",
"+",
"getJavaHome",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** AppWork: ",
"\"",
"+",
"getWorkingDirectory",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** UserHome: ",
"\"",
"+",
"getHomeDirectory",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** UserPrefs: ",
"\"",
"+",
"getPrefsDirectory",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** LocalPrefs: ",
"\"",
"+",
"getLocalPrefsDirectory",
"(",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"**",
"\"",
")",
";",
"System",
".",
"out",
".",
"print",
"(",
"\"",
"** System: ",
"\"",
")",
";",
"if",
"(",
"isMacOSX",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Mac OS X",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"isMacOS",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Mac OS 8/9",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"isLinux",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Linux",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"isWindows",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Windows",
"\"",
")",
";",
"}",
"else",
"if",
"(",
"isOS2",
"(",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"OS/2",
"\"",
")",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"unknown",
"\"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"os.name",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** Java: ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"java.version",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"java.runtime.version",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"java.vm.version",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"java.vendor",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"** MRJ: ",
"\"",
"+",
"System",
".",
"getProperty",
"(",
"\"",
"mrj.version",
"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"}"
] | TEEEEEEEEH
<p>This class lets you determine which system your Java application runs on. | [
"TEEEEEEEEH",
"<p",
">",
"This",
"class",
"lets",
"you",
"determine",
"which",
"system",
"your",
"Java",
"application",
"runs",
"on",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0747530020425e6f9e657c94d8b6700d97fb18f8 | kayahr/wlandsuite | src/main/java/de/ailis/wlandsuite/msq/MsqHeader.java | [
"MIT"
] | Java | MsqHeader | /**
* MSQ header
*
* @author Klaus Reimer ([email protected])
* @version $Revision$
*/ | MSQ header
@author Klaus Reimer ([email protected])
@version $Revision$ | [
"MSQ",
"header",
"@author",
"Klaus",
"Reimer",
"(",
"k@ailis",
".",
"de",
")",
"@version",
"$Revision$"
] | public class MsqHeader implements Serializable
{
/** Serial version UID */
private static final long serialVersionUID = -5186751829710381419L;
/** The MSQ block type */
private final MsqType type;
/** The disk index (0 or 1) */
private final int disk;
/** The size of the uncompressed MSQ data */
private final int size;
/**
* Constructor
*
* @param type
* The MSQ block type
* @param disk
* The disk index (0 or 1)
* @param size
* The size of the uncompressed MSQ data
*/
public MsqHeader(final MsqType type, final int disk, final int size)
{
this.type = type;
this.disk = disk;
this.size = size;
}
/**
* Reads a MSQ header from the stream. If the end of the stream has been
* reached then NULL is returned.
*
* @param stream
* The input stream
* @return The MSQ header or null if end of stream
* @throws IOException
* When file operation fails.
*/
public static MsqHeader read(final InputStream stream) throws IOException
{
int b1, b2, b3, b4;
int size;
// Read the next four bytes. If the first byte hit the end of the
// stream then no more MSQ blocks are available and null is returned
b1 = stream.read();
if (b1 == -1)
{
return null;
}
b2 = stream.read();
b3 = stream.read();
b4 = stream.read();
if (b2 == -1 || b3 == -1 || b4 == -1)
{
throw new EOFException(
"Unexpected end of stream while reading MSQ header");
}
// Check for uncompressed MSQ block type
if (b1 == 'm' && b2 == 's' && b3 == 'q' && (b4 == '0' || b4 == '1'))
{
return new MsqHeader(MsqType.Uncompressed, b4 - '0', 0);
}
// Assume the first four bytes are size information and read the next
// four bytes
size = b1 | (b2 << 8) | (b3 << 16) | (b4 << 24);
b1 = stream.read();
b2 = stream.read();
b3 = stream.read();
b4 = stream.read();
if (b1 == -1 || b2 == -1 || b3 == -1 || b4 == -1)
{
throw new EOFException(
"Unexpected end of stream while reading MSQ header");
}
// Check for compressed MSQ block type
if (b1 == 'm' && b2 == 's' && b3 == 'q' && (b4 == 0 || b4 == 1))
{
return new MsqHeader(MsqType.Compressed, b4, size);
}
// Check for CPA Animation block type
if (b1 == 0x08 && b2 == 0x67 && b3 == 0x01 && b4 == 0)
{
return new MsqHeader(MsqType.CpaAnimation, b4, size);
}
// Give up, unknown MSQ block type
throw new IOException("Unable to read MSQ header from stream");
}
/**
* Writes the MSQ header to the given output stream
*
* @param stream
* The output stream
* @throws IOException
* When file operation fails.
*/
public void write(final OutputStream stream) throws IOException
{
// Write the size information for compressed or Cpa animation block
if (this.type == MsqType.Compressed || this.type == MsqType.CpaAnimation)
{
stream.write(this.size & 0xff);
stream.write((this.size >> 8) & 0xff);
stream.write((this.size >> 16) & 0xff);
stream.write((this.size >> 24) & 0xff);
}
// Write the MSQ identifier
if (this.type == MsqType.CpaAnimation)
{
stream.write(0x08);
stream.write(0x67);
stream.write(0x01);
}
else
{
stream.write('m');
stream.write('s');
stream.write('q');
}
// Write the disk index
if (this.type == MsqType.Uncompressed)
{
stream.write(this.disk + '0');
}
else
{
stream.write(this.disk);
}
}
/**
* Returns the disk index (0 or 1).
*
* @return The disk index
*/
public int getDisk()
{
return this.disk;
}
/**
* Returns the size of the uncompressed MSQ block data.
*
* @return The size of the uncompressed data
*/
public int getSize()
{
return this.size;
}
/**
* Returns the MSQ block type.
*
* @return The MSQ block type
*/
public MsqType getType()
{
return this.type;
}
} | [
"public",
"class",
"MsqHeader",
"implements",
"Serializable",
"{",
"/** Serial version UID */",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"-",
"5186751829710381419L",
";",
"/** The MSQ block type */",
"private",
"final",
"MsqType",
"type",
";",
"/** The disk index (0 or 1) */",
"private",
"final",
"int",
"disk",
";",
"/** The size of the uncompressed MSQ data */",
"private",
"final",
"int",
"size",
";",
"/**\n * Constructor\n *\n * @param type\n * The MSQ block type\n * @param disk\n * The disk index (0 or 1)\n * @param size\n * The size of the uncompressed MSQ data\n */",
"public",
"MsqHeader",
"(",
"final",
"MsqType",
"type",
",",
"final",
"int",
"disk",
",",
"final",
"int",
"size",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"this",
".",
"disk",
"=",
"disk",
";",
"this",
".",
"size",
"=",
"size",
";",
"}",
"/**\n * Reads a MSQ header from the stream. If the end of the stream has been\n * reached then NULL is returned.\n *\n * @param stream\n * The input stream\n * @return The MSQ header or null if end of stream\n * @throws IOException\n * When file operation fails.\n */",
"public",
"static",
"MsqHeader",
"read",
"(",
"final",
"InputStream",
"stream",
")",
"throws",
"IOException",
"{",
"int",
"b1",
",",
"b2",
",",
"b3",
",",
"b4",
";",
"int",
"size",
";",
"b1",
"=",
"stream",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"==",
"-",
"1",
")",
"{",
"return",
"null",
";",
"}",
"b2",
"=",
"stream",
".",
"read",
"(",
")",
";",
"b3",
"=",
"stream",
".",
"read",
"(",
")",
";",
"b4",
"=",
"stream",
".",
"read",
"(",
")",
";",
"if",
"(",
"b2",
"==",
"-",
"1",
"||",
"b3",
"==",
"-",
"1",
"||",
"b4",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"EOFException",
"(",
"\"",
"Unexpected end of stream while reading MSQ header",
"\"",
")",
";",
"}",
"if",
"(",
"b1",
"==",
"'m'",
"&&",
"b2",
"==",
"'s'",
"&&",
"b3",
"==",
"'q'",
"&&",
"(",
"b4",
"==",
"'0'",
"||",
"b4",
"==",
"'1'",
")",
")",
"{",
"return",
"new",
"MsqHeader",
"(",
"MsqType",
".",
"Uncompressed",
",",
"b4",
"-",
"'0'",
",",
"0",
")",
";",
"}",
"size",
"=",
"b1",
"|",
"(",
"b2",
"<<",
"8",
")",
"|",
"(",
"b3",
"<<",
"16",
")",
"|",
"(",
"b4",
"<<",
"24",
")",
";",
"b1",
"=",
"stream",
".",
"read",
"(",
")",
";",
"b2",
"=",
"stream",
".",
"read",
"(",
")",
";",
"b3",
"=",
"stream",
".",
"read",
"(",
")",
";",
"b4",
"=",
"stream",
".",
"read",
"(",
")",
";",
"if",
"(",
"b1",
"==",
"-",
"1",
"||",
"b2",
"==",
"-",
"1",
"||",
"b3",
"==",
"-",
"1",
"||",
"b4",
"==",
"-",
"1",
")",
"{",
"throw",
"new",
"EOFException",
"(",
"\"",
"Unexpected end of stream while reading MSQ header",
"\"",
")",
";",
"}",
"if",
"(",
"b1",
"==",
"'m'",
"&&",
"b2",
"==",
"'s'",
"&&",
"b3",
"==",
"'q'",
"&&",
"(",
"b4",
"==",
"0",
"||",
"b4",
"==",
"1",
")",
")",
"{",
"return",
"new",
"MsqHeader",
"(",
"MsqType",
".",
"Compressed",
",",
"b4",
",",
"size",
")",
";",
"}",
"if",
"(",
"b1",
"==",
"0x08",
"&&",
"b2",
"==",
"0x67",
"&&",
"b3",
"==",
"0x01",
"&&",
"b4",
"==",
"0",
")",
"{",
"return",
"new",
"MsqHeader",
"(",
"MsqType",
".",
"CpaAnimation",
",",
"b4",
",",
"size",
")",
";",
"}",
"throw",
"new",
"IOException",
"(",
"\"",
"Unable to read MSQ header from stream",
"\"",
")",
";",
"}",
"/**\n * Writes the MSQ header to the given output stream\n *\n * @param stream\n * The output stream\n * @throws IOException\n * When file operation fails.\n */",
"public",
"void",
"write",
"(",
"final",
"OutputStream",
"stream",
")",
"throws",
"IOException",
"{",
"if",
"(",
"this",
".",
"type",
"==",
"MsqType",
".",
"Compressed",
"||",
"this",
".",
"type",
"==",
"MsqType",
".",
"CpaAnimation",
")",
"{",
"stream",
".",
"write",
"(",
"this",
".",
"size",
"&",
"0xff",
")",
";",
"stream",
".",
"write",
"(",
"(",
"this",
".",
"size",
">>",
"8",
")",
"&",
"0xff",
")",
";",
"stream",
".",
"write",
"(",
"(",
"this",
".",
"size",
">>",
"16",
")",
"&",
"0xff",
")",
";",
"stream",
".",
"write",
"(",
"(",
"this",
".",
"size",
">>",
"24",
")",
"&",
"0xff",
")",
";",
"}",
"if",
"(",
"this",
".",
"type",
"==",
"MsqType",
".",
"CpaAnimation",
")",
"{",
"stream",
".",
"write",
"(",
"0x08",
")",
";",
"stream",
".",
"write",
"(",
"0x67",
")",
";",
"stream",
".",
"write",
"(",
"0x01",
")",
";",
"}",
"else",
"{",
"stream",
".",
"write",
"(",
"'m'",
")",
";",
"stream",
".",
"write",
"(",
"'s'",
")",
";",
"stream",
".",
"write",
"(",
"'q'",
")",
";",
"}",
"if",
"(",
"this",
".",
"type",
"==",
"MsqType",
".",
"Uncompressed",
")",
"{",
"stream",
".",
"write",
"(",
"this",
".",
"disk",
"+",
"'0'",
")",
";",
"}",
"else",
"{",
"stream",
".",
"write",
"(",
"this",
".",
"disk",
")",
";",
"}",
"}",
"/**\n * Returns the disk index (0 or 1).\n *\n * @return The disk index\n */",
"public",
"int",
"getDisk",
"(",
")",
"{",
"return",
"this",
".",
"disk",
";",
"}",
"/**\n * Returns the size of the uncompressed MSQ block data.\n *\n * @return The size of the uncompressed data\n */",
"public",
"int",
"getSize",
"(",
")",
"{",
"return",
"this",
".",
"size",
";",
"}",
"/**\n * Returns the MSQ block type.\n *\n * @return The MSQ block type\n */",
"public",
"MsqType",
"getType",
"(",
")",
"{",
"return",
"this",
".",
"type",
";",
"}",
"}"
] | MSQ header
@author Klaus Reimer ([email protected])
@version $Revision$ | [
"MSQ",
"header",
"@author",
"Klaus",
"Reimer",
"(",
"k@ailis",
".",
"de",
")",
"@version",
"$Revision$"
] | [
"// Read the next four bytes. If the first byte hit the end of the",
"// stream then no more MSQ blocks are available and null is returned",
"// Check for uncompressed MSQ block type",
"// Assume the first four bytes are size information and read the next",
"// four bytes",
"// Check for compressed MSQ block type",
"// Check for CPA Animation block type",
"// Give up, unknown MSQ block type",
"// Write the size information for compressed or Cpa animation block",
"// Write the MSQ identifier",
"// Write the disk index"
] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
074ad9ee921ebece968997eb5541571ddecacf25 | JimCallahan/Pipeline | src/java/us/temerity/pipeline/message/node/NodeMultiStatusReq.java | [
"Apache-2.0"
] | Java | NodeMultiStatusReq | /**
* Get the status of multiple overlapping trees of nodes. <P>
*
* @see MasterMgr
*/ | Get the status of multiple overlapping trees of nodes.
| [
"Get",
"the",
"status",
"of",
"multiple",
"overlapping",
"trees",
"of",
"nodes",
"."
] | public
class NodeMultiStatusReq
implements Serializable
{
/*----------------------------------------------------------------------------------------*/
/* C O N S T R U C T O R S */
/*----------------------------------------------------------------------------------------*/
/**
* Constructs a new request.
*
* @param author
* The name of the user which owns the working version.
*
* @param view
* The name of the user's working area view.
*
* @param rootNames
* The fully resolved names of the nodes for which <CODE>NodeStatus</CODE> will be
* reported.
*
* @param heavyNames
* The fully resolved names of the nodes which require heavyweight node status details.
* All nodes upstream will also return heavyweight details as well. Note that in order
* for these heavyweight nodes to be returned, they must be included or reachable
* upstream from the <CODE>rootNames</CODE> set.
*
* @param dmode
* The criteria used to determine how downstream node status is reported for the nodes
* included in the <CODE>roots</CODE> set.
*/
public
NodeMultiStatusReq
(
String author,
String view,
TreeSet<String> rootNames,
TreeSet<String> heavyNames,
DownstreamMode dmode
)
{
if(author == null)
throw new IllegalArgumentException("The author cannot be (null)!");
pAuthor = author;
if(view == null)
throw new IllegalArgumentException("The view cannot be (null)!");
pView = view;
if(rootNames == null)
throw new IllegalArgumentException
("The root node names cannot be (null)!");
pRootNames = rootNames;
if(heavyNames == null)
throw new IllegalArgumentException
("The heavyweight node names cannot be (null)!");
pHeavyNames = heavyNames;
if(dmode == null)
throw new IllegalArgumentException
("The downstream mode cannot be (null)!");
pDownstreamMode = dmode;
}
/*----------------------------------------------------------------------------------------*/
/* A C C E S S */
/*----------------------------------------------------------------------------------------*/
/**
* Get the name of user which owens the working area.
*/
public String
getAuthor()
{
return pAuthor;
}
/**
* Get the name of the working area view.
*/
public String
getView()
{
return pView;
}
/**
* Gets the fully resolved names of the nodes for which node stats will be reported.
*/
public TreeSet<String>
getRootNames()
{
return pRootNames;
}
/**
* Gets the fully resolved names of the nodes which require heavyweight node status details.
*/
public TreeSet<String>
getHeavyNames()
{
return pHeavyNames;
}
/**
* The criteria used to determine how downstream node status is reported.
*/
public DownstreamMode
getDownstreamMode()
{
return pDownstreamMode;
}
/*----------------------------------------------------------------------------------------*/
/* S T A T I C I N T E R N A L S */
/*----------------------------------------------------------------------------------------*/
private static final long serialVersionUID = 2386610225504409786L;
/*----------------------------------------------------------------------------------------*/
/* I N T E R N A L S */
/*----------------------------------------------------------------------------------------*/
/**
* The name of user which owens the working version.
*/
private String pAuthor;
/**
* The name of the working area view.
*/
private String pView;
/**
* The fully resolved names of the nodes for which node stats will be reported.
*/
private TreeSet<String> pRootNames;
/**
* The fully resolved names of the nodes which require heavyweight node status details.
*/
private TreeSet<String> pHeavyNames;
/**
* The criteria used to determine how downstream node status is reported.
*/
private DownstreamMode pDownstreamMode;
} | [
"public",
"class",
"NodeMultiStatusReq",
"implements",
"Serializable",
"{",
"/*----------------------------------------------------------------------------------------*/",
"/* C O N S T R U C T O R S */",
"/*----------------------------------------------------------------------------------------*/",
"/** \n * Constructs a new request.\n * \n * @param author \n * The name of the user which owns the working version.\n * \n * @param view \n * The name of the user's working area view. \n * \n * @param rootNames\n * The fully resolved names of the nodes for which <CODE>NodeStatus</CODE> will be \n * reported.\n * \n * @param heavyNames\n * The fully resolved names of the nodes which require heavyweight node status details.\n * All nodes upstream will also return heavyweight details as well. Note that in order\n * for these heavyweight nodes to be returned, they must be included or reachable\n * upstream from the <CODE>rootNames</CODE> set.\n * \n * @param dmode\n * The criteria used to determine how downstream node status is reported for the nodes\n * included in the <CODE>roots</CODE> set.\n */",
"public",
"NodeMultiStatusReq",
"(",
"String",
"author",
",",
"String",
"view",
",",
"TreeSet",
"<",
"String",
">",
"rootNames",
",",
"TreeSet",
"<",
"String",
">",
"heavyNames",
",",
"DownstreamMode",
"dmode",
")",
"{",
"if",
"(",
"author",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"The author cannot be (null)!",
"\"",
")",
";",
"pAuthor",
"=",
"author",
";",
"if",
"(",
"view",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"The view cannot be (null)!",
"\"",
")",
";",
"pView",
"=",
"view",
";",
"if",
"(",
"rootNames",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"The root node names cannot be (null)!",
"\"",
")",
";",
"pRootNames",
"=",
"rootNames",
";",
"if",
"(",
"heavyNames",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"The heavyweight node names cannot be (null)!",
"\"",
")",
";",
"pHeavyNames",
"=",
"heavyNames",
";",
"if",
"(",
"dmode",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"The downstream mode cannot be (null)!",
"\"",
")",
";",
"pDownstreamMode",
"=",
"dmode",
";",
"}",
"/*----------------------------------------------------------------------------------------*/",
"/* A C C E S S */",
"/*----------------------------------------------------------------------------------------*/",
"/** \n * Get the name of user which owens the working area.\n */",
"public",
"String",
"getAuthor",
"(",
")",
"{",
"return",
"pAuthor",
";",
"}",
"/** \n * Get the name of the working area view.\n */",
"public",
"String",
"getView",
"(",
")",
"{",
"return",
"pView",
";",
"}",
"/**\n * Gets the fully resolved names of the nodes for which node stats will be reported.\n */",
"public",
"TreeSet",
"<",
"String",
">",
"getRootNames",
"(",
")",
"{",
"return",
"pRootNames",
";",
"}",
"/**\n * Gets the fully resolved names of the nodes which require heavyweight node status details.\n */",
"public",
"TreeSet",
"<",
"String",
">",
"getHeavyNames",
"(",
")",
"{",
"return",
"pHeavyNames",
";",
"}",
"/**\n * The criteria used to determine how downstream node status is reported.\n */",
"public",
"DownstreamMode",
"getDownstreamMode",
"(",
")",
"{",
"return",
"pDownstreamMode",
";",
"}",
"/*----------------------------------------------------------------------------------------*/",
"/* S T A T I C I N T E R N A L S */",
"/*----------------------------------------------------------------------------------------*/",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"2386610225504409786L",
";",
"/*----------------------------------------------------------------------------------------*/",
"/* I N T E R N A L S */",
"/*----------------------------------------------------------------------------------------*/",
"/** \n * The name of user which owens the working version.\n */",
"private",
"String",
"pAuthor",
";",
"/** \n * The name of the working area view.\n */",
"private",
"String",
"pView",
";",
"/** \n * The fully resolved names of the nodes for which node stats will be reported.\n */",
"private",
"TreeSet",
"<",
"String",
">",
"pRootNames",
";",
"/** \n * The fully resolved names of the nodes which require heavyweight node status details.\n */",
"private",
"TreeSet",
"<",
"String",
">",
"pHeavyNames",
";",
"/**\n * The criteria used to determine how downstream node status is reported.\n */",
"private",
"DownstreamMode",
"pDownstreamMode",
";",
"}"
] | Get the status of multiple overlapping trees of nodes. | [
"Get",
"the",
"status",
"of",
"multiple",
"overlapping",
"trees",
"of",
"nodes",
"."
] | [] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07545e31008de00059fe6580eab30177989b99ce | dsuarezf/ixa-pipe-ml | src/main/java/eus/ixa/ixa/pipe/ml/parse/ParserEventStream.java | [
"Apache-2.0"
] | Java | ParserEventStream | /**
* Wrapper class for one of four parser event streams. The particular event
* stream is specified at construction.
*/ | Wrapper class for one of four parser event streams. The particular event
stream is specified at construction. | [
"Wrapper",
"class",
"for",
"one",
"of",
"four",
"parser",
"event",
"streams",
".",
"The",
"particular",
"event",
"stream",
"is",
"specified",
"at",
"construction",
"."
] | public class ParserEventStream
extends opennlp.tools.util.AbstractEventStream<Parse> {
private final HeadRules rules;
private final Set<String> punctSet;
/**
* The type of events being generated by this event stream.
*/
private final ParserEventTypeEnum etype;
private boolean fixPossesives;
private BuildContextGenerator bcg;
private CheckContextGenerator kcg;
public ParserEventStream(final ObjectStream<Parse> samples,
final HeadRules rules, final ParserEventTypeEnum etype,
final ParserFactory factory) {
super(samples);
this.rules = rules;
this.punctSet = rules.getPunctuationTags();
this.etype = etype;
init();
}
public ParserEventStream(final ObjectStream<Parse> d, final HeadRules rules,
final ParserEventTypeEnum etype) {
this(d, rules, etype, null);
}
private void init() {
if (this.etype == ParserEventTypeEnum.BUILD) {
this.bcg = new BuildContextGenerator();
} else if (this.etype == ParserEventTypeEnum.CHECK) {
this.kcg = new CheckContextGenerator();
}
this.fixPossesives = false;
}
@Override
protected Iterator<Event> createEvents(final Parse sample) {
final List<Event> newEvents = new ArrayList<Event>();
Parse.pruneParse(sample);
if (this.fixPossesives) {
Parse.fixPossesives(sample);
}
sample.updateHeads(this.rules);
final Parse[] chunks = getInitialChunks(sample);
addParseEvents(newEvents,
ShiftReduceParser.collapsePunctuation(chunks, this.punctSet));
return newEvents.iterator();
}
/**
* Adds events for parsing (post tagging and chunking to the specified list of
* events for the specified parse chunks.
*
* @param parseEvents
* The events for the specified chunks.
* @param chunks
* The incomplete parses to be parsed.
*/
private void addParseEvents(final List<Event> parseEvents, Parse[] chunks) {
int ci = 0;
while (ci < chunks.length) {
// System.err.println("parserEventStream.addParseEvents: chunks=" +
// Arrays.asList(chunks));
final Parse c = chunks[ci];
final Parse parent = c.getParent();
if (parent != null) {
final String type = parent.getType();
String outcome;
if (firstChild(c, parent)) {
outcome = type + "-" + BioCodec.START;
} else {
outcome = type + "-" + BioCodec.CONTINUE;
}
// System.err.println("parserEventStream.addParseEvents:
// chunks["+ci+"]="+c+" label=" +outcome + " bcg=" + bcg);
c.setLabel(outcome);
if (this.etype == ParserEventTypeEnum.BUILD) {
parseEvents.add(new Event(outcome, this.bcg.getContext(chunks, ci)));
}
int start = ci - 1;
while (start >= 0 && chunks[start].getParent() == parent) {
start--;
}
if (lastChild(c, parent)) {
if (this.etype == ParserEventTypeEnum.CHECK) {
parseEvents.add(new Event(ShiftReduceParser.COMPLETE,
this.kcg.getContext(chunks, type, start + 1, ci)));
}
// perform reduce
int reduceStart = ci;
while (reduceStart >= 0
&& chunks[reduceStart].getParent() == parent) {
reduceStart--;
}
reduceStart++;
chunks = reduceChunks(chunks, ci, parent);
ci = reduceStart - 1; // ci will be incremented at end of loop
} else {
if (this.etype == ParserEventTypeEnum.CHECK) {
parseEvents.add(new Event(ShiftReduceParser.INCOMPLETE,
this.kcg.getContext(chunks, type, start + 1, ci)));
}
}
}
ci++;
}
}
public static Parse[] getInitialChunks(final Parse p) {
final List<Parse> chunks = new ArrayList<Parse>();
getInitialChunks(p, chunks);
return chunks.toArray(new Parse[chunks.size()]);
}
private static void getInitialChunks(final Parse p,
final List<Parse> ichunks) {
if (p.isPosTag()) {
ichunks.add(p);
} else {
final Parse[] kids = p.getChildren();
boolean allKidsAreTags = true;
for (int ci = 0, cl = kids.length; ci < cl; ci++) {
if (!kids[ci].isPosTag()) {
allKidsAreTags = false;
break;
}
}
if (allKidsAreTags) {
ichunks.add(p);
} else {
for (final Parse kid : kids) {
getInitialChunks(kid, ichunks);
}
}
}
}
/**
* Returns true if the specified child is the first child of the specified
* parent.
*
* @param child
* The child parse.
* @param parent
* The parent parse.
* @return true if the specified child is the first child of the specified
* parent; false otherwise.
*/
protected boolean firstChild(final Parse child, final Parse parent) {
return ShiftReduceParser.collapsePunctuation(parent.getChildren(),
this.punctSet)[0] == child;
}
public static Parse[] reduceChunks(final Parse[] chunks, int ci,
final Parse parent) {
final String type = parent.getType();
// perform reduce
int reduceStart = ci;
final int reduceEnd = ci;
while (reduceStart >= 0 && chunks[reduceStart].getParent() == parent) {
reduceStart--;
}
reduceStart++;
Parse[] reducedChunks;
if (!type.equals(ShiftReduceParser.TOP_NODE)) {
reducedChunks = new Parse[chunks.length - (reduceEnd - reduceStart + 1)
+ 1]; // total - num_removed + 1 (for new node)
// insert nodes before reduction
for (int ri = 0, rn = reduceStart; ri < rn; ri++) {
reducedChunks[ri] = chunks[ri];
}
// insert reduced node
reducedChunks[reduceStart] = parent;
// propagate punctuation sets
parent
.setPrevPunctuation(chunks[reduceStart].getPreviousPunctuationSet());
parent.setNextPunctuation(chunks[reduceEnd].getNextPunctuationSet());
// insert nodes after reduction
int ri = reduceStart + 1;
for (int rci = reduceEnd + 1; rci < chunks.length; rci++) {
reducedChunks[ri] = chunks[rci];
ri++;
}
ci = reduceStart - 1; // ci will be incremented at end of loop
} else {
reducedChunks = new Parse[0];
}
return reducedChunks;
}
/**
* Returns true if the specified child is the last child of the specified
* parent.
*
* @param child
* The child parse.
* @param parent
* The parent parse.
* @return true if the specified child is the last child of the specified
* parent; false otherwise.
*/
protected boolean lastChild(final Parse child, final Parse parent) {
final Parse[] kids = ShiftReduceParser
.collapsePunctuation(parent.getChildren(), this.punctSet);
return kids[kids.length - 1] == child;
}
} | [
"public",
"class",
"ParserEventStream",
"extends",
"opennlp",
".",
"tools",
".",
"util",
".",
"AbstractEventStream",
"<",
"Parse",
">",
"{",
"private",
"final",
"HeadRules",
"rules",
";",
"private",
"final",
"Set",
"<",
"String",
">",
"punctSet",
";",
"/**\n * The type of events being generated by this event stream.\n */",
"private",
"final",
"ParserEventTypeEnum",
"etype",
";",
"private",
"boolean",
"fixPossesives",
";",
"private",
"BuildContextGenerator",
"bcg",
";",
"private",
"CheckContextGenerator",
"kcg",
";",
"public",
"ParserEventStream",
"(",
"final",
"ObjectStream",
"<",
"Parse",
">",
"samples",
",",
"final",
"HeadRules",
"rules",
",",
"final",
"ParserEventTypeEnum",
"etype",
",",
"final",
"ParserFactory",
"factory",
")",
"{",
"super",
"(",
"samples",
")",
";",
"this",
".",
"rules",
"=",
"rules",
";",
"this",
".",
"punctSet",
"=",
"rules",
".",
"getPunctuationTags",
"(",
")",
";",
"this",
".",
"etype",
"=",
"etype",
";",
"init",
"(",
")",
";",
"}",
"public",
"ParserEventStream",
"(",
"final",
"ObjectStream",
"<",
"Parse",
">",
"d",
",",
"final",
"HeadRules",
"rules",
",",
"final",
"ParserEventTypeEnum",
"etype",
")",
"{",
"this",
"(",
"d",
",",
"rules",
",",
"etype",
",",
"null",
")",
";",
"}",
"private",
"void",
"init",
"(",
")",
"{",
"if",
"(",
"this",
".",
"etype",
"==",
"ParserEventTypeEnum",
".",
"BUILD",
")",
"{",
"this",
".",
"bcg",
"=",
"new",
"BuildContextGenerator",
"(",
")",
";",
"}",
"else",
"if",
"(",
"this",
".",
"etype",
"==",
"ParserEventTypeEnum",
".",
"CHECK",
")",
"{",
"this",
".",
"kcg",
"=",
"new",
"CheckContextGenerator",
"(",
")",
";",
"}",
"this",
".",
"fixPossesives",
"=",
"false",
";",
"}",
"@",
"Override",
"protected",
"Iterator",
"<",
"Event",
">",
"createEvents",
"(",
"final",
"Parse",
"sample",
")",
"{",
"final",
"List",
"<",
"Event",
">",
"newEvents",
"=",
"new",
"ArrayList",
"<",
"Event",
">",
"(",
")",
";",
"Parse",
".",
"pruneParse",
"(",
"sample",
")",
";",
"if",
"(",
"this",
".",
"fixPossesives",
")",
"{",
"Parse",
".",
"fixPossesives",
"(",
"sample",
")",
";",
"}",
"sample",
".",
"updateHeads",
"(",
"this",
".",
"rules",
")",
";",
"final",
"Parse",
"[",
"]",
"chunks",
"=",
"getInitialChunks",
"(",
"sample",
")",
";",
"addParseEvents",
"(",
"newEvents",
",",
"ShiftReduceParser",
".",
"collapsePunctuation",
"(",
"chunks",
",",
"this",
".",
"punctSet",
")",
")",
";",
"return",
"newEvents",
".",
"iterator",
"(",
")",
";",
"}",
"/**\n * Adds events for parsing (post tagging and chunking to the specified list of\n * events for the specified parse chunks.\n *\n * @param parseEvents\n * The events for the specified chunks.\n * @param chunks\n * The incomplete parses to be parsed.\n */",
"private",
"void",
"addParseEvents",
"(",
"final",
"List",
"<",
"Event",
">",
"parseEvents",
",",
"Parse",
"[",
"]",
"chunks",
")",
"{",
"int",
"ci",
"=",
"0",
";",
"while",
"(",
"ci",
"<",
"chunks",
".",
"length",
")",
"{",
"final",
"Parse",
"c",
"=",
"chunks",
"[",
"ci",
"]",
";",
"final",
"Parse",
"parent",
"=",
"c",
".",
"getParent",
"(",
")",
";",
"if",
"(",
"parent",
"!=",
"null",
")",
"{",
"final",
"String",
"type",
"=",
"parent",
".",
"getType",
"(",
")",
";",
"String",
"outcome",
";",
"if",
"(",
"firstChild",
"(",
"c",
",",
"parent",
")",
")",
"{",
"outcome",
"=",
"type",
"+",
"\"",
"-",
"\"",
"+",
"BioCodec",
".",
"START",
";",
"}",
"else",
"{",
"outcome",
"=",
"type",
"+",
"\"",
"-",
"\"",
"+",
"BioCodec",
".",
"CONTINUE",
";",
"}",
"c",
".",
"setLabel",
"(",
"outcome",
")",
";",
"if",
"(",
"this",
".",
"etype",
"==",
"ParserEventTypeEnum",
".",
"BUILD",
")",
"{",
"parseEvents",
".",
"add",
"(",
"new",
"Event",
"(",
"outcome",
",",
"this",
".",
"bcg",
".",
"getContext",
"(",
"chunks",
",",
"ci",
")",
")",
")",
";",
"}",
"int",
"start",
"=",
"ci",
"-",
"1",
";",
"while",
"(",
"start",
">=",
"0",
"&&",
"chunks",
"[",
"start",
"]",
".",
"getParent",
"(",
")",
"==",
"parent",
")",
"{",
"start",
"--",
";",
"}",
"if",
"(",
"lastChild",
"(",
"c",
",",
"parent",
")",
")",
"{",
"if",
"(",
"this",
".",
"etype",
"==",
"ParserEventTypeEnum",
".",
"CHECK",
")",
"{",
"parseEvents",
".",
"add",
"(",
"new",
"Event",
"(",
"ShiftReduceParser",
".",
"COMPLETE",
",",
"this",
".",
"kcg",
".",
"getContext",
"(",
"chunks",
",",
"type",
",",
"start",
"+",
"1",
",",
"ci",
")",
")",
")",
";",
"}",
"int",
"reduceStart",
"=",
"ci",
";",
"while",
"(",
"reduceStart",
">=",
"0",
"&&",
"chunks",
"[",
"reduceStart",
"]",
".",
"getParent",
"(",
")",
"==",
"parent",
")",
"{",
"reduceStart",
"--",
";",
"}",
"reduceStart",
"++",
";",
"chunks",
"=",
"reduceChunks",
"(",
"chunks",
",",
"ci",
",",
"parent",
")",
";",
"ci",
"=",
"reduceStart",
"-",
"1",
";",
"}",
"else",
"{",
"if",
"(",
"this",
".",
"etype",
"==",
"ParserEventTypeEnum",
".",
"CHECK",
")",
"{",
"parseEvents",
".",
"add",
"(",
"new",
"Event",
"(",
"ShiftReduceParser",
".",
"INCOMPLETE",
",",
"this",
".",
"kcg",
".",
"getContext",
"(",
"chunks",
",",
"type",
",",
"start",
"+",
"1",
",",
"ci",
")",
")",
")",
";",
"}",
"}",
"}",
"ci",
"++",
";",
"}",
"}",
"public",
"static",
"Parse",
"[",
"]",
"getInitialChunks",
"(",
"final",
"Parse",
"p",
")",
"{",
"final",
"List",
"<",
"Parse",
">",
"chunks",
"=",
"new",
"ArrayList",
"<",
"Parse",
">",
"(",
")",
";",
"getInitialChunks",
"(",
"p",
",",
"chunks",
")",
";",
"return",
"chunks",
".",
"toArray",
"(",
"new",
"Parse",
"[",
"chunks",
".",
"size",
"(",
")",
"]",
")",
";",
"}",
"private",
"static",
"void",
"getInitialChunks",
"(",
"final",
"Parse",
"p",
",",
"final",
"List",
"<",
"Parse",
">",
"ichunks",
")",
"{",
"if",
"(",
"p",
".",
"isPosTag",
"(",
")",
")",
"{",
"ichunks",
".",
"add",
"(",
"p",
")",
";",
"}",
"else",
"{",
"final",
"Parse",
"[",
"]",
"kids",
"=",
"p",
".",
"getChildren",
"(",
")",
";",
"boolean",
"allKidsAreTags",
"=",
"true",
";",
"for",
"(",
"int",
"ci",
"=",
"0",
",",
"cl",
"=",
"kids",
".",
"length",
";",
"ci",
"<",
"cl",
";",
"ci",
"++",
")",
"{",
"if",
"(",
"!",
"kids",
"[",
"ci",
"]",
".",
"isPosTag",
"(",
")",
")",
"{",
"allKidsAreTags",
"=",
"false",
";",
"break",
";",
"}",
"}",
"if",
"(",
"allKidsAreTags",
")",
"{",
"ichunks",
".",
"add",
"(",
"p",
")",
";",
"}",
"else",
"{",
"for",
"(",
"final",
"Parse",
"kid",
":",
"kids",
")",
"{",
"getInitialChunks",
"(",
"kid",
",",
"ichunks",
")",
";",
"}",
"}",
"}",
"}",
"/**\n * Returns true if the specified child is the first child of the specified\n * parent.\n *\n * @param child\n * The child parse.\n * @param parent\n * The parent parse.\n * @return true if the specified child is the first child of the specified\n * parent; false otherwise.\n */",
"protected",
"boolean",
"firstChild",
"(",
"final",
"Parse",
"child",
",",
"final",
"Parse",
"parent",
")",
"{",
"return",
"ShiftReduceParser",
".",
"collapsePunctuation",
"(",
"parent",
".",
"getChildren",
"(",
")",
",",
"this",
".",
"punctSet",
")",
"[",
"0",
"]",
"==",
"child",
";",
"}",
"public",
"static",
"Parse",
"[",
"]",
"reduceChunks",
"(",
"final",
"Parse",
"[",
"]",
"chunks",
",",
"int",
"ci",
",",
"final",
"Parse",
"parent",
")",
"{",
"final",
"String",
"type",
"=",
"parent",
".",
"getType",
"(",
")",
";",
"int",
"reduceStart",
"=",
"ci",
";",
"final",
"int",
"reduceEnd",
"=",
"ci",
";",
"while",
"(",
"reduceStart",
">=",
"0",
"&&",
"chunks",
"[",
"reduceStart",
"]",
".",
"getParent",
"(",
")",
"==",
"parent",
")",
"{",
"reduceStart",
"--",
";",
"}",
"reduceStart",
"++",
";",
"Parse",
"[",
"]",
"reducedChunks",
";",
"if",
"(",
"!",
"type",
".",
"equals",
"(",
"ShiftReduceParser",
".",
"TOP_NODE",
")",
")",
"{",
"reducedChunks",
"=",
"new",
"Parse",
"[",
"chunks",
".",
"length",
"-",
"(",
"reduceEnd",
"-",
"reduceStart",
"+",
"1",
")",
"+",
"1",
"]",
";",
"for",
"(",
"int",
"ri",
"=",
"0",
",",
"rn",
"=",
"reduceStart",
";",
"ri",
"<",
"rn",
";",
"ri",
"++",
")",
"{",
"reducedChunks",
"[",
"ri",
"]",
"=",
"chunks",
"[",
"ri",
"]",
";",
"}",
"reducedChunks",
"[",
"reduceStart",
"]",
"=",
"parent",
";",
"parent",
".",
"setPrevPunctuation",
"(",
"chunks",
"[",
"reduceStart",
"]",
".",
"getPreviousPunctuationSet",
"(",
")",
")",
";",
"parent",
".",
"setNextPunctuation",
"(",
"chunks",
"[",
"reduceEnd",
"]",
".",
"getNextPunctuationSet",
"(",
")",
")",
";",
"int",
"ri",
"=",
"reduceStart",
"+",
"1",
";",
"for",
"(",
"int",
"rci",
"=",
"reduceEnd",
"+",
"1",
";",
"rci",
"<",
"chunks",
".",
"length",
";",
"rci",
"++",
")",
"{",
"reducedChunks",
"[",
"ri",
"]",
"=",
"chunks",
"[",
"rci",
"]",
";",
"ri",
"++",
";",
"}",
"ci",
"=",
"reduceStart",
"-",
"1",
";",
"}",
"else",
"{",
"reducedChunks",
"=",
"new",
"Parse",
"[",
"0",
"]",
";",
"}",
"return",
"reducedChunks",
";",
"}",
"/**\n * Returns true if the specified child is the last child of the specified\n * parent.\n * \n * @param child\n * The child parse.\n * @param parent\n * The parent parse.\n * @return true if the specified child is the last child of the specified\n * parent; false otherwise.\n */",
"protected",
"boolean",
"lastChild",
"(",
"final",
"Parse",
"child",
",",
"final",
"Parse",
"parent",
")",
"{",
"final",
"Parse",
"[",
"]",
"kids",
"=",
"ShiftReduceParser",
".",
"collapsePunctuation",
"(",
"parent",
".",
"getChildren",
"(",
")",
",",
"this",
".",
"punctSet",
")",
";",
"return",
"kids",
"[",
"kids",
".",
"length",
"-",
"1",
"]",
"==",
"child",
";",
"}",
"}"
] | Wrapper class for one of four parser event streams. | [
"Wrapper",
"class",
"for",
"one",
"of",
"four",
"parser",
"event",
"streams",
"."
] | [
"// System.err.println(\"parserEventStream.addParseEvents: chunks=\" +",
"// Arrays.asList(chunks));",
"// System.err.println(\"parserEventStream.addParseEvents:",
"// chunks[\"+ci+\"]=\"+c+\" label=\" +outcome + \" bcg=\" + bcg);",
"// perform reduce",
"// ci will be incremented at end of loop",
"// perform reduce",
"// total - num_removed + 1 (for new node)",
"// insert nodes before reduction",
"// insert reduced node",
"// propagate punctuation sets",
"// insert nodes after reduction",
"// ci will be incremented at end of loop"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0755622e076dfdb31790a17ce2ad15062ea825fb | avaya/cpaas-java | src/main/java/com/zang/api/connectors/UsagesConnector.java | [
"MIT"
] | Java | UsagesConnector | /**
* Used for all forms of communication with the Usages endpoint of the Zang REST API.
* @see ZangConnectorFactory
*/ | Used for all forms of communication with the Usages endpoint of the Zang REST API. | [
"Used",
"for",
"all",
"forms",
"of",
"communication",
"with",
"the",
"Usages",
"endpoint",
"of",
"the",
"Zang",
"REST",
"API",
"."
] | public class UsagesConnector extends BaseConnector {
private UsagesProxy proxy;
UsagesConnector(ZangConfiguration conf, ClientHttpEngine executor) {
super(conf, executor);
proxy = createProxy(UsagesProxy.class);
}
/**
* View the usage of an item returned by List Usages
* @param accountSid Account SID
* @param usageSid Usages SID
* @return Information about the Usage.
* @throws ZangException
*/
public Usage viewUsage(String accountSid, String usageSid) throws ZangException {
Response response = proxy.getUsage(accountSid, usageSid);
return returnThrows(response, Usage.class);
}
/**
* View the usage of an item returned by List Usages
* @param usageSid Usages SID
* @return Information about the Usage.
* @throws ZangException
*/
public Usage viewUsage(String usageSid) throws ZangException {
return viewUsage(conf.getSid(), usageSid);
}
/**
* Lists usages associated with an account.
* @param accountSid Account SID
* @param day Filters usage by day of month. If no month is specified then defaults to current month. Allowed
* values are integers between 1 and 31 depending on the month.
* @param month Filters usage by month. Allowed values are integers between 1 and 12.
* @param year Filters usage by year. Allowed values are valid years in integer form.
* @param product Filters usage by a specific Zang product.
* @param page Page to return
* @param pageSize Number of items to return per page
* @return A list of Usages
* @throws ZangException
*/
public UsagesList listUsages(String accountSid, Integer day, Integer month, Integer year,
Product product, Integer page, Integer pageSize) throws ZangException {
Integer productCode = null;
if (product != null && product != Product.UNKNOWN) {
productCode = Integer.parseInt(product.toString());
}
Response usages = proxy.listUsages(accountSid, day, month, year,
productCode, page, pageSize);
return returnThrows(usages, UsagesList.class);
}
/**
* Lists usages associated with your account.
* @param day Filters usage by day of month. If no month is specified then defaults to current month. Allowed
* values are integers between 1 and 31 depending on the month.
* @param month Filters usage by month. Allowed values are integers between 1 and 12.
* @param year Filters usage by year. Allowed values are valid years in integer form.
* @param product Filters usage by a specific Zang product.
* @param page Page to return
* @param pageSize Number of items to return per page
* @return A list of Usages
* @throws ZangException
*/
public UsagesList listUsages(Integer day, Integer month, Integer year,
Product product, Integer page, Integer pageSize) throws ZangException {
return listUsages(conf.getSid(), day, month, year, product, page, pageSize);
}
/**
* Returns up to 50 usages associated with your account.
* @return A list of Usages
* @throws ZangException
*/
public UsagesList listUsages() throws ZangException {
return listUsages(conf.getSid(), null, null, null, null, null, null);
}
/**
* Lists usages associated with your account.
* @param listUsagesParams Parameters by which to list usages.
* @return A List of Usages.
* @throws ZangException
*/
public UsagesList listUsages(ListUsagesParams listUsagesParams) throws ZangException {
return listUsages(listUsagesParams.getAccountSid() != null ? listUsagesParams.getAccountSid() : conf.getSid(), listUsagesParams.getDay(), listUsagesParams.getMonth(), listUsagesParams.getYear(),
listUsagesParams.getProduct(), listUsagesParams.getPage(), listUsagesParams.getPageSize());
}
} | [
"public",
"class",
"UsagesConnector",
"extends",
"BaseConnector",
"{",
"private",
"UsagesProxy",
"proxy",
";",
"UsagesConnector",
"(",
"ZangConfiguration",
"conf",
",",
"ClientHttpEngine",
"executor",
")",
"{",
"super",
"(",
"conf",
",",
"executor",
")",
";",
"proxy",
"=",
"createProxy",
"(",
"UsagesProxy",
".",
"class",
")",
";",
"}",
"/**\n * View the usage of an item returned by List Usages\n * @param accountSid Account SID\n * @param usageSid Usages SID\n * @return Information about the Usage.\n * @throws ZangException\n */",
"public",
"Usage",
"viewUsage",
"(",
"String",
"accountSid",
",",
"String",
"usageSid",
")",
"throws",
"ZangException",
"{",
"Response",
"response",
"=",
"proxy",
".",
"getUsage",
"(",
"accountSid",
",",
"usageSid",
")",
";",
"return",
"returnThrows",
"(",
"response",
",",
"Usage",
".",
"class",
")",
";",
"}",
"/**\n * View the usage of an item returned by List Usages\n * @param usageSid Usages SID\n * @return Information about the Usage.\n * @throws ZangException\n */",
"public",
"Usage",
"viewUsage",
"(",
"String",
"usageSid",
")",
"throws",
"ZangException",
"{",
"return",
"viewUsage",
"(",
"conf",
".",
"getSid",
"(",
")",
",",
"usageSid",
")",
";",
"}",
"/**\n * Lists usages associated with an account.\n * @param accountSid Account SID\n * @param day Filters usage by day of month. If no month is specified then defaults to current month. Allowed\n * values are integers between 1 and 31 depending on the month.\n * @param month Filters usage by month. Allowed values are integers between 1 and 12.\n * @param year Filters usage by year. Allowed values are valid years in integer form.\n * @param product Filters usage by a specific Zang product.\n * @param page Page to return\n * @param pageSize Number of items to return per page\n * @return A list of Usages\n * @throws ZangException\n */",
"public",
"UsagesList",
"listUsages",
"(",
"String",
"accountSid",
",",
"Integer",
"day",
",",
"Integer",
"month",
",",
"Integer",
"year",
",",
"Product",
"product",
",",
"Integer",
"page",
",",
"Integer",
"pageSize",
")",
"throws",
"ZangException",
"{",
"Integer",
"productCode",
"=",
"null",
";",
"if",
"(",
"product",
"!=",
"null",
"&&",
"product",
"!=",
"Product",
".",
"UNKNOWN",
")",
"{",
"productCode",
"=",
"Integer",
".",
"parseInt",
"(",
"product",
".",
"toString",
"(",
")",
")",
";",
"}",
"Response",
"usages",
"=",
"proxy",
".",
"listUsages",
"(",
"accountSid",
",",
"day",
",",
"month",
",",
"year",
",",
"productCode",
",",
"page",
",",
"pageSize",
")",
";",
"return",
"returnThrows",
"(",
"usages",
",",
"UsagesList",
".",
"class",
")",
";",
"}",
"/**\n * Lists usages associated with your account.\n * @param day Filters usage by day of month. If no month is specified then defaults to current month. Allowed\n * values are integers between 1 and 31 depending on the month.\n * @param month Filters usage by month. Allowed values are integers between 1 and 12.\n * @param year Filters usage by year. Allowed values are valid years in integer form.\n * @param product Filters usage by a specific Zang product.\n * @param page Page to return\n * @param pageSize Number of items to return per page\n * @return A list of Usages\n * @throws ZangException\n */",
"public",
"UsagesList",
"listUsages",
"(",
"Integer",
"day",
",",
"Integer",
"month",
",",
"Integer",
"year",
",",
"Product",
"product",
",",
"Integer",
"page",
",",
"Integer",
"pageSize",
")",
"throws",
"ZangException",
"{",
"return",
"listUsages",
"(",
"conf",
".",
"getSid",
"(",
")",
",",
"day",
",",
"month",
",",
"year",
",",
"product",
",",
"page",
",",
"pageSize",
")",
";",
"}",
"/**\n * Returns up to 50 usages associated with your account.\n * @return A list of Usages\n * @throws ZangException\n */",
"public",
"UsagesList",
"listUsages",
"(",
")",
"throws",
"ZangException",
"{",
"return",
"listUsages",
"(",
"conf",
".",
"getSid",
"(",
")",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
",",
"null",
")",
";",
"}",
"/**\n * Lists usages associated with your account.\n * @param listUsagesParams Parameters by which to list usages.\n * @return A List of Usages.\n * @throws ZangException\n */",
"public",
"UsagesList",
"listUsages",
"(",
"ListUsagesParams",
"listUsagesParams",
")",
"throws",
"ZangException",
"{",
"return",
"listUsages",
"(",
"listUsagesParams",
".",
"getAccountSid",
"(",
")",
"!=",
"null",
"?",
"listUsagesParams",
".",
"getAccountSid",
"(",
")",
":",
"conf",
".",
"getSid",
"(",
")",
",",
"listUsagesParams",
".",
"getDay",
"(",
")",
",",
"listUsagesParams",
".",
"getMonth",
"(",
")",
",",
"listUsagesParams",
".",
"getYear",
"(",
")",
",",
"listUsagesParams",
".",
"getProduct",
"(",
")",
",",
"listUsagesParams",
".",
"getPage",
"(",
")",
",",
"listUsagesParams",
".",
"getPageSize",
"(",
")",
")",
";",
"}",
"}"
] | Used for all forms of communication with the Usages endpoint of the Zang REST API. | [
"Used",
"for",
"all",
"forms",
"of",
"communication",
"with",
"the",
"Usages",
"endpoint",
"of",
"the",
"Zang",
"REST",
"API",
"."
] | [] | [
{
"param": "BaseConnector",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "BaseConnector",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07558c1a376fb62260d9d1a868df43ca01621554 | trungtuan/motech | platform/mds/mds/src/main/java/org/motechproject/mds/dto/SettingDto.java | [
"BSD-3-Clause"
] | Java | SettingDto | /**
* The <code>SettingDto</code> contains information about a single setting inside a field.
*/ | The SettingDto contains information about a single setting inside a field. | [
"The",
"SettingDto",
"contains",
"information",
"about",
"a",
"single",
"setting",
"inside",
"a",
"field",
"."
] | public class SettingDto implements Pair<String, Object> {
private String name;
private Object value;
private List<SettingOptions> options = new LinkedList<>();
private TypeDto type;
public SettingDto() {
this(null, null, null);
}
public SettingDto(String name, Object value) {
this(name, value, null);
}
public SettingDto(final String name, final Object value, final TypeDto type,
final SettingOptions... options) {
this.name = name;
this.value = value;
this.type = type;
if (!ArrayUtils.isEmpty(options)) {
Collections.addAll(this.options, options);
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@JsonIgnore
public String getValueAsString() {
return value == null ? "" : value.toString();
}
@Override
@JsonIgnore
public String getKey() {
return getName();
}
@Override
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public List<SettingOptions> getOptions() {
return options;
}
public void setOptions(List<SettingOptions> options) {
this.options = CollectionUtils.isEmpty(options)
? new LinkedList<SettingOptions>()
: options;
}
public TypeDto getType() {
return type;
}
public void setType(TypeDto type) {
this.type = type;
}
public SettingDto copy() {
return new SettingDto(name, value, type, options.toArray(new SettingOptions[options.size()]));
}
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object obj) {
return EqualsBuilder.reflectionEquals(this, obj);
}
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
} | [
"public",
"class",
"SettingDto",
"implements",
"Pair",
"<",
"String",
",",
"Object",
">",
"{",
"private",
"String",
"name",
";",
"private",
"Object",
"value",
";",
"private",
"List",
"<",
"SettingOptions",
">",
"options",
"=",
"new",
"LinkedList",
"<",
">",
"(",
")",
";",
"private",
"TypeDto",
"type",
";",
"public",
"SettingDto",
"(",
")",
"{",
"this",
"(",
"null",
",",
"null",
",",
"null",
")",
";",
"}",
"public",
"SettingDto",
"(",
"String",
"name",
",",
"Object",
"value",
")",
"{",
"this",
"(",
"name",
",",
"value",
",",
"null",
")",
";",
"}",
"public",
"SettingDto",
"(",
"final",
"String",
"name",
",",
"final",
"Object",
"value",
",",
"final",
"TypeDto",
"type",
",",
"final",
"SettingOptions",
"...",
"options",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"value",
"=",
"value",
";",
"this",
".",
"type",
"=",
"type",
";",
"if",
"(",
"!",
"ArrayUtils",
".",
"isEmpty",
"(",
"options",
")",
")",
"{",
"Collections",
".",
"addAll",
"(",
"this",
".",
"options",
",",
"options",
")",
";",
"}",
"}",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"@",
"JsonIgnore",
"public",
"String",
"getValueAsString",
"(",
")",
"{",
"return",
"value",
"==",
"null",
"?",
"\"",
"\"",
":",
"value",
".",
"toString",
"(",
")",
";",
"}",
"@",
"Override",
"@",
"JsonIgnore",
"public",
"String",
"getKey",
"(",
")",
"{",
"return",
"getName",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"Object",
"getValue",
"(",
")",
"{",
"return",
"value",
";",
"}",
"public",
"void",
"setValue",
"(",
"Object",
"value",
")",
"{",
"this",
".",
"value",
"=",
"value",
";",
"}",
"public",
"List",
"<",
"SettingOptions",
">",
"getOptions",
"(",
")",
"{",
"return",
"options",
";",
"}",
"public",
"void",
"setOptions",
"(",
"List",
"<",
"SettingOptions",
">",
"options",
")",
"{",
"this",
".",
"options",
"=",
"CollectionUtils",
".",
"isEmpty",
"(",
"options",
")",
"?",
"new",
"LinkedList",
"<",
"SettingOptions",
">",
"(",
")",
":",
"options",
";",
"}",
"public",
"TypeDto",
"getType",
"(",
")",
"{",
"return",
"type",
";",
"}",
"public",
"void",
"setType",
"(",
"TypeDto",
"type",
")",
"{",
"this",
".",
"type",
"=",
"type",
";",
"}",
"public",
"SettingDto",
"copy",
"(",
")",
"{",
"return",
"new",
"SettingDto",
"(",
"name",
",",
"value",
",",
"type",
",",
"options",
".",
"toArray",
"(",
"new",
"SettingOptions",
"[",
"options",
".",
"size",
"(",
")",
"]",
")",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"return",
"HashCodeBuilder",
".",
"reflectionHashCode",
"(",
"this",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"obj",
")",
"{",
"return",
"EqualsBuilder",
".",
"reflectionEquals",
"(",
"this",
",",
"obj",
")",
";",
"}",
"/**\n * {@inheritDoc}\n */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"ToStringBuilder",
".",
"reflectionToString",
"(",
"this",
",",
"ToStringStyle",
".",
"SHORT_PREFIX_STYLE",
")",
";",
"}",
"}"
] | The <code>SettingDto</code> contains information about a single setting inside a field. | [
"The",
"<code",
">",
"SettingDto<",
"/",
"code",
">",
"contains",
"information",
"about",
"a",
"single",
"setting",
"inside",
"a",
"field",
"."
] | [] | [
{
"param": "Pair<String, Object>",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Pair<String, Object>",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
07596ad568ffa0532d0fbf32b685808e8cf50144 | fossabot/temporal-java-sdk | src/main/java/io/temporal/internal/sync/WorkflowInvocationHandler.java | [
"Apache-2.0"
] | Java | WorkflowInvocationHandler | /**
* Dynamic implementation of a strongly typed workflow interface that can be used to start, signal
* and query workflows from external processes.
*/ | Dynamic implementation of a strongly typed workflow interface that can be used to start, signal
and query workflows from external processes. | [
"Dynamic",
"implementation",
"of",
"a",
"strongly",
"typed",
"workflow",
"interface",
"that",
"can",
"be",
"used",
"to",
"start",
"signal",
"and",
"query",
"workflows",
"from",
"external",
"processes",
"."
] | class WorkflowInvocationHandler implements InvocationHandler {
public enum InvocationType {
SYNC,
START,
EXECUTE,
SIGNAL_WITH_START,
}
interface SpecificInvocationHandler {
InvocationType getInvocationType();
void invoke(
POJOWorkflowInterfaceMetadata workflowMetadata,
WorkflowStub untyped,
Method method,
Object[] args)
throws Throwable;
<R> R getResult(Class<R> resultClass);
}
private static final ThreadLocal<SpecificInvocationHandler> invocationContext =
new ThreadLocal<>();
/** Must call {@link #closeAsyncInvocation()} if this one was called. */
static void initAsyncInvocation(InvocationType type) {
initAsyncInvocation(type, null);
}
/** Must call {@link #closeAsyncInvocation()} if this one was called. */
static <T> void initAsyncInvocation(InvocationType type, T value) {
if (invocationContext.get() != null) {
throw new IllegalStateException("already in start invocation");
}
if (type == InvocationType.START) {
invocationContext.set(new StartWorkflowInvocationHandler());
} else if (type == InvocationType.EXECUTE) {
invocationContext.set(new ExecuteWorkflowInvocationHandler());
} else if (type == InvocationType.SIGNAL_WITH_START) {
@SuppressWarnings("unchecked")
SignalWithStartBatchRequest batch = (SignalWithStartBatchRequest) value;
invocationContext.set(new SignalWithStartWorkflowInvocationHandler(batch));
} else {
throw new IllegalArgumentException("Unexpected InvocationType: " + type);
}
}
@SuppressWarnings("unchecked")
static <R> R getAsyncInvocationResult(Class<R> resultClass) {
SpecificInvocationHandler invocation = invocationContext.get();
if (invocation == null) {
throw new IllegalStateException("initAsyncInvocation wasn't called");
}
return invocation.getResult(resultClass);
}
/** Closes async invocation created through {@link #initAsyncInvocation(InvocationType)} */
static void closeAsyncInvocation() {
invocationContext.remove();
}
private final WorkflowStub untyped;
private final POJOWorkflowInterfaceMetadata workflowMetadata;
WorkflowInvocationHandler(
Class<?> workflowInterface,
WorkflowClientOptions clientOptions,
GenericWorkflowClientExternal genericClient,
WorkflowExecution execution) {
workflowMetadata = POJOWorkflowInterfaceMetadata.newInstance(workflowInterface);
Optional<String> workflowType = workflowMetadata.getWorkflowType();
WorkflowStub stub = new WorkflowStubImpl(clientOptions, genericClient, workflowType, execution);
for (WorkflowClientInterceptor i : clientOptions.getInterceptors()) {
stub = i.newUntypedWorkflowStub(execution, workflowType, stub);
}
this.untyped = stub;
}
WorkflowInvocationHandler(
Class<?> workflowInterface,
WorkflowClientOptions clientOptions,
GenericWorkflowClientExternal genericClient,
WorkflowOptions options) {
Objects.requireNonNull(options, "options");
workflowMetadata = POJOWorkflowInterfaceMetadata.newInstance(workflowInterface);
Optional<POJOWorkflowMethodMetadata> workflowMethodMetadata =
workflowMetadata.getWorkflowMethod();
if (!workflowMethodMetadata.isPresent()) {
throw new IllegalArgumentException(
"Method annotated with @WorkflowMethod is not found in " + workflowInterface);
}
Method workflowMethod = workflowMethodMetadata.get().getWorkflowMethod();
MethodRetry methodRetry = workflowMethod.getAnnotation(MethodRetry.class);
CronSchedule cronSchedule = workflowMethod.getAnnotation(CronSchedule.class);
WorkflowOptions mergedOptions = WorkflowOptions.merge(methodRetry, cronSchedule, options);
String workflowType = workflowMethodMetadata.get().getName();
WorkflowStub stub =
new WorkflowStubImpl(clientOptions, genericClient, workflowType, mergedOptions);
for (WorkflowClientInterceptor i : clientOptions.getInterceptors()) {
stub = i.newUntypedWorkflowStub(workflowType, mergedOptions, stub);
}
this.untyped = stub;
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
try {
if (method.equals(Object.class.getMethod("toString"))) {
// TODO: workflow info
return "WorkflowInvocationHandler";
}
} catch (NoSuchMethodException e) {
throw new Error("unexpected", e);
}
// Implement StubMarker
if (method.getName().equals(StubMarker.GET_UNTYPED_STUB_METHOD)) {
return untyped;
}
if (!method.getDeclaringClass().isInterface()) {
throw new IllegalArgumentException(
"Interface type is expected: " + method.getDeclaringClass());
}
SpecificInvocationHandler handler = invocationContext.get();
if (handler == null) {
handler = new SyncWorkflowInvocationHandler();
}
handler.invoke(this.workflowMetadata, untyped, method, args);
if (handler.getInvocationType() == InvocationType.SYNC) {
return handler.getResult(method.getReturnType());
}
return Defaults.defaultValue(method.getReturnType());
}
private static void startWorkflow(WorkflowStub untyped, Object[] args) {
Optional<WorkflowOptions> options = untyped.getOptions();
if (untyped.getExecution() == null
|| (options.isPresent()
&& options.get().getWorkflowIdReusePolicy() == WorkflowIdReusePolicy.AllowDuplicate)) {
try {
untyped.start(args);
} catch (DuplicateWorkflowException e) {
// We do allow duplicated calls if policy is not AllowDuplicate. Semantic is to wait for
// result.
if (options.isPresent()
&& options.get().getWorkflowIdReusePolicy() == WorkflowIdReusePolicy.AllowDuplicate) {
throw e;
}
}
}
}
static void checkAnnotations(
Method method,
WorkflowMethod workflowMethod,
QueryMethod queryMethod,
SignalMethod signalMethod) {
int count =
(workflowMethod == null ? 0 : 1)
+ (queryMethod == null ? 0 : 1)
+ (signalMethod == null ? 0 : 1);
if (count > 1) {
throw new IllegalArgumentException(
method
+ " must contain at most one annotation "
+ "from @WorkflowMethod, @QueryMethod or @SignalMethod");
}
}
private static class StartWorkflowInvocationHandler implements SpecificInvocationHandler {
private Object result;
@Override
public InvocationType getInvocationType() {
return InvocationType.START;
}
@Override
public void invoke(
POJOWorkflowInterfaceMetadata workflowMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
WorkflowMethod workflowMethod = method.getAnnotation(WorkflowMethod.class);
if (workflowMethod == null) {
throw new IllegalArgumentException(
"WorkflowClient.start can be called only on a method annotated with @WorkflowMethod");
}
result = untyped.start(args);
}
@Override
@SuppressWarnings("unchecked")
public <R> R getResult(Class<R> resultClass) {
return (R) result;
}
}
private static class SyncWorkflowInvocationHandler implements SpecificInvocationHandler {
private Object result;
@Override
public InvocationType getInvocationType() {
return InvocationType.SYNC;
}
@Override
public void invoke(
POJOWorkflowInterfaceMetadata workflowMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
POJOWorkflowMethodMetadata methodMetadata = workflowMetadata.getMethodMetadata(method);
WorkflowMethodType type = methodMetadata.getType();
if (type == WorkflowMethodType.WORKFLOW) {
result = startWorkflow(untyped, method, args);
} else if (type == WorkflowMethodType.QUERY) {
result = queryWorkflow(methodMetadata, untyped, method, args);
} else if (type == WorkflowMethodType.SIGNAL) {
signalWorkflow(methodMetadata, untyped, method, args);
result = null;
} else {
throw new IllegalArgumentException(
method + " is not annotated with @WorkflowMethod or @QueryMethod");
}
}
@Override
@SuppressWarnings("unchecked")
public <R> R getResult(Class<R> resultClass) {
return (R) result;
}
private void signalWorkflow(
POJOWorkflowMethodMetadata methodMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
if (method.getReturnType() != Void.TYPE) {
throw new IllegalArgumentException("Signal method must have void return type: " + method);
}
String signalName = methodMetadata.getName();
untyped.signal(signalName, args);
}
private Object queryWorkflow(
POJOWorkflowMethodMetadata methodMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
if (method.getReturnType() == Void.TYPE) {
throw new IllegalArgumentException("Query method cannot have void return type: " + method);
}
String queryType = methodMetadata.getName();
return untyped.query(queryType, method.getReturnType(), method.getGenericReturnType(), args);
}
@SuppressWarnings("FutureReturnValueIgnored")
private Object startWorkflow(WorkflowStub untyped, Method method, Object[] args) {
WorkflowInvocationHandler.startWorkflow(untyped, args);
return untyped.getResult(method.getReturnType(), method.getGenericReturnType());
}
}
private static class ExecuteWorkflowInvocationHandler implements SpecificInvocationHandler {
private Object result;
@Override
public InvocationType getInvocationType() {
return InvocationType.EXECUTE;
}
@Override
public void invoke(
POJOWorkflowInterfaceMetadata workflowMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
WorkflowMethod workflowMethod = method.getAnnotation(WorkflowMethod.class);
if (workflowMethod == null) {
throw new IllegalArgumentException(
"WorkflowClient.execute can be called only on a method annotated with @WorkflowMethod");
}
WorkflowInvocationHandler.startWorkflow(untyped, args);
result = untyped.getResultAsync(method.getReturnType(), method.getGenericReturnType());
}
@Override
@SuppressWarnings("unchecked")
public <R> R getResult(Class<R> resultClass) {
return (R) result;
}
}
private static class SignalWithStartWorkflowInvocationHandler
implements SpecificInvocationHandler {
private final SignalWithStartBatchRequest batch;
public SignalWithStartWorkflowInvocationHandler(SignalWithStartBatchRequest batch) {
this.batch = batch;
}
@Override
public InvocationType getInvocationType() {
return InvocationType.SIGNAL_WITH_START;
}
@Override
public void invoke(
POJOWorkflowInterfaceMetadata workflowMetadata,
WorkflowStub untyped,
Method method,
Object[] args) {
POJOWorkflowMethodMetadata methodMetadata = workflowMetadata.getMethodMetadata(method);
switch (methodMetadata.getType()) {
case QUERY:
throw new IllegalArgumentException(
"SignalWithStart batch doesn't accept methods annotated with @QueryMethod");
case WORKFLOW:
batch.start(untyped, args);
break;
case SIGNAL:
batch.signal(untyped, methodMetadata.getName(), args);
break;
}
}
@Override
public <R> R getResult(Class<R> resultClass) {
throw new IllegalStateException("No result is expected");
}
}
} | [
"class",
"WorkflowInvocationHandler",
"implements",
"InvocationHandler",
"{",
"public",
"enum",
"InvocationType",
"{",
"SYNC",
",",
"START",
",",
"EXECUTE",
",",
"SIGNAL_WITH_START",
",",
"}",
"interface",
"SpecificInvocationHandler",
"{",
"InvocationType",
"getInvocationType",
"(",
")",
";",
"void",
"invoke",
"(",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
";",
"<",
"R",
">",
"R",
"getResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
";",
"}",
"private",
"static",
"final",
"ThreadLocal",
"<",
"SpecificInvocationHandler",
">",
"invocationContext",
"=",
"new",
"ThreadLocal",
"<",
">",
"(",
")",
";",
"/** Must call {@link #closeAsyncInvocation()} if this one was called. */",
"static",
"void",
"initAsyncInvocation",
"(",
"InvocationType",
"type",
")",
"{",
"initAsyncInvocation",
"(",
"type",
",",
"null",
")",
";",
"}",
"/** Must call {@link #closeAsyncInvocation()} if this one was called. */",
"static",
"<",
"T",
">",
"void",
"initAsyncInvocation",
"(",
"InvocationType",
"type",
",",
"T",
"value",
")",
"{",
"if",
"(",
"invocationContext",
".",
"get",
"(",
")",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"already in start invocation",
"\"",
")",
";",
"}",
"if",
"(",
"type",
"==",
"InvocationType",
".",
"START",
")",
"{",
"invocationContext",
".",
"set",
"(",
"new",
"StartWorkflowInvocationHandler",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"InvocationType",
".",
"EXECUTE",
")",
"{",
"invocationContext",
".",
"set",
"(",
"new",
"ExecuteWorkflowInvocationHandler",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"InvocationType",
".",
"SIGNAL_WITH_START",
")",
"{",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"SignalWithStartBatchRequest",
"batch",
"=",
"(",
"SignalWithStartBatchRequest",
")",
"value",
";",
"invocationContext",
".",
"set",
"(",
"new",
"SignalWithStartWorkflowInvocationHandler",
"(",
"batch",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Unexpected InvocationType: ",
"\"",
"+",
"type",
")",
";",
"}",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"static",
"<",
"R",
">",
"R",
"getAsyncInvocationResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
"{",
"SpecificInvocationHandler",
"invocation",
"=",
"invocationContext",
".",
"get",
"(",
")",
";",
"if",
"(",
"invocation",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"initAsyncInvocation wasn't called",
"\"",
")",
";",
"}",
"return",
"invocation",
".",
"getResult",
"(",
"resultClass",
")",
";",
"}",
"/** Closes async invocation created through {@link #initAsyncInvocation(InvocationType)} */",
"static",
"void",
"closeAsyncInvocation",
"(",
")",
"{",
"invocationContext",
".",
"remove",
"(",
")",
";",
"}",
"private",
"final",
"WorkflowStub",
"untyped",
";",
"private",
"final",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
";",
"WorkflowInvocationHandler",
"(",
"Class",
"<",
"?",
">",
"workflowInterface",
",",
"WorkflowClientOptions",
"clientOptions",
",",
"GenericWorkflowClientExternal",
"genericClient",
",",
"WorkflowExecution",
"execution",
")",
"{",
"workflowMetadata",
"=",
"POJOWorkflowInterfaceMetadata",
".",
"newInstance",
"(",
"workflowInterface",
")",
";",
"Optional",
"<",
"String",
">",
"workflowType",
"=",
"workflowMetadata",
".",
"getWorkflowType",
"(",
")",
";",
"WorkflowStub",
"stub",
"=",
"new",
"WorkflowStubImpl",
"(",
"clientOptions",
",",
"genericClient",
",",
"workflowType",
",",
"execution",
")",
";",
"for",
"(",
"WorkflowClientInterceptor",
"i",
":",
"clientOptions",
".",
"getInterceptors",
"(",
")",
")",
"{",
"stub",
"=",
"i",
".",
"newUntypedWorkflowStub",
"(",
"execution",
",",
"workflowType",
",",
"stub",
")",
";",
"}",
"this",
".",
"untyped",
"=",
"stub",
";",
"}",
"WorkflowInvocationHandler",
"(",
"Class",
"<",
"?",
">",
"workflowInterface",
",",
"WorkflowClientOptions",
"clientOptions",
",",
"GenericWorkflowClientExternal",
"genericClient",
",",
"WorkflowOptions",
"options",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"options",
",",
"\"",
"options",
"\"",
")",
";",
"workflowMetadata",
"=",
"POJOWorkflowInterfaceMetadata",
".",
"newInstance",
"(",
"workflowInterface",
")",
";",
"Optional",
"<",
"POJOWorkflowMethodMetadata",
">",
"workflowMethodMetadata",
"=",
"workflowMetadata",
".",
"getWorkflowMethod",
"(",
")",
";",
"if",
"(",
"!",
"workflowMethodMetadata",
".",
"isPresent",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Method annotated with @WorkflowMethod is not found in ",
"\"",
"+",
"workflowInterface",
")",
";",
"}",
"Method",
"workflowMethod",
"=",
"workflowMethodMetadata",
".",
"get",
"(",
")",
".",
"getWorkflowMethod",
"(",
")",
";",
"MethodRetry",
"methodRetry",
"=",
"workflowMethod",
".",
"getAnnotation",
"(",
"MethodRetry",
".",
"class",
")",
";",
"CronSchedule",
"cronSchedule",
"=",
"workflowMethod",
".",
"getAnnotation",
"(",
"CronSchedule",
".",
"class",
")",
";",
"WorkflowOptions",
"mergedOptions",
"=",
"WorkflowOptions",
".",
"merge",
"(",
"methodRetry",
",",
"cronSchedule",
",",
"options",
")",
";",
"String",
"workflowType",
"=",
"workflowMethodMetadata",
".",
"get",
"(",
")",
".",
"getName",
"(",
")",
";",
"WorkflowStub",
"stub",
"=",
"new",
"WorkflowStubImpl",
"(",
"clientOptions",
",",
"genericClient",
",",
"workflowType",
",",
"mergedOptions",
")",
";",
"for",
"(",
"WorkflowClientInterceptor",
"i",
":",
"clientOptions",
".",
"getInterceptors",
"(",
")",
")",
"{",
"stub",
"=",
"i",
".",
"newUntypedWorkflowStub",
"(",
"workflowType",
",",
"mergedOptions",
",",
"stub",
")",
";",
"}",
"this",
".",
"untyped",
"=",
"stub",
";",
"}",
"@",
"Override",
"public",
"Object",
"invoke",
"(",
"Object",
"proxy",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"throws",
"Throwable",
"{",
"try",
"{",
"if",
"(",
"method",
".",
"equals",
"(",
"Object",
".",
"class",
".",
"getMethod",
"(",
"\"",
"toString",
"\"",
")",
")",
")",
"{",
"return",
"\"",
"WorkflowInvocationHandler",
"\"",
";",
"}",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"",
"unexpected",
"\"",
",",
"e",
")",
";",
"}",
"if",
"(",
"method",
".",
"getName",
"(",
")",
".",
"equals",
"(",
"StubMarker",
".",
"GET_UNTYPED_STUB_METHOD",
")",
")",
"{",
"return",
"untyped",
";",
"}",
"if",
"(",
"!",
"method",
".",
"getDeclaringClass",
"(",
")",
".",
"isInterface",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Interface type is expected: ",
"\"",
"+",
"method",
".",
"getDeclaringClass",
"(",
")",
")",
";",
"}",
"SpecificInvocationHandler",
"handler",
"=",
"invocationContext",
".",
"get",
"(",
")",
";",
"if",
"(",
"handler",
"==",
"null",
")",
"{",
"handler",
"=",
"new",
"SyncWorkflowInvocationHandler",
"(",
")",
";",
"}",
"handler",
".",
"invoke",
"(",
"this",
".",
"workflowMetadata",
",",
"untyped",
",",
"method",
",",
"args",
")",
";",
"if",
"(",
"handler",
".",
"getInvocationType",
"(",
")",
"==",
"InvocationType",
".",
"SYNC",
")",
"{",
"return",
"handler",
".",
"getResult",
"(",
"method",
".",
"getReturnType",
"(",
")",
")",
";",
"}",
"return",
"Defaults",
".",
"defaultValue",
"(",
"method",
".",
"getReturnType",
"(",
")",
")",
";",
"}",
"private",
"static",
"void",
"startWorkflow",
"(",
"WorkflowStub",
"untyped",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"Optional",
"<",
"WorkflowOptions",
">",
"options",
"=",
"untyped",
".",
"getOptions",
"(",
")",
";",
"if",
"(",
"untyped",
".",
"getExecution",
"(",
")",
"==",
"null",
"||",
"(",
"options",
".",
"isPresent",
"(",
")",
"&&",
"options",
".",
"get",
"(",
")",
".",
"getWorkflowIdReusePolicy",
"(",
")",
"==",
"WorkflowIdReusePolicy",
".",
"AllowDuplicate",
")",
")",
"{",
"try",
"{",
"untyped",
".",
"start",
"(",
"args",
")",
";",
"}",
"catch",
"(",
"DuplicateWorkflowException",
"e",
")",
"{",
"if",
"(",
"options",
".",
"isPresent",
"(",
")",
"&&",
"options",
".",
"get",
"(",
")",
".",
"getWorkflowIdReusePolicy",
"(",
")",
"==",
"WorkflowIdReusePolicy",
".",
"AllowDuplicate",
")",
"{",
"throw",
"e",
";",
"}",
"}",
"}",
"}",
"static",
"void",
"checkAnnotations",
"(",
"Method",
"method",
",",
"WorkflowMethod",
"workflowMethod",
",",
"QueryMethod",
"queryMethod",
",",
"SignalMethod",
"signalMethod",
")",
"{",
"int",
"count",
"=",
"(",
"workflowMethod",
"==",
"null",
"?",
"0",
":",
"1",
")",
"+",
"(",
"queryMethod",
"==",
"null",
"?",
"0",
":",
"1",
")",
"+",
"(",
"signalMethod",
"==",
"null",
"?",
"0",
":",
"1",
")",
";",
"if",
"(",
"count",
">",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"method",
"+",
"\"",
" must contain at most one annotation ",
"\"",
"+",
"\"",
"from @WorkflowMethod, @QueryMethod or @SignalMethod",
"\"",
")",
";",
"}",
"}",
"private",
"static",
"class",
"StartWorkflowInvocationHandler",
"implements",
"SpecificInvocationHandler",
"{",
"private",
"Object",
"result",
";",
"@",
"Override",
"public",
"InvocationType",
"getInvocationType",
"(",
")",
"{",
"return",
"InvocationType",
".",
"START",
";",
"}",
"@",
"Override",
"public",
"void",
"invoke",
"(",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"WorkflowMethod",
"workflowMethod",
"=",
"method",
".",
"getAnnotation",
"(",
"WorkflowMethod",
".",
"class",
")",
";",
"if",
"(",
"workflowMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"WorkflowClient.start can be called only on a method annotated with @WorkflowMethod",
"\"",
")",
";",
"}",
"result",
"=",
"untyped",
".",
"start",
"(",
"args",
")",
";",
"}",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"R",
">",
"R",
"getResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
"{",
"return",
"(",
"R",
")",
"result",
";",
"}",
"}",
"private",
"static",
"class",
"SyncWorkflowInvocationHandler",
"implements",
"SpecificInvocationHandler",
"{",
"private",
"Object",
"result",
";",
"@",
"Override",
"public",
"InvocationType",
"getInvocationType",
"(",
")",
"{",
"return",
"InvocationType",
".",
"SYNC",
";",
"}",
"@",
"Override",
"public",
"void",
"invoke",
"(",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"POJOWorkflowMethodMetadata",
"methodMetadata",
"=",
"workflowMetadata",
".",
"getMethodMetadata",
"(",
"method",
")",
";",
"WorkflowMethodType",
"type",
"=",
"methodMetadata",
".",
"getType",
"(",
")",
";",
"if",
"(",
"type",
"==",
"WorkflowMethodType",
".",
"WORKFLOW",
")",
"{",
"result",
"=",
"startWorkflow",
"(",
"untyped",
",",
"method",
",",
"args",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"WorkflowMethodType",
".",
"QUERY",
")",
"{",
"result",
"=",
"queryWorkflow",
"(",
"methodMetadata",
",",
"untyped",
",",
"method",
",",
"args",
")",
";",
"}",
"else",
"if",
"(",
"type",
"==",
"WorkflowMethodType",
".",
"SIGNAL",
")",
"{",
"signalWorkflow",
"(",
"methodMetadata",
",",
"untyped",
",",
"method",
",",
"args",
")",
";",
"result",
"=",
"null",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"method",
"+",
"\"",
" is not annotated with @WorkflowMethod or @QueryMethod",
"\"",
")",
";",
"}",
"}",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"R",
">",
"R",
"getResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
"{",
"return",
"(",
"R",
")",
"result",
";",
"}",
"private",
"void",
"signalWorkflow",
"(",
"POJOWorkflowMethodMetadata",
"methodMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"method",
".",
"getReturnType",
"(",
")",
"!=",
"Void",
".",
"TYPE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Signal method must have void return type: ",
"\"",
"+",
"method",
")",
";",
"}",
"String",
"signalName",
"=",
"methodMetadata",
".",
"getName",
"(",
")",
";",
"untyped",
".",
"signal",
"(",
"signalName",
",",
"args",
")",
";",
"}",
"private",
"Object",
"queryWorkflow",
"(",
"POJOWorkflowMethodMetadata",
"methodMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"if",
"(",
"method",
".",
"getReturnType",
"(",
")",
"==",
"Void",
".",
"TYPE",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Query method cannot have void return type: ",
"\"",
"+",
"method",
")",
";",
"}",
"String",
"queryType",
"=",
"methodMetadata",
".",
"getName",
"(",
")",
";",
"return",
"untyped",
".",
"query",
"(",
"queryType",
",",
"method",
".",
"getReturnType",
"(",
")",
",",
"method",
".",
"getGenericReturnType",
"(",
")",
",",
"args",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"FutureReturnValueIgnored",
"\"",
")",
"private",
"Object",
"startWorkflow",
"(",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"WorkflowInvocationHandler",
".",
"startWorkflow",
"(",
"untyped",
",",
"args",
")",
";",
"return",
"untyped",
".",
"getResult",
"(",
"method",
".",
"getReturnType",
"(",
")",
",",
"method",
".",
"getGenericReturnType",
"(",
")",
")",
";",
"}",
"}",
"private",
"static",
"class",
"ExecuteWorkflowInvocationHandler",
"implements",
"SpecificInvocationHandler",
"{",
"private",
"Object",
"result",
";",
"@",
"Override",
"public",
"InvocationType",
"getInvocationType",
"(",
")",
"{",
"return",
"InvocationType",
".",
"EXECUTE",
";",
"}",
"@",
"Override",
"public",
"void",
"invoke",
"(",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"WorkflowMethod",
"workflowMethod",
"=",
"method",
".",
"getAnnotation",
"(",
"WorkflowMethod",
".",
"class",
")",
";",
"if",
"(",
"workflowMethod",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"WorkflowClient.execute can be called only on a method annotated with @WorkflowMethod",
"\"",
")",
";",
"}",
"WorkflowInvocationHandler",
".",
"startWorkflow",
"(",
"untyped",
",",
"args",
")",
";",
"result",
"=",
"untyped",
".",
"getResultAsync",
"(",
"method",
".",
"getReturnType",
"(",
")",
",",
"method",
".",
"getGenericReturnType",
"(",
")",
")",
";",
"}",
"@",
"Override",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"<",
"R",
">",
"R",
"getResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
"{",
"return",
"(",
"R",
")",
"result",
";",
"}",
"}",
"private",
"static",
"class",
"SignalWithStartWorkflowInvocationHandler",
"implements",
"SpecificInvocationHandler",
"{",
"private",
"final",
"SignalWithStartBatchRequest",
"batch",
";",
"public",
"SignalWithStartWorkflowInvocationHandler",
"(",
"SignalWithStartBatchRequest",
"batch",
")",
"{",
"this",
".",
"batch",
"=",
"batch",
";",
"}",
"@",
"Override",
"public",
"InvocationType",
"getInvocationType",
"(",
")",
"{",
"return",
"InvocationType",
".",
"SIGNAL_WITH_START",
";",
"}",
"@",
"Override",
"public",
"void",
"invoke",
"(",
"POJOWorkflowInterfaceMetadata",
"workflowMetadata",
",",
"WorkflowStub",
"untyped",
",",
"Method",
"method",
",",
"Object",
"[",
"]",
"args",
")",
"{",
"POJOWorkflowMethodMetadata",
"methodMetadata",
"=",
"workflowMetadata",
".",
"getMethodMetadata",
"(",
"method",
")",
";",
"switch",
"(",
"methodMetadata",
".",
"getType",
"(",
")",
")",
"{",
"case",
"QUERY",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"SignalWithStart batch doesn't accept methods annotated with @QueryMethod",
"\"",
")",
";",
"case",
"WORKFLOW",
":",
"batch",
".",
"start",
"(",
"untyped",
",",
"args",
")",
";",
"break",
";",
"case",
"SIGNAL",
":",
"batch",
".",
"signal",
"(",
"untyped",
",",
"methodMetadata",
".",
"getName",
"(",
")",
",",
"args",
")",
";",
"break",
";",
"}",
"}",
"@",
"Override",
"public",
"<",
"R",
">",
"R",
"getResult",
"(",
"Class",
"<",
"R",
">",
"resultClass",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"No result is expected",
"\"",
")",
";",
"}",
"}",
"}"
] | Dynamic implementation of a strongly typed workflow interface that can be used to start, signal
and query workflows from external processes. | [
"Dynamic",
"implementation",
"of",
"a",
"strongly",
"typed",
"workflow",
"interface",
"that",
"can",
"be",
"used",
"to",
"start",
"signal",
"and",
"query",
"workflows",
"from",
"external",
"processes",
"."
] | [
"// TODO: workflow info",
"// Implement StubMarker",
"// We do allow duplicated calls if policy is not AllowDuplicate. Semantic is to wait for",
"// result."
] | [
{
"param": "InvocationHandler",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "InvocationHandler",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
075c9273e3645fd8d1ec5930fff89d613d4b5d83 | KoizumiSinya/DemoProject | Animation/SwipeBackDemo/src/main/java/jp/sinya/swipeback/demo/library3/core/anim/DefaultVerticalAnimator.java | [
"Apache-2.0"
] | Java | DefaultVerticalAnimator | /**
* Created by YoKeyword on 16/2/5.
*/ | Created by YoKeyword on 16/2/5. | [
"Created",
"by",
"YoKeyword",
"on",
"16",
"/",
"2",
"/",
"5",
"."
] | public class DefaultVerticalAnimator extends FragmentAnimator implements Parcelable {
public DefaultVerticalAnimator() {
enter = R.anim.v_fragment_enter;
exit = R.anim.v_fragment_exit;
popEnter = R.anim.v_fragment_pop_enter;
popExit = R.anim.v_fragment_pop_exit;
}
protected DefaultVerticalAnimator(Parcel in) {
super(in);
}
@Override
public void writeToParcel(Parcel dest, int flags) {
super.writeToParcel(dest, flags);
}
@Override
public int describeContents() {
return 0;
}
public static final Creator<DefaultVerticalAnimator> CREATOR = new Creator<DefaultVerticalAnimator>() {
@Override
public DefaultVerticalAnimator createFromParcel(Parcel in) {
return new DefaultVerticalAnimator(in);
}
@Override
public DefaultVerticalAnimator[] newArray(int size) {
return new DefaultVerticalAnimator[size];
}
};
} | [
"public",
"class",
"DefaultVerticalAnimator",
"extends",
"FragmentAnimator",
"implements",
"Parcelable",
"{",
"public",
"DefaultVerticalAnimator",
"(",
")",
"{",
"enter",
"=",
"R",
".",
"anim",
".",
"v_fragment_enter",
";",
"exit",
"=",
"R",
".",
"anim",
".",
"v_fragment_exit",
";",
"popEnter",
"=",
"R",
".",
"anim",
".",
"v_fragment_pop_enter",
";",
"popExit",
"=",
"R",
".",
"anim",
".",
"v_fragment_pop_exit",
";",
"}",
"protected",
"DefaultVerticalAnimator",
"(",
"Parcel",
"in",
")",
"{",
"super",
"(",
"in",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"writeToParcel",
"(",
"Parcel",
"dest",
",",
"int",
"flags",
")",
"{",
"super",
".",
"writeToParcel",
"(",
"dest",
",",
"flags",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"describeContents",
"(",
")",
"{",
"return",
"0",
";",
"}",
"public",
"static",
"final",
"Creator",
"<",
"DefaultVerticalAnimator",
">",
"CREATOR",
"=",
"new",
"Creator",
"<",
"DefaultVerticalAnimator",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"DefaultVerticalAnimator",
"createFromParcel",
"(",
"Parcel",
"in",
")",
"{",
"return",
"new",
"DefaultVerticalAnimator",
"(",
"in",
")",
";",
"}",
"@",
"Override",
"public",
"DefaultVerticalAnimator",
"[",
"]",
"newArray",
"(",
"int",
"size",
")",
"{",
"return",
"new",
"DefaultVerticalAnimator",
"[",
"size",
"]",
";",
"}",
"}",
";",
"}"
] | Created by YoKeyword on 16/2/5. | [
"Created",
"by",
"YoKeyword",
"on",
"16",
"/",
"2",
"/",
"5",
"."
] | [] | [
{
"param": "FragmentAnimator",
"type": null
},
{
"param": "Parcelable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "FragmentAnimator",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Parcelable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
075e409902a4af5d0cc1b620c5a90210068e1538 | nlipkow/dcaf-java | src/main/java/de/unibremen/beduino/dcaf/AuthorizationManager.java | [
"MIT"
] | Java | AuthorizationManager | /**
* @author Norman Lipkow
*/ | @author Norman Lipkow | [
"@author",
"Norman",
"Lipkow"
] | abstract class AuthorizationManager extends CoapServer {
private static final String TRUST_STORE_PASSWORD = "rootPass";
private static final String KEY_STORE_PASSWORD = "endPass";
private static final String KEY_STORE_LOCATION = "certs/keyStore.jks";
private static final String TRUST_STORE_LOCATION = "certs/trustStore.jks";
private static final String KEYSTORE_TYPE = "JKS";
private final Logger logger = LoggerFactory.getLogger(getClass());
private final int port;
protected DTLSConnector dtlsConnector;
private DtlsConnectorConfig config;
AuthorizationManager() {
this.port = NetworkConfig.getStandard().getInt(NetworkConfig.Keys.COAP_SECURE_PORT);
}
AuthorizationManager(int port) {
this.port = port;
}
void addDTLSEndpoint(String identity) {
addDTLSEndpoint(this.port, identity);
}
void addDTLSEndpoint(int port, String identity) {
for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
if (addr.getHostAddress().equals("127.0.0.1")) {
InetSocketAddress bindToAddress = new InetSocketAddress(addr, port);
dtlsConnector = getDtlsConnector(identity, bindToAddress);
CoapEndpoint.CoapEndpointBuilder builder = new CoapEndpoint.CoapEndpointBuilder();
builder.setConnector(dtlsConnector)
.setNetworkConfig(NetworkConfig.getStandard());
addEndpoint(builder.build());
}
}
}
/**
* Add individual endpoints listening on default CoAP port on all ddresses of all network interfaces.
*/
public void addEndpoints(int port) {
for (InetAddress addr : EndpointManager.getEndpointManager().getNetworkInterfaces()) {
InetSocketAddress bindToAddress = new InetSocketAddress(addr, port);
CoapEndpoint.CoapEndpointBuilder coapEndpointBuilder = new CoapEndpoint.CoapEndpointBuilder();
addEndpoint(coapEndpointBuilder.setInetSocketAddress(bindToAddress).build());
}
}
int getDTLSPort() {
return port;
}
private DTLSConnector getDtlsConnector(String identity, InetSocketAddress bindToAddress) {
if (dtlsConnector == null) {
DTLSConnector connector;
try (InputStream in = getClass().getClassLoader().getResourceAsStream(KEY_STORE_LOCATION);
InputStream inTrust = getClass().getClassLoader().getResourceAsStream(TRUST_STORE_LOCATION)) {
KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE);
keyStore.load(in, KEY_STORE_PASSWORD.toCharArray());
KeyStore trustStore = KeyStore.getInstance(KEYSTORE_TYPE);
trustStore.load(inTrust, TRUST_STORE_PASSWORD.toCharArray());
Certificate[] trustedCertificates = new Certificate[1];
trustedCertificates[0] = trustStore.getCertificate("root");
DtlsConnectorConfig.Builder dTLSConfig = new DtlsConnectorConfig.Builder();
JsonPskStore store = new JsonPskStore();
config = dTLSConfig.setAddress(bindToAddress)
.setIdentity((PrivateKey)keyStore.getKey(identity, KEY_STORE_PASSWORD.toCharArray()),
keyStore.getCertificateChain(identity), true)
.setClientAuthenticationRequired(true)
.setPskStore(store)
.setTrustStore(trustedCertificates)
.build();
connector = new DTLSConnector(config);
} catch (Exception e) {
throw new RuntimeException("Something went wrong while initializing the key and trust store", e.getCause());
}
return connector;
}
return dtlsConnector;
}
public void addPsk(final String identity, final String key) {
PskStore store = this.config.getPskStore();
if (store instanceof JsonPskStore) {
((JsonPskStore) store).setKey(identity, key);
return;
}
logger.error("PSKStore does not support adding new keys after initialization.");
}
public void addKnownPeer(final InetSocketAddress peer, final String identity, final String key) {
PskStore store = this.config.getPskStore();
if (store instanceof JsonPskStore) {
((JsonPskStore) store).addKnownPeer(peer, identity, key);
return;
}
logger.error("PSKStore does not support adding new keys after initialization.");
}
public byte[] getPsk(final String identity) {
return this.config.getPskStore().getKey(identity);
}
void deletePsk(final String identity) {
PskStore store = this.config.getPskStore();
if (store instanceof JsonPskStore) {
((JsonPskStore) store).deleteKey(identity);
return;
}
logger.error("PSKStore does not support deleting keys after initialization.");
}
String getInterfaces() {
return getEndpoints().stream()
.map(Endpoint::getAddress)
.map(a -> "[" + a.getHostString() + ":" + a.getPort() + "]")
.collect(Collectors.joining(", "));
}
} | [
"abstract",
"class",
"AuthorizationManager",
"extends",
"CoapServer",
"{",
"private",
"static",
"final",
"String",
"TRUST_STORE_PASSWORD",
"=",
"\"",
"rootPass",
"\"",
";",
"private",
"static",
"final",
"String",
"KEY_STORE_PASSWORD",
"=",
"\"",
"endPass",
"\"",
";",
"private",
"static",
"final",
"String",
"KEY_STORE_LOCATION",
"=",
"\"",
"certs/keyStore.jks",
"\"",
";",
"private",
"static",
"final",
"String",
"TRUST_STORE_LOCATION",
"=",
"\"",
"certs/trustStore.jks",
"\"",
";",
"private",
"static",
"final",
"String",
"KEYSTORE_TYPE",
"=",
"\"",
"JKS",
"\"",
";",
"private",
"final",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"getClass",
"(",
")",
")",
";",
"private",
"final",
"int",
"port",
";",
"protected",
"DTLSConnector",
"dtlsConnector",
";",
"private",
"DtlsConnectorConfig",
"config",
";",
"AuthorizationManager",
"(",
")",
"{",
"this",
".",
"port",
"=",
"NetworkConfig",
".",
"getStandard",
"(",
")",
".",
"getInt",
"(",
"NetworkConfig",
".",
"Keys",
".",
"COAP_SECURE_PORT",
")",
";",
"}",
"AuthorizationManager",
"(",
"int",
"port",
")",
"{",
"this",
".",
"port",
"=",
"port",
";",
"}",
"void",
"addDTLSEndpoint",
"(",
"String",
"identity",
")",
"{",
"addDTLSEndpoint",
"(",
"this",
".",
"port",
",",
"identity",
")",
";",
"}",
"void",
"addDTLSEndpoint",
"(",
"int",
"port",
",",
"String",
"identity",
")",
"{",
"for",
"(",
"InetAddress",
"addr",
":",
"EndpointManager",
".",
"getEndpointManager",
"(",
")",
".",
"getNetworkInterfaces",
"(",
")",
")",
"{",
"if",
"(",
"addr",
".",
"getHostAddress",
"(",
")",
".",
"equals",
"(",
"\"",
"127.0.0.1",
"\"",
")",
")",
"{",
"InetSocketAddress",
"bindToAddress",
"=",
"new",
"InetSocketAddress",
"(",
"addr",
",",
"port",
")",
";",
"dtlsConnector",
"=",
"getDtlsConnector",
"(",
"identity",
",",
"bindToAddress",
")",
";",
"CoapEndpoint",
".",
"CoapEndpointBuilder",
"builder",
"=",
"new",
"CoapEndpoint",
".",
"CoapEndpointBuilder",
"(",
")",
";",
"builder",
".",
"setConnector",
"(",
"dtlsConnector",
")",
".",
"setNetworkConfig",
"(",
"NetworkConfig",
".",
"getStandard",
"(",
")",
")",
";",
"addEndpoint",
"(",
"builder",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"}",
"/**\n * Add individual endpoints listening on default CoAP port on all ddresses of all network interfaces.\n */",
"public",
"void",
"addEndpoints",
"(",
"int",
"port",
")",
"{",
"for",
"(",
"InetAddress",
"addr",
":",
"EndpointManager",
".",
"getEndpointManager",
"(",
")",
".",
"getNetworkInterfaces",
"(",
")",
")",
"{",
"InetSocketAddress",
"bindToAddress",
"=",
"new",
"InetSocketAddress",
"(",
"addr",
",",
"port",
")",
";",
"CoapEndpoint",
".",
"CoapEndpointBuilder",
"coapEndpointBuilder",
"=",
"new",
"CoapEndpoint",
".",
"CoapEndpointBuilder",
"(",
")",
";",
"addEndpoint",
"(",
"coapEndpointBuilder",
".",
"setInetSocketAddress",
"(",
"bindToAddress",
")",
".",
"build",
"(",
")",
")",
";",
"}",
"}",
"int",
"getDTLSPort",
"(",
")",
"{",
"return",
"port",
";",
"}",
"private",
"DTLSConnector",
"getDtlsConnector",
"(",
"String",
"identity",
",",
"InetSocketAddress",
"bindToAddress",
")",
"{",
"if",
"(",
"dtlsConnector",
"==",
"null",
")",
"{",
"DTLSConnector",
"connector",
";",
"try",
"(",
"InputStream",
"in",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"KEY_STORE_LOCATION",
")",
";",
"InputStream",
"inTrust",
"=",
"getClass",
"(",
")",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"TRUST_STORE_LOCATION",
")",
")",
"{",
"KeyStore",
"keyStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"KEYSTORE_TYPE",
")",
";",
"keyStore",
".",
"load",
"(",
"in",
",",
"KEY_STORE_PASSWORD",
".",
"toCharArray",
"(",
")",
")",
";",
"KeyStore",
"trustStore",
"=",
"KeyStore",
".",
"getInstance",
"(",
"KEYSTORE_TYPE",
")",
";",
"trustStore",
".",
"load",
"(",
"inTrust",
",",
"TRUST_STORE_PASSWORD",
".",
"toCharArray",
"(",
")",
")",
";",
"Certificate",
"[",
"]",
"trustedCertificates",
"=",
"new",
"Certificate",
"[",
"1",
"]",
";",
"trustedCertificates",
"[",
"0",
"]",
"=",
"trustStore",
".",
"getCertificate",
"(",
"\"",
"root",
"\"",
")",
";",
"DtlsConnectorConfig",
".",
"Builder",
"dTLSConfig",
"=",
"new",
"DtlsConnectorConfig",
".",
"Builder",
"(",
")",
";",
"JsonPskStore",
"store",
"=",
"new",
"JsonPskStore",
"(",
")",
";",
"config",
"=",
"dTLSConfig",
".",
"setAddress",
"(",
"bindToAddress",
")",
".",
"setIdentity",
"(",
"(",
"PrivateKey",
")",
"keyStore",
".",
"getKey",
"(",
"identity",
",",
"KEY_STORE_PASSWORD",
".",
"toCharArray",
"(",
")",
")",
",",
"keyStore",
".",
"getCertificateChain",
"(",
"identity",
")",
",",
"true",
")",
".",
"setClientAuthenticationRequired",
"(",
"true",
")",
".",
"setPskStore",
"(",
"store",
")",
".",
"setTrustStore",
"(",
"trustedCertificates",
")",
".",
"build",
"(",
")",
";",
"connector",
"=",
"new",
"DTLSConnector",
"(",
"config",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"",
"Something went wrong while initializing the key and trust store",
"\"",
",",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"return",
"connector",
";",
"}",
"return",
"dtlsConnector",
";",
"}",
"public",
"void",
"addPsk",
"(",
"final",
"String",
"identity",
",",
"final",
"String",
"key",
")",
"{",
"PskStore",
"store",
"=",
"this",
".",
"config",
".",
"getPskStore",
"(",
")",
";",
"if",
"(",
"store",
"instanceof",
"JsonPskStore",
")",
"{",
"(",
"(",
"JsonPskStore",
")",
"store",
")",
".",
"setKey",
"(",
"identity",
",",
"key",
")",
";",
"return",
";",
"}",
"logger",
".",
"error",
"(",
"\"",
"PSKStore does not support adding new keys after initialization.",
"\"",
")",
";",
"}",
"public",
"void",
"addKnownPeer",
"(",
"final",
"InetSocketAddress",
"peer",
",",
"final",
"String",
"identity",
",",
"final",
"String",
"key",
")",
"{",
"PskStore",
"store",
"=",
"this",
".",
"config",
".",
"getPskStore",
"(",
")",
";",
"if",
"(",
"store",
"instanceof",
"JsonPskStore",
")",
"{",
"(",
"(",
"JsonPskStore",
")",
"store",
")",
".",
"addKnownPeer",
"(",
"peer",
",",
"identity",
",",
"key",
")",
";",
"return",
";",
"}",
"logger",
".",
"error",
"(",
"\"",
"PSKStore does not support adding new keys after initialization.",
"\"",
")",
";",
"}",
"public",
"byte",
"[",
"]",
"getPsk",
"(",
"final",
"String",
"identity",
")",
"{",
"return",
"this",
".",
"config",
".",
"getPskStore",
"(",
")",
".",
"getKey",
"(",
"identity",
")",
";",
"}",
"void",
"deletePsk",
"(",
"final",
"String",
"identity",
")",
"{",
"PskStore",
"store",
"=",
"this",
".",
"config",
".",
"getPskStore",
"(",
")",
";",
"if",
"(",
"store",
"instanceof",
"JsonPskStore",
")",
"{",
"(",
"(",
"JsonPskStore",
")",
"store",
")",
".",
"deleteKey",
"(",
"identity",
")",
";",
"return",
";",
"}",
"logger",
".",
"error",
"(",
"\"",
"PSKStore does not support deleting keys after initialization.",
"\"",
")",
";",
"}",
"String",
"getInterfaces",
"(",
")",
"{",
"return",
"getEndpoints",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"Endpoint",
"::",
"getAddress",
")",
".",
"map",
"(",
"a",
"->",
"\"",
"[",
"\"",
"+",
"a",
".",
"getHostString",
"(",
")",
"+",
"\"",
":",
"\"",
"+",
"a",
".",
"getPort",
"(",
")",
"+",
"\"",
"]",
"\"",
")",
".",
"collect",
"(",
"Collectors",
".",
"joining",
"(",
"\"",
", ",
"\"",
")",
")",
";",
"}",
"}"
] | @author Norman Lipkow | [
"@author",
"Norman",
"Lipkow"
] | [] | [
{
"param": "CoapServer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "CoapServer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
075ff6a8606fb5bdc636a7228497440468d5b1a9 | suryanarayanakb/Gooru-Web | src/main/java/org/ednovo/gooru/application/client/gin/GoogleAnalyticsHpNavigationTracker.java | [
"MIT"
] | Java | GoogleAnalyticsHpNavigationTracker | /**
* This class let's you register every navigation event to a Google Analytics
* account. To use it, you must bind GoogleAnalytics as eager singleton in your
* gin module and also bind the annotation {@link GaAccount} to your Google
* Analytics account number:
* <p />
* <code>bind(GoogleAnalyticsImpl.class).to(GoogleAnalytics.class).asEagerSingleton();
* bindConstant().annotatedWith(GaAccount.class).to("UA-12345678-1");</code>
* <p />
* If you want to log custom events, see {@link GoogleAnalytics}.
*
* @author Christian Goudreau
*/ | This class let's you register every navigation event to a Google Analytics
account. To use it, you must bind GoogleAnalytics as eager singleton in your
gin module and also bind the annotation GaAccount to your Google
Analytics account number:
bind(GoogleAnalyticsImpl.class).to(GoogleAnalytics.class).asEagerSingleton();
bindConstant().annotatedWith(GaAccount.class).to("UA-12345678-1");
If you want to log custom events, see GoogleAnalytics.
@author Christian Goudreau | [
"This",
"class",
"let",
"'",
"s",
"you",
"register",
"every",
"navigation",
"event",
"to",
"a",
"Google",
"Analytics",
"account",
".",
"To",
"use",
"it",
"you",
"must",
"bind",
"GoogleAnalytics",
"as",
"eager",
"singleton",
"in",
"your",
"gin",
"module",
"and",
"also",
"bind",
"the",
"annotation",
"GaAccount",
"to",
"your",
"Google",
"Analytics",
"account",
"number",
":",
"bind",
"(",
"GoogleAnalyticsImpl",
".",
"class",
")",
".",
"to",
"(",
"GoogleAnalytics",
".",
"class",
")",
".",
"asEagerSingleton",
"()",
";",
"bindConstant",
"()",
".",
"annotatedWith",
"(",
"GaAccount",
".",
"class",
")",
".",
"to",
"(",
"\"",
"UA",
"-",
"12345678",
"-",
"1",
"\"",
")",
";",
"If",
"you",
"want",
"to",
"log",
"custom",
"events",
"see",
"GoogleAnalytics",
".",
"@author",
"Christian",
"Goudreau"
] | public class GoogleAnalyticsHpNavigationTracker implements NavigationHandler {
private final GoogleAnalytics analytics;
@Inject
public GoogleAnalyticsHpNavigationTracker(@GaAccount final String gaAccount,
final EventBus eventBus, final GoogleAnalytics analytics) {
this.analytics = analytics;
if (GWT.isScript()) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
analytics.init(gaAccount);
eventBus.addHandler(NavigationEvent.getType(), GoogleAnalyticsHpNavigationTracker.this);
}
});
}
}
@Override
public void onNavigation(NavigationEvent navigationEvent) {
analytics.trackPageview(navigationEvent.getRequest().getNameToken());
}
} | [
"public",
"class",
"GoogleAnalyticsHpNavigationTracker",
"implements",
"NavigationHandler",
"{",
"private",
"final",
"GoogleAnalytics",
"analytics",
";",
"@",
"Inject",
"public",
"GoogleAnalyticsHpNavigationTracker",
"(",
"@",
"GaAccount",
"final",
"String",
"gaAccount",
",",
"final",
"EventBus",
"eventBus",
",",
"final",
"GoogleAnalytics",
"analytics",
")",
"{",
"this",
".",
"analytics",
"=",
"analytics",
";",
"if",
"(",
"GWT",
".",
"isScript",
"(",
")",
")",
"{",
"Scheduler",
".",
"get",
"(",
")",
".",
"scheduleDeferred",
"(",
"new",
"ScheduledCommand",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"{",
"analytics",
".",
"init",
"(",
"gaAccount",
")",
";",
"eventBus",
".",
"addHandler",
"(",
"NavigationEvent",
".",
"getType",
"(",
")",
",",
"GoogleAnalyticsHpNavigationTracker",
".",
"this",
")",
";",
"}",
"}",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onNavigation",
"(",
"NavigationEvent",
"navigationEvent",
")",
"{",
"analytics",
".",
"trackPageview",
"(",
"navigationEvent",
".",
"getRequest",
"(",
")",
".",
"getNameToken",
"(",
")",
")",
";",
"}",
"}"
] | This class let's you register every navigation event to a Google Analytics
account. | [
"This",
"class",
"let",
"'",
"s",
"you",
"register",
"every",
"navigation",
"event",
"to",
"a",
"Google",
"Analytics",
"account",
"."
] | [] | [
{
"param": "NavigationHandler",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "NavigationHandler",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
076035e53d479429d952ac8b7c99152b307824e7 | senaceet/Ejemplos-Proyectos-ADSI | 03_Tercer Trimestre/RAE-16 220501007 02/ejemplo1/integracion/CuentaPK.java | [
"Apache-2.0"
] | Java | CuentaPK | /**
* Esta clase contiene las llaves primarias de la tabla CUENTA
* @author Dxracso
*/ | Esta clase contiene las llaves primarias de la tabla CUENTA
@author Dxracso | [
"Esta",
"clase",
"contiene",
"las",
"llaves",
"primarias",
"de",
"la",
"tabla",
"CUENTA",
"@author",
"Dxracso"
] | @Embeddable
public class CuentaPK implements Serializable {
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 12)
@Column(name = "NUMERO_DOCUMENTO")
private String numeroDocumento;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 12)
@Column(name = "TIPO_DOCUMENTO_TIPO_DOCUMENTO")
private String tipoDocumentoTipoDocumento;
public CuentaPK() {
/**
* Esto es un costructor generico
*/
}
/**
* Este constructor que inicializa las llaves primarias
* @param numeroDocumento objeto String numero de documento del usuario
* @param tipoDocumentoTipoDocumento objeto String tipo de documento
* que puede tener el usuario
*/
public CuentaPK(String numeroDocumento, String tipoDocumentoTipoDocumento) {
this.numeroDocumento = numeroDocumento;
this.tipoDocumentoTipoDocumento = tipoDocumentoTipoDocumento;
}
/**
* Obtiene numero de documento del usuario
* @return objeto String nombero de documento del usuario
*/
public String getNumeroDocumento() {
return numeroDocumento;
}
/**
* Permite añadir el numero de documento del usuario
* @param numeroDocumento objeto String numero de documento del usuario
*/
public void setNumeroDocumento(String numeroDocumento) {
this.numeroDocumento = numeroDocumento;
}
/**
* Obtiene el tipo de documento del usuario
* @return objeto String tipo de documento del usuario
*/
public String getTipoDocumentoTipoDocumento() {
return tipoDocumentoTipoDocumento;
}
/**
* Permite añadir el tipo de documento que puede tener el usuario
* @param tipoDocumentoTipoDocumento objeto String tipo de documento
* del usuario
*/
public void setTipoDocumentoTipoDocumento(String tipoDocumentoTipoDocumento) {
this.tipoDocumentoTipoDocumento = tipoDocumentoTipoDocumento;
}
/**
* Este metodo obtiene el id unico de memoria de la clase
* @return retorna dato primitivo entero
*/
@Override
public int hashCode() {
int hash = 0;
hash += (numeroDocumento != null ? numeroDocumento.hashCode() : 0);
hash += (tipoDocumentoTipoDocumento != null ? tipoDocumentoTipoDocumento.hashCode() : 0);
return hash;
}
/**
* Este metodo compara entre los cuentas
* @param object
* @return retorna dato primitivo boolean
*/
@Override
public boolean equals(Object object) {
if (!(object instanceof CuentaPK)) {
return false;
}
CuentaPK other = (CuentaPK) object;
if (!this.numeroDocumento.equals(other.numeroDocumento)) {
return false;
}
if (!this.tipoDocumentoTipoDocumento.equals(other.tipoDocumentoTipoDocumento)) {
return false;
}
return true;
}
/**
* Este metodo contiene los valores de las variables de los get y set
* @return
*/
@Override
public String toString() {
return "numeroDocumento=" + numeroDocumento + ", tipoDocumentoTipoDocumento=" + tipoDocumentoTipoDocumento;
}
} | [
"@",
"Embeddable",
"public",
"class",
"CuentaPK",
"implements",
"Serializable",
"{",
"@",
"Basic",
"(",
"optional",
"=",
"false",
")",
"@",
"NotNull",
"@",
"Size",
"(",
"min",
"=",
"1",
",",
"max",
"=",
"12",
")",
"@",
"Column",
"(",
"name",
"=",
"\"",
"NUMERO_DOCUMENTO",
"\"",
")",
"private",
"String",
"numeroDocumento",
";",
"@",
"Basic",
"(",
"optional",
"=",
"false",
")",
"@",
"NotNull",
"@",
"Size",
"(",
"min",
"=",
"1",
",",
"max",
"=",
"12",
")",
"@",
"Column",
"(",
"name",
"=",
"\"",
"TIPO_DOCUMENTO_TIPO_DOCUMENTO",
"\"",
")",
"private",
"String",
"tipoDocumentoTipoDocumento",
";",
"public",
"CuentaPK",
"(",
")",
"{",
"/**\n * Esto es un costructor generico\n */",
"}",
"/**\n * Este constructor que inicializa las llaves primarias\n * @param numeroDocumento objeto String numero de documento del usuario\n * @param tipoDocumentoTipoDocumento objeto String tipo de documento \n * que puede tener el usuario\n */",
"public",
"CuentaPK",
"(",
"String",
"numeroDocumento",
",",
"String",
"tipoDocumentoTipoDocumento",
")",
"{",
"this",
".",
"numeroDocumento",
"=",
"numeroDocumento",
";",
"this",
".",
"tipoDocumentoTipoDocumento",
"=",
"tipoDocumentoTipoDocumento",
";",
"}",
"/**\n * Obtiene numero de documento del usuario\n * @return objeto String nombero de documento del usuario\n */",
"public",
"String",
"getNumeroDocumento",
"(",
")",
"{",
"return",
"numeroDocumento",
";",
"}",
"/**\n * Permite añadir el numero de documento del usuario\n * @param numeroDocumento objeto String numero de documento del usuario\n */",
"public",
"void",
"setNumeroDocumento",
"(",
"String",
"numeroDocumento",
")",
"{",
"this",
".",
"numeroDocumento",
"=",
"numeroDocumento",
";",
"}",
"/**\n * Obtiene el tipo de documento del usuario\n * @return objeto String tipo de documento del usuario\n */",
"public",
"String",
"getTipoDocumentoTipoDocumento",
"(",
")",
"{",
"return",
"tipoDocumentoTipoDocumento",
";",
"}",
"/**\n * Permite añadir el tipo de documento que puede tener el usuario\n * @param tipoDocumentoTipoDocumento objeto String tipo de documento \n * del usuario \n */",
"public",
"void",
"setTipoDocumentoTipoDocumento",
"(",
"String",
"tipoDocumentoTipoDocumento",
")",
"{",
"this",
".",
"tipoDocumentoTipoDocumento",
"=",
"tipoDocumentoTipoDocumento",
";",
"}",
"/**\n * Este metodo obtiene el id unico de memoria de la clase\n * @return retorna dato primitivo entero\n */",
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"int",
"hash",
"=",
"0",
";",
"hash",
"+=",
"(",
"numeroDocumento",
"!=",
"null",
"?",
"numeroDocumento",
".",
"hashCode",
"(",
")",
":",
"0",
")",
";",
"hash",
"+=",
"(",
"tipoDocumentoTipoDocumento",
"!=",
"null",
"?",
"tipoDocumentoTipoDocumento",
".",
"hashCode",
"(",
")",
":",
"0",
")",
";",
"return",
"hash",
";",
"}",
"/**\n * Este metodo compara entre los cuentas \n * @param object \n * @return retorna dato primitivo boolean\n */",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"object",
"instanceof",
"CuentaPK",
")",
")",
"{",
"return",
"false",
";",
"}",
"CuentaPK",
"other",
"=",
"(",
"CuentaPK",
")",
"object",
";",
"if",
"(",
"!",
"this",
".",
"numeroDocumento",
".",
"equals",
"(",
"other",
".",
"numeroDocumento",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"this",
".",
"tipoDocumentoTipoDocumento",
".",
"equals",
"(",
"other",
".",
"tipoDocumentoTipoDocumento",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"/**\n * Este metodo contiene los valores de las variables de los get y set\n * @return \n */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"",
"numeroDocumento=",
"\"",
"+",
"numeroDocumento",
"+",
"\"",
", tipoDocumentoTipoDocumento=",
"\"",
"+",
"tipoDocumentoTipoDocumento",
";",
"}",
"}"
] | Esta clase contiene las llaves primarias de la tabla CUENTA
@author Dxracso | [
"Esta",
"clase",
"contiene",
"las",
"llaves",
"primarias",
"de",
"la",
"tabla",
"CUENTA",
"@author",
"Dxracso"
] | [] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0765d81a5fdee15f8978d9a7d4c7d5d15f3e619c | ncats/gsrs-play | app/ix/core/util/CloseableIterators.java | [
"Apache-2.0"
] | Java | CloseableIterators | /**
* Helper class that can create CloseableIterator
* objects.
*
* Created by katzelda on 4/21/16.
*/ | Helper class that can create CloseableIterator
objects.
Created by katzelda on 4/21/16. | [
"Helper",
"class",
"that",
"can",
"create",
"CloseableIterator",
"objects",
".",
"Created",
"by",
"katzelda",
"on",
"4",
"/",
"21",
"/",
"16",
"."
] | public final class CloseableIterators {
private CloseableIterators(){
//can not instantiate
}
/**
* Wrap an Iterator and make it CloseableIterator that delegates all calls to Iterator#next(), Iterator#hasNext()
* and Iterator#remove(). The returned object will usually be a new object, but will not always
* be depending on what type is passed in.
* <p>
* Rules for how to make the returned CloseableIterator instance:
* </p>
* <ol>
* <li>If the iterator is not closeable, then make a new CloseableIterator instance with an empty close()</li>
* <li>If the iterator IS closeable:
*
* <ol>If the iterator already implements CloseableIterator, do not make a new object and just return the passed in object</ol>
* <ol>Make a new CloseableIterator that will delegate to the wrapped object's close()</ol>
* </li>
* </ol>
* If the iterator to wrap
* is already also Closeable then it's close() will be correctly delegated to.
* @param iter the iterator to wrap; can not be null.
* @param <T> the type returned by Iterator calls to next().
* @param <I> generic mess that is used to make compiler happy casting if the passed in iterator already is closeable.
* @return a new CloseableIterator object if the passed in iter is not already a CloseableIterator; or
* iter if it is.
*
* @throws NullPointerException if iter is null.
*/
@SuppressWarnings("unchecked")
public static <T, I extends Iterator<T> & Closeable> CloseableIterator<T> wrap(Iterator<T> iter){
Objects.requireNonNull(iter);
if(iter instanceof Closeable){
//already closeableIterator just return it as is.
if(iter instanceof CloseableIterator){
return (CloseableIterator<T>) iter;
}
return new CloseableWrapper<>((I)iter);
}
return new Wrapper<>(iter);
}
private static final class Wrapper<T> implements CloseableIterator<T>{
private final Iterator<T> delegate;
public Wrapper(Iterator<T> iter){
this.delegate = iter;
}
@Override
public void close() throws IOException {
//no-op
}
@Override
public boolean hasNext() {
return delegate.hasNext();
}
@Override
public T next() {
return delegate.next();
}
@Override
public void remove() {
delegate.remove();
}
}
private static final class CloseableWrapper<T, I extends Iterator<T> & Closeable> implements CloseableIterator<T>{
private final I delegate;
public CloseableWrapper(I iter){
this.delegate = iter;
}
@Override
public void close() throws IOException {
delegate.close();
}
@Override
public boolean hasNext() {
return delegate.hasNext();
}
@Override
public T next() {
return delegate.next();
}
@Override
public void remove() {
delegate.remove();
}
}
} | [
"public",
"final",
"class",
"CloseableIterators",
"{",
"private",
"CloseableIterators",
"(",
")",
"{",
"}",
"/**\n * Wrap an Iterator and make it CloseableIterator that delegates all calls to Iterator#next(), Iterator#hasNext()\n * and Iterator#remove(). The returned object will usually be a new object, but will not always\n * be depending on what type is passed in.\n * <p>\n * Rules for how to make the returned CloseableIterator instance:\n * </p>\n * <ol>\n * <li>If the iterator is not closeable, then make a new CloseableIterator instance with an empty close()</li>\n * <li>If the iterator IS closeable:\n *\n * <ol>If the iterator already implements CloseableIterator, do not make a new object and just return the passed in object</ol>\n * <ol>Make a new CloseableIterator that will delegate to the wrapped object's close()</ol>\n * </li>\n * </ol>\n * If the iterator to wrap\n * is already also Closeable then it's close() will be correctly delegated to.\n * @param iter the iterator to wrap; can not be null.\n * @param <T> the type returned by Iterator calls to next().\n * @param <I> generic mess that is used to make compiler happy casting if the passed in iterator already is closeable.\n * @return a new CloseableIterator object if the passed in iter is not already a CloseableIterator; or\n * iter if it is.\n *\n * @throws NullPointerException if iter is null.\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"public",
"static",
"<",
"T",
",",
"I",
"extends",
"Iterator",
"<",
"T",
">",
"&",
"Closeable",
">",
"CloseableIterator",
"<",
"T",
">",
"wrap",
"(",
"Iterator",
"<",
"T",
">",
"iter",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"iter",
")",
";",
"if",
"(",
"iter",
"instanceof",
"Closeable",
")",
"{",
"if",
"(",
"iter",
"instanceof",
"CloseableIterator",
")",
"{",
"return",
"(",
"CloseableIterator",
"<",
"T",
">",
")",
"iter",
";",
"}",
"return",
"new",
"CloseableWrapper",
"<",
">",
"(",
"(",
"I",
")",
"iter",
")",
";",
"}",
"return",
"new",
"Wrapper",
"<",
">",
"(",
"iter",
")",
";",
"}",
"private",
"static",
"final",
"class",
"Wrapper",
"<",
"T",
">",
"implements",
"CloseableIterator",
"<",
"T",
">",
"{",
"private",
"final",
"Iterator",
"<",
"T",
">",
"delegate",
";",
"public",
"Wrapper",
"(",
"Iterator",
"<",
"T",
">",
"iter",
")",
"{",
"this",
".",
"delegate",
"=",
"iter",
";",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"}",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"delegate",
".",
"hasNext",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"T",
"next",
"(",
")",
"{",
"return",
"delegate",
".",
"next",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"remove",
"(",
")",
"{",
"delegate",
".",
"remove",
"(",
")",
";",
"}",
"}",
"private",
"static",
"final",
"class",
"CloseableWrapper",
"<",
"T",
",",
"I",
"extends",
"Iterator",
"<",
"T",
">",
"&",
"Closeable",
">",
"implements",
"CloseableIterator",
"<",
"T",
">",
"{",
"private",
"final",
"I",
"delegate",
";",
"public",
"CloseableWrapper",
"(",
"I",
"iter",
")",
"{",
"this",
".",
"delegate",
"=",
"iter",
";",
"}",
"@",
"Override",
"public",
"void",
"close",
"(",
")",
"throws",
"IOException",
"{",
"delegate",
".",
"close",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"hasNext",
"(",
")",
"{",
"return",
"delegate",
".",
"hasNext",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"T",
"next",
"(",
")",
"{",
"return",
"delegate",
".",
"next",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"remove",
"(",
")",
"{",
"delegate",
".",
"remove",
"(",
")",
";",
"}",
"}",
"}"
] | Helper class that can create CloseableIterator
objects. | [
"Helper",
"class",
"that",
"can",
"create",
"CloseableIterator",
"objects",
"."
] | [
"//can not instantiate",
"//already closeableIterator just return it as is.",
"//no-op"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0766d5c6f317bd0aa4de955be3439633fb2121c6 | uit-plus/vspehere-jdk | src/main/java/com/vmware/vim25/OvfUnsupportedAttribute.java | [
"Apache-2.0"
] | Java | OvfUnsupportedAttribute | /**
* <p>Java class for OvfUnsupportedAttribute complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="OvfUnsupportedAttribute">
* <complexContent>
* <extension base="{urn:vim25}OvfUnsupportedPackage">
* <sequence>
* <element name="elementName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* <element name="attributeName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* </sequence>
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
*/ | Java class for OvfUnsupportedAttribute complex type.
The following schema fragment specifies the expected content contained within this class.
| [
"Java",
"class",
"for",
"OvfUnsupportedAttribute",
"complex",
"type",
".",
"The",
"following",
"schema",
"fragment",
"specifies",
"the",
"expected",
"content",
"contained",
"within",
"this",
"class",
"."
] | @XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "OvfUnsupportedAttribute", propOrder = {
"elementName",
"attributeName"
})
@XmlSeeAlso({
OvfUnsupportedAttributeValue.class
})
public class OvfUnsupportedAttribute
extends OvfUnsupportedPackage
{
@XmlElement(required = true)
protected String elementName;
@XmlElement(required = true)
protected String attributeName;
/**
* Gets the value of the elementName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getElementName() {
return elementName;
}
/**
* Sets the value of the elementName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setElementName(String value) {
this.elementName = value;
}
/**
* Gets the value of the attributeName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAttributeName() {
return attributeName;
}
/**
* Sets the value of the attributeName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAttributeName(String value) {
this.attributeName = value;
}
} | [
"@",
"XmlAccessorType",
"(",
"XmlAccessType",
".",
"FIELD",
")",
"@",
"XmlType",
"(",
"name",
"=",
"\"",
"OvfUnsupportedAttribute",
"\"",
",",
"propOrder",
"=",
"{",
"\"",
"elementName",
"\"",
",",
"\"",
"attributeName",
"\"",
"}",
")",
"@",
"XmlSeeAlso",
"(",
"{",
"OvfUnsupportedAttributeValue",
".",
"class",
"}",
")",
"public",
"class",
"OvfUnsupportedAttribute",
"extends",
"OvfUnsupportedPackage",
"{",
"@",
"XmlElement",
"(",
"required",
"=",
"true",
")",
"protected",
"String",
"elementName",
";",
"@",
"XmlElement",
"(",
"required",
"=",
"true",
")",
"protected",
"String",
"attributeName",
";",
"/**\n * Gets the value of the elementName property.\n * \n * @return\n * possible object is\n * {@link String }\n * \n */",
"public",
"String",
"getElementName",
"(",
")",
"{",
"return",
"elementName",
";",
"}",
"/**\n * Sets the value of the elementName property.\n * \n * @param value\n * allowed object is\n * {@link String }\n * \n */",
"public",
"void",
"setElementName",
"(",
"String",
"value",
")",
"{",
"this",
".",
"elementName",
"=",
"value",
";",
"}",
"/**\n * Gets the value of the attributeName property.\n * \n * @return\n * possible object is\n * {@link String }\n * \n */",
"public",
"String",
"getAttributeName",
"(",
")",
"{",
"return",
"attributeName",
";",
"}",
"/**\n * Sets the value of the attributeName property.\n * \n * @param value\n * allowed object is\n * {@link String }\n * \n */",
"public",
"void",
"setAttributeName",
"(",
"String",
"value",
")",
"{",
"this",
".",
"attributeName",
"=",
"value",
";",
"}",
"}"
] | <p>Java class for OvfUnsupportedAttribute complex type. | [
"<p",
">",
"Java",
"class",
"for",
"OvfUnsupportedAttribute",
"complex",
"type",
"."
] | [] | [
{
"param": "OvfUnsupportedPackage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "OvfUnsupportedPackage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0768a1528b5d8b0c510d4dedeec43097f2214c61 | hwellmann/org.ops4j.ramler | ramler-maven-plugin/src/main/java/org/ops4j/ramler/maven/AbstractRamlerMojo.java | [
"Apache-2.0"
] | Java | AbstractRamlerMojo | /**
* Base class for Ramler Mojos, taking care of incremental builds with m2e.
*
* @author Harald Wellmann
*
*/ | Base class for Ramler Mojos, taking care of incremental builds with m2e.
@author Harald Wellmann | [
"Base",
"class",
"for",
"Ramler",
"Mojos",
"taking",
"care",
"of",
"incremental",
"builds",
"with",
"m2e",
".",
"@author",
"Harald",
"Wellmann"
] | public abstract class AbstractRamlerMojo extends AbstractMojo {
/** RAML specification file, relative to <code>${project.basedir}</code>. */
@Parameter(required = true)
protected String model;
@Parameter(readonly = true, defaultValue = "${project}")
protected MavenProject project;
@Inject
private BuildContext buildContext;
@Override
public void execute() throws MojoFailureException {
validateModelPath();
extendProject();
if (buildContext.hasDelta(model)) {
generateOutput();
refreshOutput();
}
else {
getLog().info("Skipping execution, RAML model is unchanged");
}
}
private void validateModelPath() throws MojoFailureException {
if (new File(model).isAbsolute()) {
throw new MojoFailureException(
"<model> must be a relative path with respect to ${project.basedir}");
}
}
private void refreshOutput() {
getLog().debug("refreshing " + getOutputDir());
buildContext.refresh(getOutputDir());
}
/**
* Generates output from the given RAML model.
*
* @throws MojoFailureException
* on misconfiguration
*/
protected abstract void generateOutput() throws MojoFailureException;
/**
* Gets the output directories for generated files. The directory and its parent directories
* will be created, if necessary.
*
* @return output directory
*/
protected abstract File getOutputDir();
/**
* Override to add (test) source directories.
*/
protected void extendProject() {
// empty
}
} | [
"public",
"abstract",
"class",
"AbstractRamlerMojo",
"extends",
"AbstractMojo",
"{",
"/** RAML specification file, relative to <code>${project.basedir}</code>. */",
"@",
"Parameter",
"(",
"required",
"=",
"true",
")",
"protected",
"String",
"model",
";",
"@",
"Parameter",
"(",
"readonly",
"=",
"true",
",",
"defaultValue",
"=",
"\"",
"${project}",
"\"",
")",
"protected",
"MavenProject",
"project",
";",
"@",
"Inject",
"private",
"BuildContext",
"buildContext",
";",
"@",
"Override",
"public",
"void",
"execute",
"(",
")",
"throws",
"MojoFailureException",
"{",
"validateModelPath",
"(",
")",
";",
"extendProject",
"(",
")",
";",
"if",
"(",
"buildContext",
".",
"hasDelta",
"(",
"model",
")",
")",
"{",
"generateOutput",
"(",
")",
";",
"refreshOutput",
"(",
")",
";",
"}",
"else",
"{",
"getLog",
"(",
")",
".",
"info",
"(",
"\"",
"Skipping execution, RAML model is unchanged",
"\"",
")",
";",
"}",
"}",
"private",
"void",
"validateModelPath",
"(",
")",
"throws",
"MojoFailureException",
"{",
"if",
"(",
"new",
"File",
"(",
"model",
")",
".",
"isAbsolute",
"(",
")",
")",
"{",
"throw",
"new",
"MojoFailureException",
"(",
"\"",
"<model> must be a relative path with respect to ${project.basedir}",
"\"",
")",
";",
"}",
"}",
"private",
"void",
"refreshOutput",
"(",
")",
"{",
"getLog",
"(",
")",
".",
"debug",
"(",
"\"",
"refreshing ",
"\"",
"+",
"getOutputDir",
"(",
")",
")",
";",
"buildContext",
".",
"refresh",
"(",
"getOutputDir",
"(",
")",
")",
";",
"}",
"/**\n * Generates output from the given RAML model.\n *\n * @throws MojoFailureException\n * on misconfiguration\n */",
"protected",
"abstract",
"void",
"generateOutput",
"(",
")",
"throws",
"MojoFailureException",
";",
"/**\n * Gets the output directories for generated files. The directory and its parent directories\n * will be created, if necessary.\n *\n * @return output directory\n */",
"protected",
"abstract",
"File",
"getOutputDir",
"(",
")",
";",
"/**\n * Override to add (test) source directories.\n */",
"protected",
"void",
"extendProject",
"(",
")",
"{",
"}",
"}"
] | Base class for Ramler Mojos, taking care of incremental builds with m2e. | [
"Base",
"class",
"for",
"Ramler",
"Mojos",
"taking",
"care",
"of",
"incremental",
"builds",
"with",
"m2e",
"."
] | [
"// empty"
] | [
{
"param": "AbstractMojo",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "AbstractMojo",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
076b4c8648789e22eb00d63cac2e8ff59e27043e | FihlaTV/openvidu | openvidu-server/src/main/java/io/openvidu/server/resources/FrontendResourceHandler.java | [
"Apache-2.0"
] | Java | FrontendResourceHandler | /**
* This class changes the path where static files are served from / to
* /NEW_FRONTEND_PATH. Entrypoint file index.html must have tag
* <base href="/NEW_FRONTEND_PATH/">
*
* By default in OpenVidu CE this path is /dashbaord and in OpenVidu PRO is
* /inspector
*
* @author Pablo Fuente ([email protected])
*/ | This class changes the path where static files are served from / to
/NEW_FRONTEND_PATH. Entrypoint file index.html must have tag
By default in OpenVidu CE this path is /dashbaord and in OpenVidu PRO is
/inspector
| [
"This",
"class",
"changes",
"the",
"path",
"where",
"static",
"files",
"are",
"served",
"from",
"/",
"to",
"/",
"NEW_FRONTEND_PATH",
".",
"Entrypoint",
"file",
"index",
".",
"html",
"must",
"have",
"tag",
"By",
"default",
"in",
"OpenVidu",
"CE",
"this",
"path",
"is",
"/",
"dashbaord",
"and",
"in",
"OpenVidu",
"PRO",
"is",
"/",
"inspector"
] | @Configuration
public class FrontendResourceHandler extends WebMvcConfigurerAdapter {
@Autowired
OpenviduConfig openviduConfig;
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/" + openviduConfig.getOpenViduFrontendDefaultPath())
.setViewName("redirect:/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/");
registry.addViewController("/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/")
.setViewName("forward:/" + openviduConfig.getOpenViduFrontendDefaultPath() + "/index.html");
super.addViewControllers(registry);
}
} | [
"@",
"Configuration",
"public",
"class",
"FrontendResourceHandler",
"extends",
"WebMvcConfigurerAdapter",
"{",
"@",
"Autowired",
"OpenviduConfig",
"openviduConfig",
";",
"@",
"Override",
"public",
"void",
"addViewControllers",
"(",
"ViewControllerRegistry",
"registry",
")",
"{",
"registry",
".",
"addViewController",
"(",
"\"",
"/",
"\"",
"+",
"openviduConfig",
".",
"getOpenViduFrontendDefaultPath",
"(",
")",
")",
".",
"setViewName",
"(",
"\"",
"redirect:/",
"\"",
"+",
"openviduConfig",
".",
"getOpenViduFrontendDefaultPath",
"(",
")",
"+",
"\"",
"/",
"\"",
")",
";",
"registry",
".",
"addViewController",
"(",
"\"",
"/",
"\"",
"+",
"openviduConfig",
".",
"getOpenViduFrontendDefaultPath",
"(",
")",
"+",
"\"",
"/",
"\"",
")",
".",
"setViewName",
"(",
"\"",
"forward:/",
"\"",
"+",
"openviduConfig",
".",
"getOpenViduFrontendDefaultPath",
"(",
")",
"+",
"\"",
"/index.html",
"\"",
")",
";",
"super",
".",
"addViewControllers",
"(",
"registry",
")",
";",
"}",
"}"
] | This class changes the path where static files are served from / to
/NEW_FRONTEND_PATH. | [
"This",
"class",
"changes",
"the",
"path",
"where",
"static",
"files",
"are",
"served",
"from",
"/",
"to",
"/",
"NEW_FRONTEND_PATH",
"."
] | [] | [
{
"param": "WebMvcConfigurerAdapter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "WebMvcConfigurerAdapter",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
076f2ae3c41d58c0281535936adc27b8595ebc3b | SolangeUG/hacker-rank | src/main/java/org/training/java/algorithms/medium/ClimbingTheLeaderboard.java | [
"MIT"
] | Java | ClimbingTheLeaderboard | /**
* Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking.
* The game uses Dense Ranking, so its leaderboard works like this:
* - The player with the highest score is ranked number on the leaderboard.
* - Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately
* following ranking number.
* For example, the four players on the leaderboard have high scores of 100, 90, 90, and 80.
* Those players will have ranks 1, 2, 2, and 3, respectively. If Alice's scores are 70, 80 and 105, her rankings
* after each game are 4th, 3rd and 1st.
*
* @author Solange U. Gasengayire
*/ | Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking.
The game uses Dense Ranking, so its leaderboard works like this:
- The player with the highest score is ranked number on the leaderboard.
- Players who have equal scores receive the same ranking number, and the next player(s) receive the immediately
following ranking number.
For example, the four players on the leaderboard have high scores of 100, 90, 90, and 80.
Those players will have ranks 1, 2, 2, and 3, respectively. If Alice's scores are 70, 80 and 105, her rankings
after each game are 4th, 3rd and 1st.
@author Solange U. Gasengayire | [
"Alice",
"is",
"playing",
"an",
"arcade",
"game",
"and",
"wants",
"to",
"climb",
"to",
"the",
"top",
"of",
"the",
"leaderboard",
"and",
"wants",
"to",
"track",
"her",
"ranking",
".",
"The",
"game",
"uses",
"Dense",
"Ranking",
"so",
"its",
"leaderboard",
"works",
"like",
"this",
":",
"-",
"The",
"player",
"with",
"the",
"highest",
"score",
"is",
"ranked",
"number",
"on",
"the",
"leaderboard",
".",
"-",
"Players",
"who",
"have",
"equal",
"scores",
"receive",
"the",
"same",
"ranking",
"number",
"and",
"the",
"next",
"player",
"(",
"s",
")",
"receive",
"the",
"immediately",
"following",
"ranking",
"number",
".",
"For",
"example",
"the",
"four",
"players",
"on",
"the",
"leaderboard",
"have",
"high",
"scores",
"of",
"100",
"90",
"90",
"and",
"80",
".",
"Those",
"players",
"will",
"have",
"ranks",
"1",
"2",
"2",
"and",
"3",
"respectively",
".",
"If",
"Alice",
"'",
"s",
"scores",
"are",
"70",
"80",
"and",
"105",
"her",
"rankings",
"after",
"each",
"game",
"are",
"4th",
"3rd",
"and",
"1st",
".",
"@author",
"Solange",
"U",
".",
"Gasengayire"
] | public class ClimbingTheLeaderboard {
private static Scanner scanner;
static {
try {
scanner = new Scanner(new File("data/leaderboard_input.txt"));
} catch (FileNotFoundException e) {
scanner = new Scanner(System.in);
e.printStackTrace();
}
}
/**
* Check whether input array values are within 0 <= i <= Math.pow(10, 7)
* @param scores an array of integers that represent leaderboard scores
* @param alice an array of integers that represent Alice's scores
* @return true if input values are valid, false otherwise.
*/
private static boolean validateInput(int[] scores, int[] alice) {
if (scores.length == 0 || alice.length == 0) {
return false;
}
int minValue = 0;
int maxValue = (int) Math.pow(10, 9);
int scoresSize = scores.length;
if (scores[0] > maxValue || scores[scoresSize - 1] < minValue) {
return false;
}
int[] aliceCopy = Arrays.copyOf(alice, alice.length);
Arrays.sort(aliceCopy);
int aliceSize = aliceCopy.length;
return aliceCopy[0] >= minValue && aliceCopy[aliceSize - 1] <= maxValue;
}
/**
* Return an integer array where each element res[j] represents Alice's rank after the jth game
* @param scores an array of integers that represent leaderboard scores
* @param alice an array of integers that represent Alice's scores
* @return an array of integers that represent Alice's ranks
*/
static int[] climbingLeaderboard(int[] scores, int[] alice) {
int[] result = new int[]{};
if (validateInput(scores, alice)) {
int size = alice.length;
result = new int[size];
int[] uniqueScores = of(scores).distinct().toArray();
int maxNdx = uniqueScores.length - 1;
for (int j = 0; j < size; j++) {
int score = alice[j];
while (maxNdx >= 0) {
if (score >= uniqueScores[maxNdx]) {
// alice's score is higher than scores encounted so far
maxNdx--;
} else {
// alice's score is lower or equal to current score
// so, we mark this position
result[j] = maxNdx + 2;
break;
}
}
if (maxNdx < 0) {
// alice's score is higher than all the other scores
result[j] = 1;
}
}
}
return result;
}
/**
* Entry point
* @param args program arguments
* @throws IOException exception thrown in case of input or output errors
*/
public static void main(String[] args) throws IOException {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
int scoresCount = scanner.nextInt();
String skipRegEx = "(\r\n|[\n\r\u2028\u2029\u0085])?";
scanner.skip(skipRegEx);
int[] scores = new int[scoresCount];
String[] scoresItems = scanner.nextLine().split(" ");
scanner.skip(skipRegEx);
for (int i = 0; i < scoresCount; i++) {
int scoresItem = Integer.parseInt(scoresItems[i]);
scores[i] = scoresItem;
}
int aliceCount = scanner.nextInt();
scanner.skip(skipRegEx);
int[] alice = new int[aliceCount];
String[] aliceItems = scanner.nextLine().split(" ");
scanner.skip(skipRegEx);
for (int i = 0; i < aliceCount; i++) {
int aliceItem = Integer.parseInt(aliceItems[i]);
alice[i] = aliceItem;
}
int[] result = climbingLeaderboard(scores, alice);
for (int i = 0; i < result.length; i++) {
bufferedWriter.write(String.valueOf(result[i]));
if (i != result.length - 1) {
bufferedWriter.write("\n");
}
}
bufferedWriter.newLine();
bufferedWriter.close();
scanner.close();
}
} | [
"public",
"class",
"ClimbingTheLeaderboard",
"{",
"private",
"static",
"Scanner",
"scanner",
";",
"static",
"{",
"try",
"{",
"scanner",
"=",
"new",
"Scanner",
"(",
"new",
"File",
"(",
"\"",
"data/leaderboard_input.txt",
"\"",
")",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"scanner",
"=",
"new",
"Scanner",
"(",
"System",
".",
"in",
")",
";",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"/**\n * Check whether input array values are within 0 <= i <= Math.pow(10, 7)\n * @param scores an array of integers that represent leaderboard scores\n * @param alice an array of integers that represent Alice's scores\n * @return true if input values are valid, false otherwise.\n */",
"private",
"static",
"boolean",
"validateInput",
"(",
"int",
"[",
"]",
"scores",
",",
"int",
"[",
"]",
"alice",
")",
"{",
"if",
"(",
"scores",
".",
"length",
"==",
"0",
"||",
"alice",
".",
"length",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"int",
"minValue",
"=",
"0",
";",
"int",
"maxValue",
"=",
"(",
"int",
")",
"Math",
".",
"pow",
"(",
"10",
",",
"9",
")",
";",
"int",
"scoresSize",
"=",
"scores",
".",
"length",
";",
"if",
"(",
"scores",
"[",
"0",
"]",
">",
"maxValue",
"||",
"scores",
"[",
"scoresSize",
"-",
"1",
"]",
"<",
"minValue",
")",
"{",
"return",
"false",
";",
"}",
"int",
"[",
"]",
"aliceCopy",
"=",
"Arrays",
".",
"copyOf",
"(",
"alice",
",",
"alice",
".",
"length",
")",
";",
"Arrays",
".",
"sort",
"(",
"aliceCopy",
")",
";",
"int",
"aliceSize",
"=",
"aliceCopy",
".",
"length",
";",
"return",
"aliceCopy",
"[",
"0",
"]",
">=",
"minValue",
"&&",
"aliceCopy",
"[",
"aliceSize",
"-",
"1",
"]",
"<=",
"maxValue",
";",
"}",
"/**\n * Return an integer array where each element res[j] represents Alice's rank after the jth game\n * @param scores an array of integers that represent leaderboard scores\n * @param alice an array of integers that represent Alice's scores\n * @return an array of integers that represent Alice's ranks\n */",
"static",
"int",
"[",
"]",
"climbingLeaderboard",
"(",
"int",
"[",
"]",
"scores",
",",
"int",
"[",
"]",
"alice",
")",
"{",
"int",
"[",
"]",
"result",
"=",
"new",
"int",
"[",
"]",
"{",
"}",
";",
"if",
"(",
"validateInput",
"(",
"scores",
",",
"alice",
")",
")",
"{",
"int",
"size",
"=",
"alice",
".",
"length",
";",
"result",
"=",
"new",
"int",
"[",
"size",
"]",
";",
"int",
"[",
"]",
"uniqueScores",
"=",
"of",
"(",
"scores",
")",
".",
"distinct",
"(",
")",
".",
"toArray",
"(",
")",
";",
"int",
"maxNdx",
"=",
"uniqueScores",
".",
"length",
"-",
"1",
";",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"size",
";",
"j",
"++",
")",
"{",
"int",
"score",
"=",
"alice",
"[",
"j",
"]",
";",
"while",
"(",
"maxNdx",
">=",
"0",
")",
"{",
"if",
"(",
"score",
">=",
"uniqueScores",
"[",
"maxNdx",
"]",
")",
"{",
"maxNdx",
"--",
";",
"}",
"else",
"{",
"result",
"[",
"j",
"]",
"=",
"maxNdx",
"+",
"2",
";",
"break",
";",
"}",
"}",
"if",
"(",
"maxNdx",
"<",
"0",
")",
"{",
"result",
"[",
"j",
"]",
"=",
"1",
";",
"}",
"}",
"}",
"return",
"result",
";",
"}",
"/**\n * Entry point\n * @param args program arguments\n * @throws IOException exception thrown in case of input or output errors\n */",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"IOException",
"{",
"BufferedWriter",
"bufferedWriter",
"=",
"new",
"BufferedWriter",
"(",
"new",
"FileWriter",
"(",
"System",
".",
"getenv",
"(",
"\"",
"OUTPUT_PATH",
"\"",
")",
")",
")",
";",
"int",
"scoresCount",
"=",
"scanner",
".",
"nextInt",
"(",
")",
";",
"String",
"skipRegEx",
"=",
"\"",
"(",
"\\r",
"\\n",
"|[",
"\\n",
"\\r",
"\\u2028",
"\\u2029",
"\\u0085",
"])?",
"\"",
";",
"scanner",
".",
"skip",
"(",
"skipRegEx",
")",
";",
"int",
"[",
"]",
"scores",
"=",
"new",
"int",
"[",
"scoresCount",
"]",
";",
"String",
"[",
"]",
"scoresItems",
"=",
"scanner",
".",
"nextLine",
"(",
")",
".",
"split",
"(",
"\"",
" ",
"\"",
")",
";",
"scanner",
".",
"skip",
"(",
"skipRegEx",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"scoresCount",
";",
"i",
"++",
")",
"{",
"int",
"scoresItem",
"=",
"Integer",
".",
"parseInt",
"(",
"scoresItems",
"[",
"i",
"]",
")",
";",
"scores",
"[",
"i",
"]",
"=",
"scoresItem",
";",
"}",
"int",
"aliceCount",
"=",
"scanner",
".",
"nextInt",
"(",
")",
";",
"scanner",
".",
"skip",
"(",
"skipRegEx",
")",
";",
"int",
"[",
"]",
"alice",
"=",
"new",
"int",
"[",
"aliceCount",
"]",
";",
"String",
"[",
"]",
"aliceItems",
"=",
"scanner",
".",
"nextLine",
"(",
")",
".",
"split",
"(",
"\"",
" ",
"\"",
")",
";",
"scanner",
".",
"skip",
"(",
"skipRegEx",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"aliceCount",
";",
"i",
"++",
")",
"{",
"int",
"aliceItem",
"=",
"Integer",
".",
"parseInt",
"(",
"aliceItems",
"[",
"i",
"]",
")",
";",
"alice",
"[",
"i",
"]",
"=",
"aliceItem",
";",
"}",
"int",
"[",
"]",
"result",
"=",
"climbingLeaderboard",
"(",
"scores",
",",
"alice",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"result",
".",
"length",
";",
"i",
"++",
")",
"{",
"bufferedWriter",
".",
"write",
"(",
"String",
".",
"valueOf",
"(",
"result",
"[",
"i",
"]",
")",
")",
";",
"if",
"(",
"i",
"!=",
"result",
".",
"length",
"-",
"1",
")",
"{",
"bufferedWriter",
".",
"write",
"(",
"\"",
"\\n",
"\"",
")",
";",
"}",
"}",
"bufferedWriter",
".",
"newLine",
"(",
")",
";",
"bufferedWriter",
".",
"close",
"(",
")",
";",
"scanner",
".",
"close",
"(",
")",
";",
"}",
"}"
] | Alice is playing an arcade game and wants to climb to the top of the leaderboard and wants to track her ranking. | [
"Alice",
"is",
"playing",
"an",
"arcade",
"game",
"and",
"wants",
"to",
"climb",
"to",
"the",
"top",
"of",
"the",
"leaderboard",
"and",
"wants",
"to",
"track",
"her",
"ranking",
"."
] | [
"// alice's score is higher than scores encounted so far",
"// alice's score is lower or equal to current score",
"// so, we mark this position",
"// alice's score is higher than all the other scores"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0771c39454a4721af698cb107b098c3818e42400 | hzut/gerrittb | java/com/google/gerrit/testing/GerritJUnit.java | [
"Apache-2.0"
] | Java | GerritJUnit | /** Static JUnit utility methods. */ | Static JUnit utility methods. | [
"Static",
"JUnit",
"utility",
"methods",
"."
] | public class GerritJUnit {
/**
* Assert that an exception is thrown by a block of code.
*
* <p>This method is source-compatible with <a
* href="https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThrows(java.lang.Class,%20org.junit.function.ThrowingRunnable)">JUnit
* 4.13 beta</a>.
*
* <p>This construction is recommended by the Truth team for use in conjunction with asserting
* over a {@code ThrowableSubject} on the return type:
*
* <pre>
* MyException e = assertThrows(MyException.class, () -> doSomething(foo));
* assertThat(e).isInstanceOf(MySubException.class);
* assertThat(e).hasMessageThat().contains("sub-exception occurred");
* </pre>
*
* @param throwableClass expected exception type.
* @param runnable runnable containing arbitrary code.
* @return exception that was thrown.
*/
public static <T extends Throwable> T assertThrows(
Class<T> throwableClass, ThrowingRunnable runnable) {
try {
runnable.run();
} catch (Throwable t) {
if (!throwableClass.isInstance(t)) {
throw new AssertionError(
"expected "
+ throwableClass.getName()
+ " but "
+ t.getClass().getName()
+ " was thrown",
t);
}
@SuppressWarnings("unchecked")
T toReturn = (T) t;
return toReturn;
}
throw new AssertionError(
"expected " + throwableClass.getName() + " but no exception was thrown");
}
@FunctionalInterface
public interface ThrowingRunnable {
void run() throws Throwable;
}
private GerritJUnit() {}
} | [
"public",
"class",
"GerritJUnit",
"{",
"/**\n * Assert that an exception is thrown by a block of code.\n *\n * <p>This method is source-compatible with <a\n * href=\"https://junit.org/junit4/javadoc/latest/org/junit/Assert.html#assertThrows(java.lang.Class,%20org.junit.function.ThrowingRunnable)\">JUnit\n * 4.13 beta</a>.\n *\n * <p>This construction is recommended by the Truth team for use in conjunction with asserting\n * over a {@code ThrowableSubject} on the return type:\n *\n * <pre>\n * MyException e = assertThrows(MyException.class, () -> doSomething(foo));\n * assertThat(e).isInstanceOf(MySubException.class);\n * assertThat(e).hasMessageThat().contains(\"sub-exception occurred\");\n * </pre>\n *\n * @param throwableClass expected exception type.\n * @param runnable runnable containing arbitrary code.\n * @return exception that was thrown.\n */",
"public",
"static",
"<",
"T",
"extends",
"Throwable",
">",
"T",
"assertThrows",
"(",
"Class",
"<",
"T",
">",
"throwableClass",
",",
"ThrowingRunnable",
"runnable",
")",
"{",
"try",
"{",
"runnable",
".",
"run",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"if",
"(",
"!",
"throwableClass",
".",
"isInstance",
"(",
"t",
")",
")",
"{",
"throw",
"new",
"AssertionError",
"(",
"\"",
"expected ",
"\"",
"+",
"throwableClass",
".",
"getName",
"(",
")",
"+",
"\"",
" but ",
"\"",
"+",
"t",
".",
"getClass",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"",
" was thrown",
"\"",
",",
"t",
")",
";",
"}",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"T",
"toReturn",
"=",
"(",
"T",
")",
"t",
";",
"return",
"toReturn",
";",
"}",
"throw",
"new",
"AssertionError",
"(",
"\"",
"expected ",
"\"",
"+",
"throwableClass",
".",
"getName",
"(",
")",
"+",
"\"",
" but no exception was thrown",
"\"",
")",
";",
"}",
"@",
"FunctionalInterface",
"public",
"interface",
"ThrowingRunnable",
"{",
"void",
"run",
"(",
")",
"throws",
"Throwable",
";",
"}",
"private",
"GerritJUnit",
"(",
")",
"{",
"}",
"}"
] | Static JUnit utility methods. | [
"Static",
"JUnit",
"utility",
"methods",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
07726532833d2fd3fa116374187417935fd6a640 | yangfancoming/guava-parent | guava-tests/test/com/google/common/util/concurrent/CallablesTest.java | [
"Apache-2.0"
] | Java | CallablesTest | /**
* Unit tests for {@link Callables}.
*
* @author Isaac Shum
*/ | Unit tests for Callables.
@author Isaac Shum | [
"Unit",
"tests",
"for",
"Callables",
".",
"@author",
"Isaac",
"Shum"
] | @GwtCompatible(emulated = true)
public class CallablesTest extends TestCase {
public void testReturning() throws Exception {
assertNull(Callables.returning(null).call());
Object value = new Object();
Callable<Object> callable = Callables.returning(value);
assertSame(value, callable.call());
// Expect the same value on subsequent calls
assertSame(value, callable.call());
}
@GwtIncompatible
public void testAsAsyncCallable() throws Exception {
final String expected = "MyCallableString";
Callable<String> callable =
new Callable<String>() {
@Override
public String call() throws Exception {
return expected;
}
};
AsyncCallable<String> asyncCallable =
Callables.asAsyncCallable(callable, MoreExecutors.newDirectExecutorService());
ListenableFuture<String> future = asyncCallable.call();
assertSame(expected, future.get());
}
@GwtIncompatible
public void testAsAsyncCallable_exception() throws Exception {
final Exception expected = new IllegalArgumentException();
Callable<String> callable =
new Callable<String>() {
@Override
public String call() throws Exception {
throw expected;
}
};
AsyncCallable<String> asyncCallable =
Callables.asAsyncCallable(callable, MoreExecutors.newDirectExecutorService());
ListenableFuture<String> future = asyncCallable.call();
try {
future.get();
fail("Expected exception to be thrown");
} catch (ExecutionException e) {
assertThat(e).hasCauseThat().isSameAs(expected);
}
}
@GwtIncompatible // threads
public void testRenaming() throws Exception {
String oldName = Thread.currentThread().getName();
final Supplier<String> newName = Suppliers.ofInstance("MyCrazyThreadName");
Callable<Void> callable =
new Callable<Void>() {
@Override
public Void call() throws Exception {
assertEquals(Thread.currentThread().getName(), newName.get());
return null;
}
};
Callables.threadRenaming(callable, newName).call();
assertEquals(oldName, Thread.currentThread().getName());
}
@GwtIncompatible // threads
public void testRenaming_exceptionalReturn() throws Exception {
String oldName = Thread.currentThread().getName();
final Supplier<String> newName = Suppliers.ofInstance("MyCrazyThreadName");
class MyException extends Exception {}
Callable<Void> callable =
new Callable<Void>() {
@Override
public Void call() throws Exception {
assertEquals(Thread.currentThread().getName(), newName.get());
throw new MyException();
}
};
try {
Callables.threadRenaming(callable, newName).call();
fail();
} catch (MyException expected) {
}
assertEquals(oldName, Thread.currentThread().getName());
}
@GwtIncompatible // threads
public void testRenaming_noPermissions() throws Exception {
System.setSecurityManager(
new SecurityManager() {
@Override
public void checkAccess(Thread t) {
throw new SecurityException();
}
@Override
public void checkPermission(Permission perm) {
// Do nothing so we can clear the security manager at the end
}
});
try {
final String oldName = Thread.currentThread().getName();
Supplier<String> newName = Suppliers.ofInstance("MyCrazyThreadName");
Callable<Void> callable =
new Callable<Void>() {
@Override
public Void call() throws Exception {
assertEquals(Thread.currentThread().getName(), oldName);
return null;
}
};
Callables.threadRenaming(callable, newName).call();
assertEquals(oldName, Thread.currentThread().getName());
} finally {
System.setSecurityManager(null);
}
}
} | [
"@",
"GwtCompatible",
"(",
"emulated",
"=",
"true",
")",
"public",
"class",
"CallablesTest",
"extends",
"TestCase",
"{",
"public",
"void",
"testReturning",
"(",
")",
"throws",
"Exception",
"{",
"assertNull",
"(",
"Callables",
".",
"returning",
"(",
"null",
")",
".",
"call",
"(",
")",
")",
";",
"Object",
"value",
"=",
"new",
"Object",
"(",
")",
";",
"Callable",
"<",
"Object",
">",
"callable",
"=",
"Callables",
".",
"returning",
"(",
"value",
")",
";",
"assertSame",
"(",
"value",
",",
"callable",
".",
"call",
"(",
")",
")",
";",
"assertSame",
"(",
"value",
",",
"callable",
".",
"call",
"(",
")",
")",
";",
"}",
"@",
"GwtIncompatible",
"public",
"void",
"testAsAsyncCallable",
"(",
")",
"throws",
"Exception",
"{",
"final",
"String",
"expected",
"=",
"\"",
"MyCallableString",
"\"",
";",
"Callable",
"<",
"String",
">",
"callable",
"=",
"new",
"Callable",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"call",
"(",
")",
"throws",
"Exception",
"{",
"return",
"expected",
";",
"}",
"}",
";",
"AsyncCallable",
"<",
"String",
">",
"asyncCallable",
"=",
"Callables",
".",
"asAsyncCallable",
"(",
"callable",
",",
"MoreExecutors",
".",
"newDirectExecutorService",
"(",
")",
")",
";",
"ListenableFuture",
"<",
"String",
">",
"future",
"=",
"asyncCallable",
".",
"call",
"(",
")",
";",
"assertSame",
"(",
"expected",
",",
"future",
".",
"get",
"(",
")",
")",
";",
"}",
"@",
"GwtIncompatible",
"public",
"void",
"testAsAsyncCallable_exception",
"(",
")",
"throws",
"Exception",
"{",
"final",
"Exception",
"expected",
"=",
"new",
"IllegalArgumentException",
"(",
")",
";",
"Callable",
"<",
"String",
">",
"callable",
"=",
"new",
"Callable",
"<",
"String",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"String",
"call",
"(",
")",
"throws",
"Exception",
"{",
"throw",
"expected",
";",
"}",
"}",
";",
"AsyncCallable",
"<",
"String",
">",
"asyncCallable",
"=",
"Callables",
".",
"asAsyncCallable",
"(",
"callable",
",",
"MoreExecutors",
".",
"newDirectExecutorService",
"(",
")",
")",
";",
"ListenableFuture",
"<",
"String",
">",
"future",
"=",
"asyncCallable",
".",
"call",
"(",
")",
";",
"try",
"{",
"future",
".",
"get",
"(",
")",
";",
"fail",
"(",
"\"",
"Expected exception to be thrown",
"\"",
")",
";",
"}",
"catch",
"(",
"ExecutionException",
"e",
")",
"{",
"assertThat",
"(",
"e",
")",
".",
"hasCauseThat",
"(",
")",
".",
"isSameAs",
"(",
"expected",
")",
";",
"}",
"}",
"@",
"GwtIncompatible",
"public",
"void",
"testRenaming",
"(",
")",
"throws",
"Exception",
"{",
"String",
"oldName",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
";",
"final",
"Supplier",
"<",
"String",
">",
"newName",
"=",
"Suppliers",
".",
"ofInstance",
"(",
"\"",
"MyCrazyThreadName",
"\"",
")",
";",
"Callable",
"<",
"Void",
">",
"callable",
"=",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"throws",
"Exception",
"{",
"assertEquals",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
",",
"newName",
".",
"get",
"(",
")",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"Callables",
".",
"threadRenaming",
"(",
"callable",
",",
"newName",
")",
".",
"call",
"(",
")",
";",
"assertEquals",
"(",
"oldName",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"@",
"GwtIncompatible",
"public",
"void",
"testRenaming_exceptionalReturn",
"(",
")",
"throws",
"Exception",
"{",
"String",
"oldName",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
";",
"final",
"Supplier",
"<",
"String",
">",
"newName",
"=",
"Suppliers",
".",
"ofInstance",
"(",
"\"",
"MyCrazyThreadName",
"\"",
")",
";",
"class",
"MyException",
"extends",
"Exception",
"{",
"}",
"Callable",
"<",
"Void",
">",
"callable",
"=",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"throws",
"Exception",
"{",
"assertEquals",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
",",
"newName",
".",
"get",
"(",
")",
")",
";",
"throw",
"new",
"MyException",
"(",
")",
";",
"}",
"}",
";",
"try",
"{",
"Callables",
".",
"threadRenaming",
"(",
"callable",
",",
"newName",
")",
".",
"call",
"(",
")",
";",
"fail",
"(",
")",
";",
"}",
"catch",
"(",
"MyException",
"expected",
")",
"{",
"}",
"assertEquals",
"(",
"oldName",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"@",
"GwtIncompatible",
"public",
"void",
"testRenaming_noPermissions",
"(",
")",
"throws",
"Exception",
"{",
"System",
".",
"setSecurityManager",
"(",
"new",
"SecurityManager",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"checkAccess",
"(",
"Thread",
"t",
")",
"{",
"throw",
"new",
"SecurityException",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"checkPermission",
"(",
"Permission",
"perm",
")",
"{",
"}",
"}",
")",
";",
"try",
"{",
"final",
"String",
"oldName",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
";",
"Supplier",
"<",
"String",
">",
"newName",
"=",
"Suppliers",
".",
"ofInstance",
"(",
"\"",
"MyCrazyThreadName",
"\"",
")",
";",
"Callable",
"<",
"Void",
">",
"callable",
"=",
"new",
"Callable",
"<",
"Void",
">",
"(",
")",
"{",
"@",
"Override",
"public",
"Void",
"call",
"(",
")",
"throws",
"Exception",
"{",
"assertEquals",
"(",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
",",
"oldName",
")",
";",
"return",
"null",
";",
"}",
"}",
";",
"Callables",
".",
"threadRenaming",
"(",
"callable",
",",
"newName",
")",
".",
"call",
"(",
")",
";",
"assertEquals",
"(",
"oldName",
",",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"}",
"finally",
"{",
"System",
".",
"setSecurityManager",
"(",
"null",
")",
";",
"}",
"}",
"}"
] | Unit tests for {@link Callables}. | [
"Unit",
"tests",
"for",
"{",
"@link",
"Callables",
"}",
"."
] | [
"// Expect the same value on subsequent calls",
"// threads",
"// threads",
"// threads",
"// Do nothing so we can clear the security manager at the end"
] | [
{
"param": "TestCase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "TestCase",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
077651cb3aacb39818983156e687079828ff0eed | wizzardo/webery | src/test/java/com/wizzardo/http/framework/template/taglib/TextFieldTest.java | [
"MIT"
] | Java | TextFieldTest | /**
* Created by wizzardo on 26.04.15.
*/ | Created by wizzardo on 26.04.15. | [
"Created",
"by",
"wizzardo",
"on",
"26",
".",
"04",
".",
"15",
"."
] | public class TextFieldTest implements TagTest {
@Before
public void setup() {
TagLib.findTags(Collections.singletonList(TextField.class));
}
protected String getType() {
return "text";
}
@Test
public void test_1() {
RenderResult result = prepare("<g:" + getType() + "Field name=\"myField\" value=\"${myValue}\"/>")
.get(new Model().append("myValue", 1));
Assert.assertEquals("<input type=\"" + getType() + "\" name=\"myField\" id=\"myField\" value=\"1\"/>\n", result.toString());
}
@Test
public void test_2() {
RenderResult result = prepare("<g:" + getType() + "Field name=\"myField\" id=\"text_${myValue}\" value=\"${myValue}\"/>")
.get(new Model().append("myValue", 1));
Assert.assertEquals("<input type=\"" + getType() + "\" name=\"myField\" id=\"text_1\" value=\"1\"/>\n", result.toString());
}
@Test
public void test_3() {
RenderResult result = prepare("<g:" + getType() + "Field name=\"myField_${myValue++}\" value=\"${myValue}\"/>")
.get(new Model().append("myValue", 1));
Assert.assertEquals("<input type=\"" + getType() + "\" name=\"myField_1\" id=\"myField_1\" value=\"2\"/>\n", result.toString());
}
@Test
public void test_4() {
RenderResult result = prepare("<g:" + getType() + "Field name=\"myField\"/>").get(new Model());
Assert.assertEquals("<input type=\"" + getType() + "\" name=\"myField\" id=\"myField\"/>\n", result.toString());
}
@Test
public void test_5() {
RenderResult result = prepare("<g:" + getType() + "Field name=\"myField\" style=\"border: 0\"/>").get(new Model());
Assert.assertEquals("<input type=\"" + getType() + "\" name=\"myField\" id=\"myField\" style=\"border: 0\"/>\n", result.toString());
}
} | [
"public",
"class",
"TextFieldTest",
"implements",
"TagTest",
"{",
"@",
"Before",
"public",
"void",
"setup",
"(",
")",
"{",
"TagLib",
".",
"findTags",
"(",
"Collections",
".",
"singletonList",
"(",
"TextField",
".",
"class",
")",
")",
";",
"}",
"protected",
"String",
"getType",
"(",
")",
"{",
"return",
"\"",
"text",
"\"",
";",
"}",
"@",
"Test",
"public",
"void",
"test_1",
"(",
")",
"{",
"RenderResult",
"result",
"=",
"prepare",
"(",
"\"",
"<g:",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"Field name=",
"\\\"",
"myField",
"\\\"",
" value=",
"\\\"",
"${myValue}",
"\\\"",
"/>",
"\"",
")",
".",
"get",
"(",
"new",
"Model",
"(",
")",
".",
"append",
"(",
"\"",
"myValue",
"\"",
",",
"1",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"<input type=",
"\\\"",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"\\\"",
" name=",
"\\\"",
"myField",
"\\\"",
" id=",
"\\\"",
"myField",
"\\\"",
" value=",
"\\\"",
"1",
"\\\"",
"/>",
"\\n",
"\"",
",",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test_2",
"(",
")",
"{",
"RenderResult",
"result",
"=",
"prepare",
"(",
"\"",
"<g:",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"Field name=",
"\\\"",
"myField",
"\\\"",
" id=",
"\\\"",
"text_${myValue}",
"\\\"",
" value=",
"\\\"",
"${myValue}",
"\\\"",
"/>",
"\"",
")",
".",
"get",
"(",
"new",
"Model",
"(",
")",
".",
"append",
"(",
"\"",
"myValue",
"\"",
",",
"1",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"<input type=",
"\\\"",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"\\\"",
" name=",
"\\\"",
"myField",
"\\\"",
" id=",
"\\\"",
"text_1",
"\\\"",
" value=",
"\\\"",
"1",
"\\\"",
"/>",
"\\n",
"\"",
",",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test_3",
"(",
")",
"{",
"RenderResult",
"result",
"=",
"prepare",
"(",
"\"",
"<g:",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"Field name=",
"\\\"",
"myField_${myValue++}",
"\\\"",
" value=",
"\\\"",
"${myValue}",
"\\\"",
"/>",
"\"",
")",
".",
"get",
"(",
"new",
"Model",
"(",
")",
".",
"append",
"(",
"\"",
"myValue",
"\"",
",",
"1",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"<input type=",
"\\\"",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"\\\"",
" name=",
"\\\"",
"myField_1",
"\\\"",
" id=",
"\\\"",
"myField_1",
"\\\"",
" value=",
"\\\"",
"2",
"\\\"",
"/>",
"\\n",
"\"",
",",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test_4",
"(",
")",
"{",
"RenderResult",
"result",
"=",
"prepare",
"(",
"\"",
"<g:",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"Field name=",
"\\\"",
"myField",
"\\\"",
"/>",
"\"",
")",
".",
"get",
"(",
"new",
"Model",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"<input type=",
"\\\"",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"\\\"",
" name=",
"\\\"",
"myField",
"\\\"",
" id=",
"\\\"",
"myField",
"\\\"",
"/>",
"\\n",
"\"",
",",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"@",
"Test",
"public",
"void",
"test_5",
"(",
")",
"{",
"RenderResult",
"result",
"=",
"prepare",
"(",
"\"",
"<g:",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"Field name=",
"\\\"",
"myField",
"\\\"",
" style=",
"\\\"",
"border: 0",
"\\\"",
"/>",
"\"",
")",
".",
"get",
"(",
"new",
"Model",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"<input type=",
"\\\"",
"\"",
"+",
"getType",
"(",
")",
"+",
"\"",
"\\\"",
" name=",
"\\\"",
"myField",
"\\\"",
" id=",
"\\\"",
"myField",
"\\\"",
" style=",
"\\\"",
"border: 0",
"\\\"",
"/>",
"\\n",
"\"",
",",
"result",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | Created by wizzardo on 26.04.15. | [
"Created",
"by",
"wizzardo",
"on",
"26",
".",
"04",
".",
"15",
"."
] | [] | [
{
"param": "TagTest",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "TagTest",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0777ddd4980eb75b2ee4a0592bb1f05b2fdf1f2c | IBM/suro-oaas | suro-oaas/suro-oaas-model/src/test/java/com/ibm/au/optim/suro/model/entities/ObjectiveTest.java | [
"Apache-2.0"
] | Java | ObjectiveTest | /**
* Class <b>ObjectiveTest</b>. This class tests the implemented behaviour
* of the {@link Objective}. An {@link Objective} instance has always a
* <i>name</i> and a <i>label</i> not {@literal null} and not empty. The
* <i>description</i> can be {@literal null}. If not specific the <i>label</i>
* takes the value of the <i>name</i>.
*
*
* @author Peter Ilfrich and Christian Vecchiola
*/ |
@author Peter Ilfrich and Christian Vecchiola | [
"@author",
"Peter",
"Ilfrich",
"and",
"Christian",
"Vecchiola"
] | public class ObjectiveTest {
/**
* This method tests the implemented behaviour of {@link Objective#Objective(String)}.
* The method is expected to initialise an instance of {@link Objective} whose <i>name</i>
* is passed as argument to the constructor, <i>label</i> is the same as the <i>name</i>
* and <i>description</i> is {@literal null}. The <i>name</i> cannot be {@literal null} or
* an empty string.
*/
@Test
public void testConstructorWithName() {
try {
new Objective(null);
Assert.fail("Objective.Objective(null) should throw IllegalArgumentException.");
} catch(IllegalArgumentException ilex) {
// ok, this means that the exception has
// been thrown as expected.
}
String expectedName = "o1";
Objective obj = new Objective(expectedName);
Assert.assertEquals(expectedName, obj.getName());
Assert.assertEquals(expectedName, obj.getLabel());
Assert.assertNull(obj.getDescription());
}
/**
* This method tests the implemented behaviour of {@link Objective#Objective(String,String,String)}.
* The method is expected to initialise an instance of {@link Objective} whose <i>name</i> is passed
* as first argument to the constructor, <i>label</i> is passed as second argument, and <i>description</i>
* is set to the third argument. Neither <i>name</i> nor <i>label</i> can be {@literal null} or an
* empty string.
*/
@Test
public void testConstructorWithNameLabelAndDescription() {
String expectedName = "o1";
try {
new Objective(null, "Label", "This is a description.");
Assert.fail("Objective.Objective(null, String, String) should throw IllegalArgumentException.");
} catch(IllegalArgumentException ilex) {
// ok, this means that the exception has
// been thrown as expected.
}
try {
new Objective(expectedName, null, "This is a description.");
Assert.fail("Objective.Objective(String, null, String) should throw IllegalArgumentException.");
} catch(IllegalArgumentException ilex) {
// ok, this means that exception has
// been thrown
}
Objective obj = new Objective(expectedName, "Label", null);
Assert.assertEquals(expectedName, obj.getName());
Assert.assertEquals("Label", obj.getLabel());
Assert.assertNull(obj.getDescription());
obj = new Objective(expectedName, "Label", "This is a description.");
Assert.assertEquals(expectedName, obj.getName());
Assert.assertEquals("Label", obj.getLabel());
Assert.assertEquals("This is a description.", obj.getDescription());
}
/**
* This method tests the implemented behaviour of the getter and setter
* methods for the <i>label</i> property. The label cannot be {@literal
* null} or an empty string. Moreover, the value of set with the setter
* must be returned by the getter. The default value is equal to the
* value of the <i>name</i> property.
*/
@Test
public void testGetSetLabel() {
// Test 1. equal to the name by the default.
//
Objective objective = new Objective("o1");
Assert.assertEquals(objective.getName(), objective.getLabel());
// Test 2. can we assign a value and retrieve it?
//
String expected = "thisIsALabel";
objective.setLabel(expected);
String actual = objective.getLabel();
Assert.assertEquals(expected, actual);
// Test 3. can we assign a null value? No!
//
try {
objective.setLabel(null);
Assert.fail("Objective.setLabel(null) should throw an IllegalArgumentException when label is null.");
} catch(IllegalArgumentException ilex) {
// ok good to go...
}
// Test 4. can we assign an empty value? No!
//
try {
objective.setLabel("");
Assert.fail("Objective.setName('') should throw an IllegalArgumentException when label is an empty string.");
} catch(IllegalArgumentException ilex) {
// ok good to go...
}
}
/**
* This method tests the implemented behaviour of the getter and setter
* methods for the <i>name</i> property. The name cannot be {@literal
* null} or an empty string. Moreover, the value of set with the setter
* must be returned by the getter.
*/
@Test
public void testGetSetName() {
String expectedName = "o1";
// Test 1. null by default.
//
Objective objective = new Objective(expectedName);
String actualName = objective.getName();
Assert.assertEquals(expectedName, actualName);
// Test 2. can we assign a value and retrieve it?
//
expectedName = "o2";
objective.setName(expectedName);
actualName = objective.getName();
Assert.assertEquals(expectedName, actualName);
// Test 3. can we assign a null value? No!
//
try {
objective.setName(null);
Assert.fail("Objective.setName(null) should throw an IllegalArgumentException when name is null.");
} catch(IllegalArgumentException ilex) {
// ok good to go...
}
// Test 4. can we assign an empty value? No!
//
try {
objective.setName("");
Assert.fail("Objective.setName('') should throw an IllegalArgumentException when name is an empty string.");
} catch(IllegalArgumentException ilex) {
// ok good to go...
}
}
/**
* This method tests the implemented behaviour of the getter and setter
* methods for the <i>description</i> property. The value of set with the setter
* must be returned by the getter. There are no restrictions on the value of the
* property and its default is {@literal null}.
*/
@Test
public void testGetSetDescription() {
// Test 1. null by default.
//
Objective objective = new Objective("o1");
Assert.assertNull(objective.getDescription());
// Test 2. can we assign a value and retrieve it?
//
String expected = "This is a description.";
objective.setDescription(expected);
String actual = objective.getDescription();
Assert.assertEquals(expected, actual);
// Test 3. can we assign a null value?
objective.setDescription(null);
Assert.assertNull(objective.getDescription());
}
/**
* This method tests the implemented behaviour of {@link Objective#equals(Object)}.
* The method is expected to return {@literal true} if the instances compared are
* both of type {@link Objective} and have the same name.
*/
@Test
public void testEquals() {
// Test 1. obviousness test.
//
Objective obj1 = new Objective("o1");
Assert.assertTrue(obj1.equals(obj1));
// Test 2. same name, should return true.
//
Objective obj2 = new Objective("o1");
Assert.assertTrue(obj1.equals(obj2));
// Test 3. different name, should return false
//
obj1.setName("o3");
Assert.assertFalse(obj1.equals(obj2));
// Test 4. when name the same again, should return true
//
obj2.setName("o3");
Assert.assertTrue(obj1.equals(obj2));
// Test 5. change of the label property does not affect
// the equality test.
//
obj1.setLabel("label");
Assert.assertTrue(obj1.equals(obj2));
obj2.setLabel("label");
Assert.assertTrue(obj1.equals(obj2));
// Test 6. change of the description property does not
// affect the equality test.
//
obj1.setDescription("description");
Assert.assertTrue(obj1.equals(obj2));
obj2.setDescription("description");
Assert.assertTrue(obj1.equals(obj2));
// Test 7. different type of object, should return false.
//
Assert.assertFalse(obj1.equals("o1"));
// Test 8. invoked with null, should return false.
//
Assert.assertFalse(obj1.equals(null));
}
/**
* This method tests the implemented behaviour of {@link Objective#clone()}.
* The method is expected to clone complex properties and to shallow copy
* immutable properties or simple ones.
*/
@Test
public void testClone() {
Objective expected = new Objective("o1");
Objective actual = expected.clone();
this.equals(expected, actual);
expected.setName("o2");
expected.setLabel("This is a label.");
expected.setDescription("This is the description.");
actual = expected.clone();
this.equals(expected, actual);
}
/**
* This method tests that the two instances of {@link Objective} passed as arguments
* are the same. It does so by comparing field by field all the properties of the
* {@link Objective} class (those defined directly in the class).
*
* @param expected a {@link Objective} reference. It cannot be {@literal null}.
* @param actual a {@link Objective} reference. It cannot be {@literal null}.
*/
protected void equals(Objective expected, Objective actual) {
Assert.assertEquals(expected.getName(), actual.getName());
Assert.assertEquals(expected.getLabel(), actual.getLabel());
Assert.assertEquals(expected.getDescription(), actual.getDescription());
}
} | [
"public",
"class",
"ObjectiveTest",
"{",
"/**\n\t * This method tests the implemented behaviour of {@link Objective#Objective(String)}.\n\t * The method is expected to initialise an instance of {@link Objective} whose <i>name</i>\n\t * is passed as argument to the constructor, <i>label</i> is the same as the <i>name</i>\n\t * and <i>description</i> is {@literal null}. The <i>name</i> cannot be {@literal null} or\n\t * an empty string. \n\t */",
"@",
"Test",
"public",
"void",
"testConstructorWithName",
"(",
")",
"{",
"try",
"{",
"new",
"Objective",
"(",
"null",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.Objective(null) should throw IllegalArgumentException.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"String",
"expectedName",
"=",
"\"",
"o1",
"\"",
";",
"Objective",
"obj",
"=",
"new",
"Objective",
"(",
"expectedName",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"obj",
".",
"getName",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"obj",
".",
"getLabel",
"(",
")",
")",
";",
"Assert",
".",
"assertNull",
"(",
"obj",
".",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\n\t * This method tests the implemented behaviour of {@link Objective#Objective(String,String,String)}.\n\t * The method is expected to initialise an instance of {@link Objective} whose <i>name</i> is passed \n\t * as first argument to the constructor, <i>label</i> is passed as second argument, and <i>description</i>\n\t * is set to the third argument. Neither <i>name</i> nor <i>label</i> can be {@literal null} or an\n\t * empty string.\n\t */",
"@",
"Test",
"public",
"void",
"testConstructorWithNameLabelAndDescription",
"(",
")",
"{",
"String",
"expectedName",
"=",
"\"",
"o1",
"\"",
";",
"try",
"{",
"new",
"Objective",
"(",
"null",
",",
"\"",
"Label",
"\"",
",",
"\"",
"This is a description.",
"\"",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.Objective(null, String, String) should throw IllegalArgumentException.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"try",
"{",
"new",
"Objective",
"(",
"expectedName",
",",
"null",
",",
"\"",
"This is a description.",
"\"",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.Objective(String, null, String) should throw IllegalArgumentException.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"Objective",
"obj",
"=",
"new",
"Objective",
"(",
"expectedName",
",",
"\"",
"Label",
"\"",
",",
"null",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"obj",
".",
"getName",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"Label",
"\"",
",",
"obj",
".",
"getLabel",
"(",
")",
")",
";",
"Assert",
".",
"assertNull",
"(",
"obj",
".",
"getDescription",
"(",
")",
")",
";",
"obj",
"=",
"new",
"Objective",
"(",
"expectedName",
",",
"\"",
"Label",
"\"",
",",
"\"",
"This is a description.",
"\"",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"obj",
".",
"getName",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"Label",
"\"",
",",
"obj",
".",
"getLabel",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"\"",
"This is a description.",
"\"",
",",
"obj",
".",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\n * This method tests the implemented behaviour of the getter and setter\n * methods for the <i>label</i> property. The label cannot be {@literal \n * null} or an empty string. Moreover, the value of set with the setter\n * must be returned by the getter. The default value is equal to the \n * value of the <i>name</i> property.\n */",
"@",
"Test",
"public",
"void",
"testGetSetLabel",
"(",
")",
"{",
"Objective",
"objective",
"=",
"new",
"Objective",
"(",
"\"",
"o1",
"\"",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"objective",
".",
"getName",
"(",
")",
",",
"objective",
".",
"getLabel",
"(",
")",
")",
";",
"String",
"expected",
"=",
"\"",
"thisIsALabel",
"\"",
";",
"objective",
".",
"setLabel",
"(",
"expected",
")",
";",
"String",
"actual",
"=",
"objective",
".",
"getLabel",
"(",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expected",
",",
"actual",
")",
";",
"try",
"{",
"objective",
".",
"setLabel",
"(",
"null",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.setLabel(null) should throw an IllegalArgumentException when label is null.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"try",
"{",
"objective",
".",
"setLabel",
"(",
"\"",
"\"",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.setName('') should throw an IllegalArgumentException when label is an empty string.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"}",
"/**\n * This method tests the implemented behaviour of the getter and setter\n * methods for the <i>name</i> property. The name cannot be {@literal \n * null} or an empty string. Moreover, the value of set with the setter\n * must be returned by the getter. \n */",
"@",
"Test",
"public",
"void",
"testGetSetName",
"(",
")",
"{",
"String",
"expectedName",
"=",
"\"",
"o1",
"\"",
";",
"Objective",
"objective",
"=",
"new",
"Objective",
"(",
"expectedName",
")",
";",
"String",
"actualName",
"=",
"objective",
".",
"getName",
"(",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"actualName",
")",
";",
"expectedName",
"=",
"\"",
"o2",
"\"",
";",
"objective",
".",
"setName",
"(",
"expectedName",
")",
";",
"actualName",
"=",
"objective",
".",
"getName",
"(",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expectedName",
",",
"actualName",
")",
";",
"try",
"{",
"objective",
".",
"setName",
"(",
"null",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.setName(null) should throw an IllegalArgumentException when name is null.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"try",
"{",
"objective",
".",
"setName",
"(",
"\"",
"\"",
")",
";",
"Assert",
".",
"fail",
"(",
"\"",
"Objective.setName('') should throw an IllegalArgumentException when name is an empty string.",
"\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"ilex",
")",
"{",
"}",
"}",
"/**\n * This method tests the implemented behaviour of the getter and setter\n * methods for the <i>description</i> property. The value of set with the setter\n * must be returned by the getter. There are no restrictions on the value of the\n * property and its default is {@literal null}.\n */",
"@",
"Test",
"public",
"void",
"testGetSetDescription",
"(",
")",
"{",
"Objective",
"objective",
"=",
"new",
"Objective",
"(",
"\"",
"o1",
"\"",
")",
";",
"Assert",
".",
"assertNull",
"(",
"objective",
".",
"getDescription",
"(",
")",
")",
";",
"String",
"expected",
"=",
"\"",
"This is a description.",
"\"",
";",
"objective",
".",
"setDescription",
"(",
"expected",
")",
";",
"String",
"actual",
"=",
"objective",
".",
"getDescription",
"(",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expected",
",",
"actual",
")",
";",
"objective",
".",
"setDescription",
"(",
"null",
")",
";",
"Assert",
".",
"assertNull",
"(",
"objective",
".",
"getDescription",
"(",
")",
")",
";",
"}",
"/**\n * This method tests the implemented behaviour of {@link Objective#equals(Object)}.\n * The method is expected to return {@literal true} if the instances compared are\n * both of type {@link Objective} and have the same name.\n */",
"@",
"Test",
"public",
"void",
"testEquals",
"(",
")",
"{",
"Objective",
"obj1",
"=",
"new",
"Objective",
"(",
"\"",
"o1",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj1",
")",
")",
";",
"Objective",
"obj2",
"=",
"new",
"Objective",
"(",
"\"",
"o1",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj1",
".",
"setName",
"(",
"\"",
"o3",
"\"",
")",
";",
"Assert",
".",
"assertFalse",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj2",
".",
"setName",
"(",
"\"",
"o3",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj1",
".",
"setLabel",
"(",
"\"",
"label",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj2",
".",
"setLabel",
"(",
"\"",
"label",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj1",
".",
"setDescription",
"(",
"\"",
"description",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"obj2",
".",
"setDescription",
"(",
"\"",
"description",
"\"",
")",
";",
"Assert",
".",
"assertTrue",
"(",
"obj1",
".",
"equals",
"(",
"obj2",
")",
")",
";",
"Assert",
".",
"assertFalse",
"(",
"obj1",
".",
"equals",
"(",
"\"",
"o1",
"\"",
")",
")",
";",
"Assert",
".",
"assertFalse",
"(",
"obj1",
".",
"equals",
"(",
"null",
")",
")",
";",
"}",
"/**\n * This method tests the implemented behaviour of {@link Objective#clone()}.\n * The method is expected to clone complex properties and to shallow copy \n * immutable properties or simple ones.\n */",
"@",
"Test",
"public",
"void",
"testClone",
"(",
")",
"{",
"Objective",
"expected",
"=",
"new",
"Objective",
"(",
"\"",
"o1",
"\"",
")",
";",
"Objective",
"actual",
"=",
"expected",
".",
"clone",
"(",
")",
";",
"this",
".",
"equals",
"(",
"expected",
",",
"actual",
")",
";",
"expected",
".",
"setName",
"(",
"\"",
"o2",
"\"",
")",
";",
"expected",
".",
"setLabel",
"(",
"\"",
"This is a label.",
"\"",
")",
";",
"expected",
".",
"setDescription",
"(",
"\"",
"This is the description.",
"\"",
")",
";",
"actual",
"=",
"expected",
".",
"clone",
"(",
")",
";",
"this",
".",
"equals",
"(",
"expected",
",",
"actual",
")",
";",
"}",
"/**\n * This method tests that the two instances of {@link Objective} passed as arguments\n * are the same. It does so by comparing field by field all the properties of the \n * {@link Objective} class (those defined directly in the class).\n * \n * @param expected\ta {@link Objective} reference. It cannot be {@literal null}.\n * @param actual\ta {@link Objective} reference. It cannot be {@literal null}.\n */",
"protected",
"void",
"equals",
"(",
"Objective",
"expected",
",",
"Objective",
"actual",
")",
"{",
"Assert",
".",
"assertEquals",
"(",
"expected",
".",
"getName",
"(",
")",
",",
"actual",
".",
"getName",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expected",
".",
"getLabel",
"(",
")",
",",
"actual",
".",
"getLabel",
"(",
")",
")",
";",
"Assert",
".",
"assertEquals",
"(",
"expected",
".",
"getDescription",
"(",
")",
",",
"actual",
".",
"getDescription",
"(",
")",
")",
";",
"}",
"}"
] | Class <b>ObjectiveTest</b>. | [
"Class",
"<b",
">",
"ObjectiveTest<",
"/",
"b",
">",
"."
] | [
"// ok, this means that the exception has",
"// been thrown as expected.",
"// ok, this means that the exception has",
"// been thrown as expected.",
"// ok, this means that exception has",
"// been thrown",
"// Test 1. equal to the name by the default.",
"//",
"// Test 2. can we assign a value and retrieve it?",
"//",
"// Test 3. can we assign a null value? No!",
"//",
"// ok good to go...",
"// Test 4. can we assign an empty value? No!",
"//",
"// ok good to go...",
"// Test 1. null by default.",
"//",
"// Test 2. can we assign a value and retrieve it?",
"//",
"// Test 3. can we assign a null value? No!",
"//",
"// ok good to go...",
"// Test 4. can we assign an empty value? No!",
"//",
"// ok good to go...",
"// Test 1. null by default.",
"//",
"// Test 2. can we assign a value and retrieve it?",
"//",
"// Test 3. can we assign a null value?",
"// Test 1. obviousness test.",
"//",
"// Test 2. same name, should return true.",
"//",
"// Test 3. different name, should return false",
"//",
"// Test 4. when name the same again, should return true",
"//",
"// Test 5. change of the label property does not affect",
"// the equality test.",
"//",
"// Test 6. change of the description property does not",
"//\t\t affect the equality test.",
"//",
"// Test 7. different type of object, should return false.",
"//",
"// Test 8. invoked with null, should return false.",
"//"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
077844c118199ca1e5146637236fce02f94354fa | Olutobz/Intro-to-Java-Programming | solutions/chapter6/Exercise_06_29.java | [
"MIT"
] | Java | Exercise_06_29 | /*
(Twin primes) Twin primes are a pair of prime numbers that differ by 2. For example,
3 and 5 are twin primes, 5 and 7 are twin primes, and 11 and 13 are twin primes.
Write a program to find all twin primes less than 1,000. Display the output as follows:
(3, 5)
(5, 7)
...
*/ | (Twin primes) Twin primes are a pair of prime numbers that differ by 2. For example,
3 and 5 are twin primes, 5 and 7 are twin primes, and 11 and 13 are twin primes.
Write a program to find all twin primes less than 1,000. Display the output as follows:
(3, 5)
(5, 7) | [
"(",
"Twin",
"primes",
")",
"Twin",
"primes",
"are",
"a",
"pair",
"of",
"prime",
"numbers",
"that",
"differ",
"by",
"2",
".",
"For",
"example",
"3",
"and",
"5",
"are",
"twin",
"primes",
"5",
"and",
"7",
"are",
"twin",
"primes",
"and",
"11",
"and",
"13",
"are",
"twin",
"primes",
".",
"Write",
"a",
"program",
"to",
"find",
"all",
"twin",
"primes",
"less",
"than",
"1",
"000",
".",
"Display",
"the",
"output",
"as",
"follows",
":",
"(",
"3",
"5",
")",
"(",
"5",
"7",
")"
] | public class Exercise_06_29 {
public static void main(String[] args) {
// Find and display all twin primes less than 1,000
System.out.println();
for (int p = 2; p < 1000; p++) {
if (isTwinprime(p))
System.out.println("(" + p + ", " + (p + 2) + ")");
}
}
/**
* Method isTwinprime returns true if num and num + 2 are primes
*/
public static boolean isTwinprime(int num) {
return PrimeNumberMethod.isPrime(num) && PrimeNumberMethod.isPrime(num + 2);
}
} | [
"public",
"class",
"Exercise_06_29",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"for",
"(",
"int",
"p",
"=",
"2",
";",
"p",
"<",
"1000",
";",
"p",
"++",
")",
"{",
"if",
"(",
"isTwinprime",
"(",
"p",
")",
")",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"(",
"\"",
"+",
"p",
"+",
"\"",
", ",
"\"",
"+",
"(",
"p",
"+",
"2",
")",
"+",
"\"",
")",
"\"",
")",
";",
"}",
"}",
"/**\n * Method isTwinprime returns true if num and num + 2 are primes\n */",
"public",
"static",
"boolean",
"isTwinprime",
"(",
"int",
"num",
")",
"{",
"return",
"PrimeNumberMethod",
".",
"isPrime",
"(",
"num",
")",
"&&",
"PrimeNumberMethod",
".",
"isPrime",
"(",
"num",
"+",
"2",
")",
";",
"}",
"}"
] | (Twin primes) Twin primes are a pair of prime numbers that differ by 2. | [
"(",
"Twin",
"primes",
")",
"Twin",
"primes",
"are",
"a",
"pair",
"of",
"prime",
"numbers",
"that",
"differ",
"by",
"2",
"."
] | [
"// Find and display all twin primes less than 1,000"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
07785712fcd6282d74b464b76a48885690b3d84b | Waitres/mydemo | Administration/src/main/java/com/liu/coder/utils/ControllerUtils.java | [
"Apache-2.0"
] | Java | ControllerUtils | /**
* Created by liuyidiao on 2017/7/10.
*/ | Created by liuyidiao on 2017/7/10. | [
"Created",
"by",
"liuyidiao",
"on",
"2017",
"/",
"7",
"/",
"10",
"."
] | public class ControllerUtils {
/**
* Ajax执行结果回调函数,返回map对象
* 需jackson包支持
*
* @param result
* @param message
* @return map
*/
public static Map ajaxResult(Boolean result, String message) {
Map map = new HashMap();
map.put("result", result);
map.put("message", message);
return map;
}
/**
* Ajax执行结果回调函数,返回Json字符串
* 需fastjson包支持
*
* @param result
* @param message
* @return String json格式
*/
public static String ajaxResultWithJsonString(Boolean result, String message) {
Map map = new HashMap();
map.put("result", result);
map.put("message", message);
return JSON.toJSONString(map);
}
} | [
"public",
"class",
"ControllerUtils",
"{",
"/**\n * Ajax执行结果回调函数,返回map对象\n * 需jackson包支持\n *\n * @param result\n * @param message\n * @return map\n */",
"public",
"static",
"Map",
"ajaxResult",
"(",
"Boolean",
"result",
",",
"String",
"message",
")",
"{",
"Map",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"",
"result",
"\"",
",",
"result",
")",
";",
"map",
".",
"put",
"(",
"\"",
"message",
"\"",
",",
"message",
")",
";",
"return",
"map",
";",
"}",
"/**\n * Ajax执行结果回调函数,返回Json字符串\n * 需fastjson包支持\n *\n * @param result\n * @param message\n * @return String json格式\n */",
"public",
"static",
"String",
"ajaxResultWithJsonString",
"(",
"Boolean",
"result",
",",
"String",
"message",
")",
"{",
"Map",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"",
"result",
"\"",
",",
"result",
")",
";",
"map",
".",
"put",
"(",
"\"",
"message",
"\"",
",",
"message",
")",
";",
"return",
"JSON",
".",
"toJSONString",
"(",
"map",
")",
";",
"}",
"}"
] | Created by liuyidiao on 2017/7/10. | [
"Created",
"by",
"liuyidiao",
"on",
"2017",
"/",
"7",
"/",
"10",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
077950a18dc009eb9c3f7c45e35a00f5d3bbd1b3 | genome-vendor/apollo | src/java/org/bdgp/util/NestedException.java | [
"BSD-3-Clause"
] | Java | NestedException | /**
* A general perpose Exception that can wrap another exception.
* <P>
* It is common practice in BioJava to throw a NestedException or a subclass of it
* when something goes wrong. The exception can be used to catch another
* throwable, thus keeping a complete record of where the original error
* originated while adding annotation to the stack-trace. It also affords a neat
* way to avoid exception-bloat on method calls, particularly when objects are
* composed from several objects from different packages.
*
* @author Matthew Pocock
*/ | A general perpose Exception that can wrap another exception.
It is common practice in BioJava to throw a NestedException or a subclass of it
when something goes wrong. The exception can be used to catch another
throwable, thus keeping a complete record of where the original error
originated while adding annotation to the stack-trace. It also affords a neat
way to avoid exception-bloat on method calls, particularly when objects are
composed from several objects from different packages.
@author Matthew Pocock | [
"A",
"general",
"perpose",
"Exception",
"that",
"can",
"wrap",
"another",
"exception",
".",
"It",
"is",
"common",
"practice",
"in",
"BioJava",
"to",
"throw",
"a",
"NestedException",
"or",
"a",
"subclass",
"of",
"it",
"when",
"something",
"goes",
"wrong",
".",
"The",
"exception",
"can",
"be",
"used",
"to",
"catch",
"another",
"throwable",
"thus",
"keeping",
"a",
"complete",
"record",
"of",
"where",
"the",
"original",
"error",
"originated",
"while",
"adding",
"annotation",
"to",
"the",
"stack",
"-",
"trace",
".",
"It",
"also",
"affords",
"a",
"neat",
"way",
"to",
"avoid",
"exception",
"-",
"bloat",
"on",
"method",
"calls",
"particularly",
"when",
"objects",
"are",
"composed",
"from",
"several",
"objects",
"from",
"different",
"packages",
".",
"@author",
"Matthew",
"Pocock"
] | public class NestedException extends Exception {
private Throwable subThrowable = null;
public NestedException(String message) {
super(message);
}
public NestedException(Throwable ex) {
this.subThrowable = ex;
}
public NestedException(Throwable ex, String message) {
super(message);
this.subThrowable = ex;
}
public NestedException() {
super();
}
public Throwable getSubThrowable() {
return subThrowable;
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream ps) {
printStackTrace(new PrintWriter(ps));
}
public void printStackTrace(PrintWriter pw) {
if (subThrowable != null) {
StringWriter sw1 = new StringWriter();
subThrowable.printStackTrace(new PrintWriter(sw1));
String mes1 = sw1.toString();
StringWriter sw2 = new StringWriter();
super.printStackTrace(new PrintWriter(sw2));
String mes2 = sw2.toString();
try {
Vector lines1 = lineSplit(new BufferedReader(new StringReader(mes1)));
Vector lines2 = lineSplit(new BufferedReader(new StringReader(mes2)));
int shortLength = lines1.size();
if (lines2.size() < shortLength)
shortLength = lines2.size();
Vector removeThese = new Vector();
for(int i=0; i < shortLength; i++) {
Object s1 = lines1.elementAt(lines1.size() - 1 - i);
Object s2 = lines2.elementAt(lines2.size() - 1 - i);
if (s1.equals(s2))
removeThese.addElement(s1);
else
break;
}
for(int i=0; i < removeThese.size(); i++)
lines1.removeElement(removeThese.elementAt(i));
for(int i=0; i < lines1.size(); i++) {
System.out.println(lines1.elementAt(i));
}
/*
ListIterator li1 = lines1.listIterator(lines1.size());
ListIterator li2 = lines2.listIterator(lines2.size());
while(li1.hasPrevious() && li2.hasPrevious()) {
Object s1 = li1.previous();
Object s2 = li2.previous();
if(s1.equals(s2)) {
li1.remove();
} else {
break;
}
}
for(Iterator i = lines1.iterator(); i.hasNext(); ) {
System.out.println(i.next());
}
*/
pw.print("rethrown as ");
pw.print(mes2);
} catch (IOException ioe) {
throw new Error("Coudn't merge stack-traces");
}
} else {
super.printStackTrace(pw);
}
pw.flush();
}
private Vector lineSplit(BufferedReader in) throws IOException {
Vector lines = new Vector();
for(String line = in.readLine(); line != null; line = in.readLine()) {
lines.addElement(line);
}
return lines;
}
} | [
"public",
"class",
"NestedException",
"extends",
"Exception",
"{",
"private",
"Throwable",
"subThrowable",
"=",
"null",
";",
"public",
"NestedException",
"(",
"String",
"message",
")",
"{",
"super",
"(",
"message",
")",
";",
"}",
"public",
"NestedException",
"(",
"Throwable",
"ex",
")",
"{",
"this",
".",
"subThrowable",
"=",
"ex",
";",
"}",
"public",
"NestedException",
"(",
"Throwable",
"ex",
",",
"String",
"message",
")",
"{",
"super",
"(",
"message",
")",
";",
"this",
".",
"subThrowable",
"=",
"ex",
";",
"}",
"public",
"NestedException",
"(",
")",
"{",
"super",
"(",
")",
";",
"}",
"public",
"Throwable",
"getSubThrowable",
"(",
")",
"{",
"return",
"subThrowable",
";",
"}",
"public",
"void",
"printStackTrace",
"(",
")",
"{",
"printStackTrace",
"(",
"System",
".",
"err",
")",
";",
"}",
"public",
"void",
"printStackTrace",
"(",
"PrintStream",
"ps",
")",
"{",
"printStackTrace",
"(",
"new",
"PrintWriter",
"(",
"ps",
")",
")",
";",
"}",
"public",
"void",
"printStackTrace",
"(",
"PrintWriter",
"pw",
")",
"{",
"if",
"(",
"subThrowable",
"!=",
"null",
")",
"{",
"StringWriter",
"sw1",
"=",
"new",
"StringWriter",
"(",
")",
";",
"subThrowable",
".",
"printStackTrace",
"(",
"new",
"PrintWriter",
"(",
"sw1",
")",
")",
";",
"String",
"mes1",
"=",
"sw1",
".",
"toString",
"(",
")",
";",
"StringWriter",
"sw2",
"=",
"new",
"StringWriter",
"(",
")",
";",
"super",
".",
"printStackTrace",
"(",
"new",
"PrintWriter",
"(",
"sw2",
")",
")",
";",
"String",
"mes2",
"=",
"sw2",
".",
"toString",
"(",
")",
";",
"try",
"{",
"Vector",
"lines1",
"=",
"lineSplit",
"(",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"mes1",
")",
")",
")",
";",
"Vector",
"lines2",
"=",
"lineSplit",
"(",
"new",
"BufferedReader",
"(",
"new",
"StringReader",
"(",
"mes2",
")",
")",
")",
";",
"int",
"shortLength",
"=",
"lines1",
".",
"size",
"(",
")",
";",
"if",
"(",
"lines2",
".",
"size",
"(",
")",
"<",
"shortLength",
")",
"shortLength",
"=",
"lines2",
".",
"size",
"(",
")",
";",
"Vector",
"removeThese",
"=",
"new",
"Vector",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"shortLength",
";",
"i",
"++",
")",
"{",
"Object",
"s1",
"=",
"lines1",
".",
"elementAt",
"(",
"lines1",
".",
"size",
"(",
")",
"-",
"1",
"-",
"i",
")",
";",
"Object",
"s2",
"=",
"lines2",
".",
"elementAt",
"(",
"lines2",
".",
"size",
"(",
")",
"-",
"1",
"-",
"i",
")",
";",
"if",
"(",
"s1",
".",
"equals",
"(",
"s2",
")",
")",
"removeThese",
".",
"addElement",
"(",
"s1",
")",
";",
"else",
"break",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"removeThese",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"lines1",
".",
"removeElement",
"(",
"removeThese",
".",
"elementAt",
"(",
"i",
")",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"lines1",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"lines1",
".",
"elementAt",
"(",
"i",
")",
")",
";",
"}",
"/* \n ListIterator li1 = lines1.listIterator(lines1.size());\n ListIterator li2 = lines2.listIterator(lines2.size());\n \n while(li1.hasPrevious() && li2.hasPrevious()) {\n Object s1 = li1.previous();\n Object s2 = li2.previous();\n \n if(s1.equals(s2)) {\n li1.remove();\n } else {\n break;\n }\n }\n for(Iterator i = lines1.iterator(); i.hasNext(); ) {\n System.out.println(i.next());\n }\n\t*/",
"pw",
".",
"print",
"(",
"\"",
"rethrown as ",
"\"",
")",
";",
"pw",
".",
"print",
"(",
"mes2",
")",
";",
"}",
"catch",
"(",
"IOException",
"ioe",
")",
"{",
"throw",
"new",
"Error",
"(",
"\"",
"Coudn't merge stack-traces",
"\"",
")",
";",
"}",
"}",
"else",
"{",
"super",
".",
"printStackTrace",
"(",
"pw",
")",
";",
"}",
"pw",
".",
"flush",
"(",
")",
";",
"}",
"private",
"Vector",
"lineSplit",
"(",
"BufferedReader",
"in",
")",
"throws",
"IOException",
"{",
"Vector",
"lines",
"=",
"new",
"Vector",
"(",
")",
";",
"for",
"(",
"String",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
";",
"line",
"!=",
"null",
";",
"line",
"=",
"in",
".",
"readLine",
"(",
")",
")",
"{",
"lines",
".",
"addElement",
"(",
"line",
")",
";",
"}",
"return",
"lines",
";",
"}",
"}"
] | A general perpose Exception that can wrap another exception. | [
"A",
"general",
"perpose",
"Exception",
"that",
"can",
"wrap",
"another",
"exception",
"."
] | [] | [
{
"param": "Exception",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Exception",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
077a199add99741bd8f4be80fa1db22f7d294810 | simplicitesoftware/android-api | src/com/simplicite/android/core/ListOfValues.java | [
"Apache-2.0"
] | Java | ListOfValues | /**
* <p>List of values</p>
*/ | List of values | [
"List",
"of",
"values"
] | public class ListOfValues implements Serializable {
private static final long serialVersionUID = 1L;
/**
* <p>Constructor</p>
* @param name Name
*/
public ListOfValues(String name) {
items = new ArrayList<ListOfValues.Item>();
}
/**
* <p>Logical name</p>
*/
public String name;
/**
* <p>List items</p>
*/
public ArrayList<Item> items;
public class Item {
/**
* <p>List of values item code</p>
*/
public String code;
/**
* <p>List of values item value</p>
*/
public String value;
/**
* <p>List of values item enabled ?</p>
*/
public boolean enabled;
/**
* <p>String representation</p>
*/
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("\tCode: " + code + "\n");
s.append("\tValue: " + value + "\n");
s.append("\tEnabled: " + enabled + "\n");
return s.toString();
}
}
/**
* <p>String representation</p>
*/
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("Name: " + name + "\n");
s.append("Items:\n");
for (Item item : items) {
s.append(item.toString());
}
return s.toString();
}
} | [
"public",
"class",
"ListOfValues",
"implements",
"Serializable",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"/**\r\n\t * <p>Constructor</p>\r\n\t * @param name Name\r\n\t */",
"public",
"ListOfValues",
"(",
"String",
"name",
")",
"{",
"items",
"=",
"new",
"ArrayList",
"<",
"ListOfValues",
".",
"Item",
">",
"(",
")",
";",
"}",
"/**\r\n\t * <p>Logical name</p>\r\n\t */",
"public",
"String",
"name",
";",
"/**\r\n\t * <p>List items</p>\r\n\t */",
"public",
"ArrayList",
"<",
"Item",
">",
"items",
";",
"public",
"class",
"Item",
"{",
"/**\r\n\t\t * <p>List of values item code</p>\r\n\t\t */",
"public",
"String",
"code",
";",
"/**\r\n\t\t * <p>List of values item value</p>\r\n\t\t */",
"public",
"String",
"value",
";",
"/**\r\n\t\t * <p>List of values item enabled ?</p>\r\n\t\t */",
"public",
"boolean",
"enabled",
";",
"/**\r\n\t\t * <p>String representation</p>\r\n\t\t */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"s",
".",
"append",
"(",
"\"",
"\\t",
"Code: ",
"\"",
"+",
"code",
"+",
"\"",
"\\n",
"\"",
")",
";",
"s",
".",
"append",
"(",
"\"",
"\\t",
"Value: ",
"\"",
"+",
"value",
"+",
"\"",
"\\n",
"\"",
")",
";",
"s",
".",
"append",
"(",
"\"",
"\\t",
"Enabled: ",
"\"",
"+",
"enabled",
"+",
"\"",
"\\n",
"\"",
")",
";",
"return",
"s",
".",
"toString",
"(",
")",
";",
"}",
"}",
"/**\r\n\t * <p>String representation</p>\r\n\t */",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"StringBuilder",
"s",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"s",
".",
"append",
"(",
"\"",
"Name: ",
"\"",
"+",
"name",
"+",
"\"",
"\\n",
"\"",
")",
";",
"s",
".",
"append",
"(",
"\"",
"Items:",
"\\n",
"\"",
")",
";",
"for",
"(",
"Item",
"item",
":",
"items",
")",
"{",
"s",
".",
"append",
"(",
"item",
".",
"toString",
"(",
")",
")",
";",
"}",
"return",
"s",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | <p>List of values</p> | [
"<p",
">",
"List",
"of",
"values<",
"/",
"p",
">"
] | [] | [
{
"param": "Serializable",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Serializable",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
077b05883a520e61c8841bd17be1ca278cd4e6ef | ZaraTech/ps-15-e06-ztd1 | src/com/zaratech/smarket/aplicacion/ListaProductos.java | [
"MIT"
] | Java | ListaProductos | /**
* Activity que gestiona el listado de productos principal.
*
* @author Juan
*/ | Activity que gestiona el listado de productos principal.
@author Juan | [
"Activity",
"que",
"gestiona",
"el",
"listado",
"de",
"productos",
"principal",
".",
"@author",
"Juan"
] | public class ListaProductos extends ListActivity implements Listado{
/**
* Guarda la ultima posicion en la que se quedo el listado
*/
private int ultimaPosicion;
/**
* Guarda el ultimo orden seleccionado
*/
private Orden ultimoOrden = new Orden(
AdaptadorBD.DB_ORDENACION_NOMBRE,
AdaptadorBD.DB_ORDENACION_ASC);
/**
* Constante que hace referencia a la activity InfoProducto. Se usara para
* identificar de donde se vuelve (startActivityForResult)
*/
private final int ACTIVITY_INFO = 0;
/**
* Constante que hace referencia a la activity EdicionProducto. Se usara
* para identificar de donde se vuelve (startActivityForResult)
*/
private final int ACTIVITY_EDICION = 1;
/**
* Constante que hace referencia a la activity IniciarSesion. Se usara
* para identificar de donde se vuelve (startActivityForResult)
*/
private final int ACTIVITY_INICIAR_SESION = 2;
/**
* Constantes que hacen referencias a elementos del menu contextual
*/
private final int EDITAR_PRODUCTO = 0;
private final int ELIMINAR_PRODUCTO = 1;
/**
* Clave que identifica un Producto dentro del campo extras del Intent
*/
private final String EXTRA_PRODUCTO = "Producto";
/**
* Conexion con la BD
*/
private AdaptadorBD bd;
/**
* Estado de sesion administrador
*/
private static boolean admin = false;
public void cargarListado() {
CargadorAsincrono ca = new CargadorAsincrono(this, bd, ultimoOrden);
ca.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);
}
public void cargarListadoAsincrono(List<Producto> productos){
AdaptadorProductos adaptador = new AdaptadorProductos(this, productos);
setListAdapter(adaptador);
setSelection(ultimaPosicion - 2);
}
// INICIO de la aplicacion
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lista_productos);
// Obtener BD
bd = new AdaptadorBD(this);
bd.open();
cargarListado();
// Separador personalizado de elementos de listado
int[] colors = { 0, 0xFFFFFFFF, 0 };
getListView().setDivider(
new GradientDrawable(Orientation.RIGHT_LEFT, colors));
getListView().setDividerHeight(2);
// Hack para Barra de Acciones
// Simula que no hay boton de menu aunque si que lo haya
// Fuerza mostrar opciones de menu en Barra de Acciones
try {
ViewConfiguration config = ViewConfiguration.get(this);
Field menuKeyField = ViewConfiguration.class
.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null) {
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config, false);
}
} catch (Exception ex) {
// Ignorar
}
/*
* Ordenacion
*/
Spinner ordenar = (Spinner) findViewById(R.id.listar_ordenar);
String[] ordenacion = new String[BusquedaProducto.NOMBRES_ORDENACION.length];
for (int i = 0; i < BusquedaProducto.NOMBRES_ORDENACION.length; i++) {
ordenacion[i] = getString(BusquedaProducto.NOMBRES_ORDENACION[i]);
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, ordenacion);
ordenar.setAdapter(adapter);
ordenar.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
if (position >= 0 && position < BusquedaProducto.ORDEN.length) {
ultimoOrden = BusquedaProducto.ORDEN[position];
cargarListado();
}
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
@Override
protected void onDestroy() {
if(bd.isSincronizacionRemotaPeriodica()){
bd.unSetSincronizacionRemotaPeriodica();
}
bd.close();
super.onDestroy();
}
// REANUDAR Activity
@Override
protected void onResume() {
// SINCRONIZACION REMOTA
EditorConfiguracion configuracion = new EditorConfiguracion(this);
// CONFIG: ACTIVAR BD REMOTA
if(!configuracion.usoBDLocal()){
bd.setSincronizacionRemota();
if(!configuracion.sincBDManual() && !bd.isSincronizacionRemotaPeriodica()){
bd.setSincronizacionRemotaPeriodica();
bd.initSincronizacionRemotaPeriodica();
} else if (configuracion.sincBDManual()) {
bd.unSetSincronizacionRemotaPeriodica();
}
// CONFIG: DESACTIVAR BD REMOTA (si procede)
} else {
if(bd.isSincronizacionRemota()){
if(bd.isSincronizacionRemotaPeriodica()){
bd.unSetSincronizacionRemotaPeriodica();
}
bd.unSetSincronizacionRemota();
}
}
super.onResume();
}
// CLICK en Producto del listado
@Override
protected void onListItemClick(ListView l, View v, int posicion, long id) {
super.onListItemClick(l, v, posicion, id);
ultimaPosicion = posicion;
Intent i = new Intent(this, InfoProducto.class);
// Añade Producto seleccionado
Producto p = (Producto) getListAdapter().getItem(posicion);
i.putExtra(EXTRA_PRODUCTO, p);
startActivityForResult(i, ACTIVITY_INFO);
}
// VUELTA de activity con RESULTADO
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent intent) {
super.onActivityResult(requestCode, resultCode, intent);
// INFO
if (requestCode == ACTIVITY_INFO) {
}
// EDICION
else if (requestCode == ACTIVITY_EDICION) {
cargarListado();
}
// INICIAR SESIÓN
else if (requestCode == ACTIVITY_INICIAR_SESION) {
if (resultCode == IniciarSesion.INICIAR_SESION_OK) {
admin = true;
invalidateOptionsMenu();
registerForContextMenu(getListView());
}
}
}
// MENU DE OPCIONES
@Override
public boolean onCreateOptionsMenu(Menu menu) {
if (admin) {
getMenuInflater().inflate(R.menu.activity_lista_productos_admin,
menu);
} else {
getMenuInflater().inflate(R.menu.activity_lista_productos, menu);
}
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
// AÑADIR
if (id == R.id.lista_menu_add) {
Intent i = new Intent(this, EdicionProducto.class);
startActivityForResult(i, ACTIVITY_EDICION);
return true;
// BUSCAR
} else if (id == R.id.lista_menu_busqueda) {
Intent i = new Intent(this, BusquedaProducto.class);
// Añade Producto seleccionado
i.putExtra(BusquedaProducto.EXTRA_ADMIN, admin);
startActivity(i);
return true;
// INICIAR SESIÓN
} else if (id == R.id.lista_menu_iniciar_sesion) {
Intent i = new Intent(this, IniciarSesion.class);
startActivityForResult(i, ACTIVITY_INICIAR_SESION);
return true;
// CONFIGURACIÓN
} else if (id == R.id.lista_menu_configuracion) {
startActivity(new Intent(this, EditarConfiguracion.class));
return true;
// ACTUALIZAR
} else if (id == R.id.lista_menu_actualizar) {
Toast.makeText(this, getString(R.string.lista_actualizar), Toast.LENGTH_SHORT).show();
if(bd.isSincronizacionRemota()){
bd.pullRemoto();
} else {
cargarListado();
}
return true;
// CERRAR SESIÓN
} else if (id == R.id.lista_menu_cerrar_sesion) {
admin = false;
invalidateOptionsMenu();
unregisterForContextMenu(getListView());
Toast.makeText(this, getString(R.string.sesion_mensaje_cerrar), Toast.LENGTH_SHORT).show();
return true;
// ???
} else {
return super.onOptionsItemSelected(item);
}
}
// MENU CONTEXTUAL
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, EDITAR_PRODUCTO, 0, R.string.lista_menu_editar);
menu.add(1, ELIMINAR_PRODUCTO, 1, R.string.lista_menu_eliminar);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = null;
// Identifica el Producto seleccionado
info = (AdapterContextMenuInfo) item.getMenuInfo();
Producto p = (Producto) getListAdapter().getItem(info.position);
// Guarda posicion
ultimaPosicion = info.position;
// EDITAR
if (item.getItemId() == EDITAR_PRODUCTO) {
Intent i = new Intent(this, EdicionProducto.class);
// Añade Producto seleccionado
i.putExtra(EXTRA_PRODUCTO, p);
startActivityForResult(i, ACTIVITY_EDICION);
// ELIMINAR
} else if (item.getItemId() == ELIMINAR_PRODUCTO) {
bd.borrarProducto(p.getId());
cargarListado();
}
return super.onContextItemSelected(item);
}
} | [
"public",
"class",
"ListaProductos",
"extends",
"ListActivity",
"implements",
"Listado",
"{",
"/**\r\n\t * Guarda la ultima posicion en la que se quedo el listado\r\n\t */",
"private",
"int",
"ultimaPosicion",
";",
"/**\r\n\t * Guarda el ultimo orden seleccionado\r\n\t */",
"private",
"Orden",
"ultimoOrden",
"=",
"new",
"Orden",
"(",
"AdaptadorBD",
".",
"DB_ORDENACION_NOMBRE",
",",
"AdaptadorBD",
".",
"DB_ORDENACION_ASC",
")",
";",
"/**\r\n\t * Constante que hace referencia a la activity InfoProducto. Se usara para\r\n\t * identificar de donde se vuelve (startActivityForResult)\r\n\t */",
"private",
"final",
"int",
"ACTIVITY_INFO",
"=",
"0",
";",
"/**\r\n\t * Constante que hace referencia a la activity EdicionProducto. Se usara\r\n\t * para identificar de donde se vuelve (startActivityForResult)\r\n\t */",
"private",
"final",
"int",
"ACTIVITY_EDICION",
"=",
"1",
";",
"/**\r\n\t * Constante que hace referencia a la activity IniciarSesion. Se usara\r\n\t * para identificar de donde se vuelve (startActivityForResult)\r\n\t */",
"private",
"final",
"int",
"ACTIVITY_INICIAR_SESION",
"=",
"2",
";",
"/**\r\n\t * Constantes que hacen referencias a elementos del menu contextual\r\n\t */",
"private",
"final",
"int",
"EDITAR_PRODUCTO",
"=",
"0",
";",
"private",
"final",
"int",
"ELIMINAR_PRODUCTO",
"=",
"1",
";",
"/**\r\n\t * Clave que identifica un Producto dentro del campo extras del Intent\r\n\t */",
"private",
"final",
"String",
"EXTRA_PRODUCTO",
"=",
"\"",
"Producto",
"\"",
";",
"/**\r\n\t * Conexion con la BD\r\n\t */",
"private",
"AdaptadorBD",
"bd",
";",
"/**\r\n\t * Estado de sesion administrador\r\n\t */",
"private",
"static",
"boolean",
"admin",
"=",
"false",
";",
"public",
"void",
"cargarListado",
"(",
")",
"{",
"CargadorAsincrono",
"ca",
"=",
"new",
"CargadorAsincrono",
"(",
"this",
",",
"bd",
",",
"ultimoOrden",
")",
";",
"ca",
".",
"executeOnExecutor",
"(",
"AsyncTask",
".",
"THREAD_POOL_EXECUTOR",
",",
"(",
"Void",
"[",
"]",
")",
"null",
")",
";",
"}",
"public",
"void",
"cargarListadoAsincrono",
"(",
"List",
"<",
"Producto",
">",
"productos",
")",
"{",
"AdaptadorProductos",
"adaptador",
"=",
"new",
"AdaptadorProductos",
"(",
"this",
",",
"productos",
")",
";",
"setListAdapter",
"(",
"adaptador",
")",
";",
"setSelection",
"(",
"ultimaPosicion",
"-",
"2",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onCreate",
"(",
"Bundle",
"savedInstanceState",
")",
"{",
"super",
".",
"onCreate",
"(",
"savedInstanceState",
")",
";",
"setContentView",
"(",
"R",
".",
"layout",
".",
"activity_lista_productos",
")",
";",
"bd",
"=",
"new",
"AdaptadorBD",
"(",
"this",
")",
";",
"bd",
".",
"open",
"(",
")",
";",
"cargarListado",
"(",
")",
";",
"int",
"[",
"]",
"colors",
"=",
"{",
"0",
",",
"0xFFFFFFFF",
",",
"0",
"}",
";",
"getListView",
"(",
")",
".",
"setDivider",
"(",
"new",
"GradientDrawable",
"(",
"Orientation",
".",
"RIGHT_LEFT",
",",
"colors",
")",
")",
";",
"getListView",
"(",
")",
".",
"setDividerHeight",
"(",
"2",
")",
";",
"try",
"{",
"ViewConfiguration",
"config",
"=",
"ViewConfiguration",
".",
"get",
"(",
"this",
")",
";",
"Field",
"menuKeyField",
"=",
"ViewConfiguration",
".",
"class",
".",
"getDeclaredField",
"(",
"\"",
"sHasPermanentMenuKey",
"\"",
")",
";",
"if",
"(",
"menuKeyField",
"!=",
"null",
")",
"{",
"menuKeyField",
".",
"setAccessible",
"(",
"true",
")",
";",
"menuKeyField",
".",
"setBoolean",
"(",
"config",
",",
"false",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"}",
"/*\r\n\t\t * Ordenacion\r\n\t\t */",
"Spinner",
"ordenar",
"=",
"(",
"Spinner",
")",
"findViewById",
"(",
"R",
".",
"id",
".",
"listar_ordenar",
")",
";",
"String",
"[",
"]",
"ordenacion",
"=",
"new",
"String",
"[",
"BusquedaProducto",
".",
"NOMBRES_ORDENACION",
".",
"length",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"BusquedaProducto",
".",
"NOMBRES_ORDENACION",
".",
"length",
";",
"i",
"++",
")",
"{",
"ordenacion",
"[",
"i",
"]",
"=",
"getString",
"(",
"BusquedaProducto",
".",
"NOMBRES_ORDENACION",
"[",
"i",
"]",
")",
";",
"}",
"ArrayAdapter",
"<",
"String",
">",
"adapter",
"=",
"new",
"ArrayAdapter",
"<",
"String",
">",
"(",
"this",
",",
"android",
".",
"R",
".",
"layout",
".",
"simple_list_item_1",
",",
"ordenacion",
")",
";",
"ordenar",
".",
"setAdapter",
"(",
"adapter",
")",
";",
"ordenar",
".",
"setOnItemSelectedListener",
"(",
"new",
"OnItemSelectedListener",
"(",
")",
"{",
"public",
"void",
"onItemSelected",
"(",
"AdapterView",
"<",
"?",
">",
"parent",
",",
"View",
"view",
",",
"int",
"position",
",",
"long",
"id",
")",
"{",
"if",
"(",
"position",
">=",
"0",
"&&",
"position",
"<",
"BusquedaProducto",
".",
"ORDEN",
".",
"length",
")",
"{",
"ultimoOrden",
"=",
"BusquedaProducto",
".",
"ORDEN",
"[",
"position",
"]",
";",
"cargarListado",
"(",
")",
";",
"}",
"}",
"public",
"void",
"onNothingSelected",
"(",
"AdapterView",
"<",
"?",
">",
"parent",
")",
"{",
"}",
"}",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onDestroy",
"(",
")",
"{",
"if",
"(",
"bd",
".",
"isSincronizacionRemotaPeriodica",
"(",
")",
")",
"{",
"bd",
".",
"unSetSincronizacionRemotaPeriodica",
"(",
")",
";",
"}",
"bd",
".",
"close",
"(",
")",
";",
"super",
".",
"onDestroy",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onResume",
"(",
")",
"{",
"EditorConfiguracion",
"configuracion",
"=",
"new",
"EditorConfiguracion",
"(",
"this",
")",
";",
"if",
"(",
"!",
"configuracion",
".",
"usoBDLocal",
"(",
")",
")",
"{",
"bd",
".",
"setSincronizacionRemota",
"(",
")",
";",
"if",
"(",
"!",
"configuracion",
".",
"sincBDManual",
"(",
")",
"&&",
"!",
"bd",
".",
"isSincronizacionRemotaPeriodica",
"(",
")",
")",
"{",
"bd",
".",
"setSincronizacionRemotaPeriodica",
"(",
")",
";",
"bd",
".",
"initSincronizacionRemotaPeriodica",
"(",
")",
";",
"}",
"else",
"if",
"(",
"configuracion",
".",
"sincBDManual",
"(",
")",
")",
"{",
"bd",
".",
"unSetSincronizacionRemotaPeriodica",
"(",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"bd",
".",
"isSincronizacionRemota",
"(",
")",
")",
"{",
"if",
"(",
"bd",
".",
"isSincronizacionRemotaPeriodica",
"(",
")",
")",
"{",
"bd",
".",
"unSetSincronizacionRemotaPeriodica",
"(",
")",
";",
"}",
"bd",
".",
"unSetSincronizacionRemota",
"(",
")",
";",
"}",
"}",
"super",
".",
"onResume",
"(",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onListItemClick",
"(",
"ListView",
"l",
",",
"View",
"v",
",",
"int",
"posicion",
",",
"long",
"id",
")",
"{",
"super",
".",
"onListItemClick",
"(",
"l",
",",
"v",
",",
"posicion",
",",
"id",
")",
";",
"ultimaPosicion",
"=",
"posicion",
";",
"Intent",
"i",
"=",
"new",
"Intent",
"(",
"this",
",",
"InfoProducto",
".",
"class",
")",
";",
"Producto",
"p",
"=",
"(",
"Producto",
")",
"getListAdapter",
"(",
")",
".",
"getItem",
"(",
"posicion",
")",
";",
"i",
".",
"putExtra",
"(",
"EXTRA_PRODUCTO",
",",
"p",
")",
";",
"startActivityForResult",
"(",
"i",
",",
"ACTIVITY_INFO",
")",
";",
"}",
"@",
"Override",
"protected",
"void",
"onActivityResult",
"(",
"int",
"requestCode",
",",
"int",
"resultCode",
",",
"Intent",
"intent",
")",
"{",
"super",
".",
"onActivityResult",
"(",
"requestCode",
",",
"resultCode",
",",
"intent",
")",
";",
"if",
"(",
"requestCode",
"==",
"ACTIVITY_INFO",
")",
"{",
"}",
"else",
"if",
"(",
"requestCode",
"==",
"ACTIVITY_EDICION",
")",
"{",
"cargarListado",
"(",
")",
";",
"}",
"else",
"if",
"(",
"requestCode",
"==",
"ACTIVITY_INICIAR_SESION",
")",
"{",
"if",
"(",
"resultCode",
"==",
"IniciarSesion",
".",
"INICIAR_SESION_OK",
")",
"{",
"admin",
"=",
"true",
";",
"invalidateOptionsMenu",
"(",
")",
";",
"registerForContextMenu",
"(",
"getListView",
"(",
")",
")",
";",
"}",
"}",
"}",
"@",
"Override",
"public",
"boolean",
"onCreateOptionsMenu",
"(",
"Menu",
"menu",
")",
"{",
"if",
"(",
"admin",
")",
"{",
"getMenuInflater",
"(",
")",
".",
"inflate",
"(",
"R",
".",
"menu",
".",
"activity_lista_productos_admin",
",",
"menu",
")",
";",
"}",
"else",
"{",
"getMenuInflater",
"(",
")",
".",
"inflate",
"(",
"R",
".",
"menu",
".",
"activity_lista_productos",
",",
"menu",
")",
";",
"}",
"return",
"true",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onOptionsItemSelected",
"(",
"MenuItem",
"item",
")",
"{",
"int",
"id",
"=",
"item",
".",
"getItemId",
"(",
")",
";",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_add",
")",
"{",
"Intent",
"i",
"=",
"new",
"Intent",
"(",
"this",
",",
"EdicionProducto",
".",
"class",
")",
";",
"startActivityForResult",
"(",
"i",
",",
"ACTIVITY_EDICION",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_busqueda",
")",
"{",
"Intent",
"i",
"=",
"new",
"Intent",
"(",
"this",
",",
"BusquedaProducto",
".",
"class",
")",
";",
"i",
".",
"putExtra",
"(",
"BusquedaProducto",
".",
"EXTRA_ADMIN",
",",
"admin",
")",
";",
"startActivity",
"(",
"i",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_iniciar_sesion",
")",
"{",
"Intent",
"i",
"=",
"new",
"Intent",
"(",
"this",
",",
"IniciarSesion",
".",
"class",
")",
";",
"startActivityForResult",
"(",
"i",
",",
"ACTIVITY_INICIAR_SESION",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_configuracion",
")",
"{",
"startActivity",
"(",
"new",
"Intent",
"(",
"this",
",",
"EditarConfiguracion",
".",
"class",
")",
")",
";",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_actualizar",
")",
"{",
"Toast",
".",
"makeText",
"(",
"this",
",",
"getString",
"(",
"R",
".",
"string",
".",
"lista_actualizar",
")",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"if",
"(",
"bd",
".",
"isSincronizacionRemota",
"(",
")",
")",
"{",
"bd",
".",
"pullRemoto",
"(",
")",
";",
"}",
"else",
"{",
"cargarListado",
"(",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"if",
"(",
"id",
"==",
"R",
".",
"id",
".",
"lista_menu_cerrar_sesion",
")",
"{",
"admin",
"=",
"false",
";",
"invalidateOptionsMenu",
"(",
")",
";",
"unregisterForContextMenu",
"(",
"getListView",
"(",
")",
")",
";",
"Toast",
".",
"makeText",
"(",
"this",
",",
"getString",
"(",
"R",
".",
"string",
".",
"sesion_mensaje_cerrar",
")",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"super",
".",
"onOptionsItemSelected",
"(",
"item",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"void",
"onCreateContextMenu",
"(",
"ContextMenu",
"menu",
",",
"View",
"v",
",",
"ContextMenuInfo",
"menuInfo",
")",
"{",
"super",
".",
"onCreateContextMenu",
"(",
"menu",
",",
"v",
",",
"menuInfo",
")",
";",
"menu",
".",
"add",
"(",
"0",
",",
"EDITAR_PRODUCTO",
",",
"0",
",",
"R",
".",
"string",
".",
"lista_menu_editar",
")",
";",
"menu",
".",
"add",
"(",
"1",
",",
"ELIMINAR_PRODUCTO",
",",
"1",
",",
"R",
".",
"string",
".",
"lista_menu_eliminar",
")",
";",
"}",
"@",
"Override",
"public",
"boolean",
"onContextItemSelected",
"(",
"MenuItem",
"item",
")",
"{",
"AdapterContextMenuInfo",
"info",
"=",
"null",
";",
"info",
"=",
"(",
"AdapterContextMenuInfo",
")",
"item",
".",
"getMenuInfo",
"(",
")",
";",
"Producto",
"p",
"=",
"(",
"Producto",
")",
"getListAdapter",
"(",
")",
".",
"getItem",
"(",
"info",
".",
"position",
")",
";",
"ultimaPosicion",
"=",
"info",
".",
"position",
";",
"if",
"(",
"item",
".",
"getItemId",
"(",
")",
"==",
"EDITAR_PRODUCTO",
")",
"{",
"Intent",
"i",
"=",
"new",
"Intent",
"(",
"this",
",",
"EdicionProducto",
".",
"class",
")",
";",
"i",
".",
"putExtra",
"(",
"EXTRA_PRODUCTO",
",",
"p",
")",
";",
"startActivityForResult",
"(",
"i",
",",
"ACTIVITY_EDICION",
")",
";",
"}",
"else",
"if",
"(",
"item",
".",
"getItemId",
"(",
")",
"==",
"ELIMINAR_PRODUCTO",
")",
"{",
"bd",
".",
"borrarProducto",
"(",
"p",
".",
"getId",
"(",
")",
")",
";",
"cargarListado",
"(",
")",
";",
"}",
"return",
"super",
".",
"onContextItemSelected",
"(",
"item",
")",
";",
"}",
"}"
] | Activity que gestiona el listado de productos principal. | [
"Activity",
"que",
"gestiona",
"el",
"listado",
"de",
"productos",
"principal",
"."
] | [
"// INICIO de la aplicacion\r",
"// Obtener BD\r",
"// Separador personalizado de elementos de listado\r",
"// Hack para Barra de Acciones\r",
"// Simula que no hay boton de menu aunque si que lo haya\r",
"// Fuerza mostrar opciones de menu en Barra de Acciones\r",
"// Ignorar\r",
"// REANUDAR Activity\r",
"// SINCRONIZACION REMOTA\r",
"// CONFIG: ACTIVAR BD REMOTA\r",
"// CONFIG: DESACTIVAR BD REMOTA (si procede)\r",
"// CLICK en Producto del listado\r",
"// Añade Producto seleccionado\r",
"// VUELTA de activity con RESULTADO\r",
"// INFO\r",
"// EDICION\r",
"// INICIAR SESIÓN\r",
"// MENU DE OPCIONES\r",
"// AÑADIR\r",
"// BUSCAR\r",
"// Añade Producto seleccionado\r",
"// INICIAR SESIÓN\r",
"// CONFIGURACIÓN\r",
"// ACTUALIZAR\r",
"// CERRAR SESIÓN\r",
"// ???\r",
"// MENU CONTEXTUAL\r",
"// Identifica el Producto seleccionado\r",
"// Guarda posicion\r",
"// EDITAR\r",
"// Añade Producto seleccionado\r",
"// ELIMINAR\r"
] | [
{
"param": "ListActivity",
"type": null
},
{
"param": "Listado",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ListActivity",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Listado",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
843deba822a543bbb03babe779acf9ddddfe43cb | rnarla123/aliyun-openapi-java-sdk | aliyun-java-sdk-hbr/src/main/java/com/aliyuncs/hbr/model/v20170908/DescribeRestoresRequest.java | [
"Apache-2.0"
] | Java | DescribeRestoresRequest | /**
* @author auto create
* @version
*/ | @author auto create
@version | [
"@author",
"auto",
"create",
"@version"
] | public class DescribeRestoresRequest extends RpcAcsRequest<DescribeRestoresResponse> {
private String clientId;
private String snapshotId;
private String vaultId;
private String source;
private Integer pageNumber;
private Integer pageSize;
private String restoreId;
private String serverId;
private String token;
private String target;
private String restoreType;
private String containerRestoreId;
private String status;
public DescribeRestoresRequest() {
super("hbr", "2017-09-08", "DescribeRestores", "hbr");
setProtocol(ProtocolType.HTTPS);
setMethod(MethodType.POST);
try {
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap);
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType);
} catch (Exception e) {}
}
public String getClientId() {
return this.clientId;
}
public void setClientId(String clientId) {
this.clientId = clientId;
if(clientId != null){
putQueryParameter("ClientId", clientId);
}
}
public String getSnapshotId() {
return this.snapshotId;
}
public void setSnapshotId(String snapshotId) {
this.snapshotId = snapshotId;
if(snapshotId != null){
putQueryParameter("SnapshotId", snapshotId);
}
}
public String getVaultId() {
return this.vaultId;
}
public void setVaultId(String vaultId) {
this.vaultId = vaultId;
if(vaultId != null){
putQueryParameter("VaultId", vaultId);
}
}
public String getSource() {
return this.source;
}
public void setSource(String source) {
this.source = source;
if(source != null){
putQueryParameter("Source", source);
}
}
public Integer getPageNumber() {
return this.pageNumber;
}
public void setPageNumber(Integer pageNumber) {
this.pageNumber = pageNumber;
if(pageNumber != null){
putQueryParameter("PageNumber", pageNumber.toString());
}
}
public Integer getPageSize() {
return this.pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
if(pageSize != null){
putQueryParameter("PageSize", pageSize.toString());
}
}
public String getRestoreId() {
return this.restoreId;
}
public void setRestoreId(String restoreId) {
this.restoreId = restoreId;
if(restoreId != null){
putQueryParameter("RestoreId", restoreId);
}
}
public String getServerId() {
return this.serverId;
}
public void setServerId(String serverId) {
this.serverId = serverId;
if(serverId != null){
putQueryParameter("ServerId", serverId);
}
}
public String getToken() {
return this.token;
}
public void setToken(String token) {
this.token = token;
if(token != null){
putQueryParameter("Token", token);
}
}
public String getTarget() {
return this.target;
}
public void setTarget(String target) {
this.target = target;
if(target != null){
putQueryParameter("Target", target);
}
}
public String getRestoreType() {
return this.restoreType;
}
public void setRestoreType(String restoreType) {
this.restoreType = restoreType;
if(restoreType != null){
putQueryParameter("RestoreType", restoreType);
}
}
public String getContainerRestoreId() {
return this.containerRestoreId;
}
public void setContainerRestoreId(String containerRestoreId) {
this.containerRestoreId = containerRestoreId;
if(containerRestoreId != null){
putQueryParameter("ContainerRestoreId", containerRestoreId);
}
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
if(status != null){
putQueryParameter("Status", status);
}
}
@Override
public Class<DescribeRestoresResponse> getResponseClass() {
return DescribeRestoresResponse.class;
}
} | [
"public",
"class",
"DescribeRestoresRequest",
"extends",
"RpcAcsRequest",
"<",
"DescribeRestoresResponse",
">",
"{",
"private",
"String",
"clientId",
";",
"private",
"String",
"snapshotId",
";",
"private",
"String",
"vaultId",
";",
"private",
"String",
"source",
";",
"private",
"Integer",
"pageNumber",
";",
"private",
"Integer",
"pageSize",
";",
"private",
"String",
"restoreId",
";",
"private",
"String",
"serverId",
";",
"private",
"String",
"token",
";",
"private",
"String",
"target",
";",
"private",
"String",
"restoreType",
";",
"private",
"String",
"containerRestoreId",
";",
"private",
"String",
"status",
";",
"public",
"DescribeRestoresRequest",
"(",
")",
"{",
"super",
"(",
"\"",
"hbr",
"\"",
",",
"\"",
"2017-09-08",
"\"",
",",
"\"",
"DescribeRestores",
"\"",
",",
"\"",
"hbr",
"\"",
")",
";",
"setProtocol",
"(",
"ProtocolType",
".",
"HTTPS",
")",
";",
"setMethod",
"(",
"MethodType",
".",
"POST",
")",
";",
"try",
"{",
"com",
".",
"aliyuncs",
".",
"AcsRequest",
".",
"class",
".",
"getDeclaredField",
"(",
"\"",
"productEndpointMap",
"\"",
")",
".",
"set",
"(",
"this",
",",
"Endpoint",
".",
"endpointMap",
")",
";",
"com",
".",
"aliyuncs",
".",
"AcsRequest",
".",
"class",
".",
"getDeclaredField",
"(",
"\"",
"productEndpointRegional",
"\"",
")",
".",
"set",
"(",
"this",
",",
"Endpoint",
".",
"endpointRegionalType",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"}",
"}",
"public",
"String",
"getClientId",
"(",
")",
"{",
"return",
"this",
".",
"clientId",
";",
"}",
"public",
"void",
"setClientId",
"(",
"String",
"clientId",
")",
"{",
"this",
".",
"clientId",
"=",
"clientId",
";",
"if",
"(",
"clientId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"ClientId",
"\"",
",",
"clientId",
")",
";",
"}",
"}",
"public",
"String",
"getSnapshotId",
"(",
")",
"{",
"return",
"this",
".",
"snapshotId",
";",
"}",
"public",
"void",
"setSnapshotId",
"(",
"String",
"snapshotId",
")",
"{",
"this",
".",
"snapshotId",
"=",
"snapshotId",
";",
"if",
"(",
"snapshotId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"SnapshotId",
"\"",
",",
"snapshotId",
")",
";",
"}",
"}",
"public",
"String",
"getVaultId",
"(",
")",
"{",
"return",
"this",
".",
"vaultId",
";",
"}",
"public",
"void",
"setVaultId",
"(",
"String",
"vaultId",
")",
"{",
"this",
".",
"vaultId",
"=",
"vaultId",
";",
"if",
"(",
"vaultId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"VaultId",
"\"",
",",
"vaultId",
")",
";",
"}",
"}",
"public",
"String",
"getSource",
"(",
")",
"{",
"return",
"this",
".",
"source",
";",
"}",
"public",
"void",
"setSource",
"(",
"String",
"source",
")",
"{",
"this",
".",
"source",
"=",
"source",
";",
"if",
"(",
"source",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"Source",
"\"",
",",
"source",
")",
";",
"}",
"}",
"public",
"Integer",
"getPageNumber",
"(",
")",
"{",
"return",
"this",
".",
"pageNumber",
";",
"}",
"public",
"void",
"setPageNumber",
"(",
"Integer",
"pageNumber",
")",
"{",
"this",
".",
"pageNumber",
"=",
"pageNumber",
";",
"if",
"(",
"pageNumber",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"PageNumber",
"\"",
",",
"pageNumber",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"public",
"Integer",
"getPageSize",
"(",
")",
"{",
"return",
"this",
".",
"pageSize",
";",
"}",
"public",
"void",
"setPageSize",
"(",
"Integer",
"pageSize",
")",
"{",
"this",
".",
"pageSize",
"=",
"pageSize",
";",
"if",
"(",
"pageSize",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"PageSize",
"\"",
",",
"pageSize",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"public",
"String",
"getRestoreId",
"(",
")",
"{",
"return",
"this",
".",
"restoreId",
";",
"}",
"public",
"void",
"setRestoreId",
"(",
"String",
"restoreId",
")",
"{",
"this",
".",
"restoreId",
"=",
"restoreId",
";",
"if",
"(",
"restoreId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"RestoreId",
"\"",
",",
"restoreId",
")",
";",
"}",
"}",
"public",
"String",
"getServerId",
"(",
")",
"{",
"return",
"this",
".",
"serverId",
";",
"}",
"public",
"void",
"setServerId",
"(",
"String",
"serverId",
")",
"{",
"this",
".",
"serverId",
"=",
"serverId",
";",
"if",
"(",
"serverId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"ServerId",
"\"",
",",
"serverId",
")",
";",
"}",
"}",
"public",
"String",
"getToken",
"(",
")",
"{",
"return",
"this",
".",
"token",
";",
"}",
"public",
"void",
"setToken",
"(",
"String",
"token",
")",
"{",
"this",
".",
"token",
"=",
"token",
";",
"if",
"(",
"token",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"Token",
"\"",
",",
"token",
")",
";",
"}",
"}",
"public",
"String",
"getTarget",
"(",
")",
"{",
"return",
"this",
".",
"target",
";",
"}",
"public",
"void",
"setTarget",
"(",
"String",
"target",
")",
"{",
"this",
".",
"target",
"=",
"target",
";",
"if",
"(",
"target",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"Target",
"\"",
",",
"target",
")",
";",
"}",
"}",
"public",
"String",
"getRestoreType",
"(",
")",
"{",
"return",
"this",
".",
"restoreType",
";",
"}",
"public",
"void",
"setRestoreType",
"(",
"String",
"restoreType",
")",
"{",
"this",
".",
"restoreType",
"=",
"restoreType",
";",
"if",
"(",
"restoreType",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"RestoreType",
"\"",
",",
"restoreType",
")",
";",
"}",
"}",
"public",
"String",
"getContainerRestoreId",
"(",
")",
"{",
"return",
"this",
".",
"containerRestoreId",
";",
"}",
"public",
"void",
"setContainerRestoreId",
"(",
"String",
"containerRestoreId",
")",
"{",
"this",
".",
"containerRestoreId",
"=",
"containerRestoreId",
";",
"if",
"(",
"containerRestoreId",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"ContainerRestoreId",
"\"",
",",
"containerRestoreId",
")",
";",
"}",
"}",
"public",
"String",
"getStatus",
"(",
")",
"{",
"return",
"this",
".",
"status",
";",
"}",
"public",
"void",
"setStatus",
"(",
"String",
"status",
")",
"{",
"this",
".",
"status",
"=",
"status",
";",
"if",
"(",
"status",
"!=",
"null",
")",
"{",
"putQueryParameter",
"(",
"\"",
"Status",
"\"",
",",
"status",
")",
";",
"}",
"}",
"@",
"Override",
"public",
"Class",
"<",
"DescribeRestoresResponse",
">",
"getResponseClass",
"(",
")",
"{",
"return",
"DescribeRestoresResponse",
".",
"class",
";",
"}",
"}"
] | @author auto create
@version | [
"@author",
"auto",
"create",
"@version"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
84422eff61abbe7ac9d4e32ac3b7c510026bdbd3 | xresch/CoreFramework_ExtensionExample | src/main/java/com/xresch/cfw/example/formsmulti/ServletMultiFormsExamples.java | [
"MIT"
] | Java | ServletMultiFormsExamples | /**************************************************************************************************************
*
* @author Reto Scheiwiller, (c) Copyright 2020
**************************************************************************************************************/ | @author Reto Scheiwiller, (c) Copyright 2020 | [
"@author",
"Reto",
"Scheiwiller",
"(",
"c",
")",
"Copyright",
"2020"
] | public class ServletMultiFormsExamples extends HttpServlet
{
private static final long serialVersionUID = 1L;
public ServletMultiFormsExamples() {
}
/******************************************************************
*
******************************************************************/
@Override
protected void doGet( HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException
{
HTMLResponse html = new HTMLResponse("Javascript Examples");
if(CFW.Context.Request.hasPermission(ExampleExtensionApplication.PERMISSION_CFWSAMPLES)) {
String action = request.getParameter("action");
if(action == null) {
html.addJSFileBottom(HandlingType.JAR_RESOURCE, FeatureMultiFormExamples.RESOURCE_PACKAGE, "multiform_examples.js");
html.addJavascriptCode("multiformexamples_initialDraw();");
response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
}else {
handleDataRequest(request, response);
}
}else {
CFWMessages.accessDenied();
}
}
/******************************************************************
*
******************************************************************/
private void handleDataRequest(HttpServletRequest request, HttpServletResponse response) {
String action = request.getParameter("action");
String item = request.getParameter("item");
//int userID = CFW.Context.Request.getUser().id();
JSONResponse jsonResponse = new JSONResponse();
switch(action.toLowerCase()) {
case "getform":
switch(item.toLowerCase()) {
case "basicmultiform": createMultiForm(jsonResponse);
break;
default: CFW.Messages.itemNotSupported(item);
break;
}
break;
default: CFW.Messages.actionNotSupported(action);
break;
}
}
/******************************************************************
*
******************************************************************/
private void createMultiForm(JSONResponse json) {
ArrayList<CFWObject> personList = new CFWSQL(new Person())
.select()
.limit(15)
.getAsObjectList();
if(personList.size() != 0) {
CFWMultiForm editPersonForm = new CFWMultiForm("cfwMultiFormExample"+CFW.Random.randomStringAlphaNumerical(12), "Save", personList);
editPersonForm.setMultiFormHandler(new CFWMultiFormHandlerDefault());
editPersonForm.appendToPayload(json);
json.setSuccess(true);
}
}
} | [
"public",
"class",
"ServletMultiFormsExamples",
"extends",
"HttpServlet",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"1L",
";",
"public",
"ServletMultiFormsExamples",
"(",
")",
"{",
"}",
"/******************************************************************\n\t *\n\t ******************************************************************/",
"@",
"Override",
"protected",
"void",
"doGet",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"HTMLResponse",
"html",
"=",
"new",
"HTMLResponse",
"(",
"\"",
"Javascript Examples",
"\"",
")",
";",
"if",
"(",
"CFW",
".",
"Context",
".",
"Request",
".",
"hasPermission",
"(",
"ExampleExtensionApplication",
".",
"PERMISSION_CFWSAMPLES",
")",
")",
"{",
"String",
"action",
"=",
"request",
".",
"getParameter",
"(",
"\"",
"action",
"\"",
")",
";",
"if",
"(",
"action",
"==",
"null",
")",
"{",
"html",
".",
"addJSFileBottom",
"(",
"HandlingType",
".",
"JAR_RESOURCE",
",",
"FeatureMultiFormExamples",
".",
"RESOURCE_PACKAGE",
",",
"\"",
"multiform_examples.js",
"\"",
")",
";",
"html",
".",
"addJavascriptCode",
"(",
"\"",
"multiformexamples_initialDraw();",
"\"",
")",
";",
"response",
".",
"setContentType",
"(",
"\"",
"text/html",
"\"",
")",
";",
"response",
".",
"setStatus",
"(",
"HttpServletResponse",
".",
"SC_OK",
")",
";",
"}",
"else",
"{",
"handleDataRequest",
"(",
"request",
",",
"response",
")",
";",
"}",
"}",
"else",
"{",
"CFWMessages",
".",
"accessDenied",
"(",
")",
";",
"}",
"}",
"/******************************************************************\n\t *\n\t ******************************************************************/",
"private",
"void",
"handleDataRequest",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"{",
"String",
"action",
"=",
"request",
".",
"getParameter",
"(",
"\"",
"action",
"\"",
")",
";",
"String",
"item",
"=",
"request",
".",
"getParameter",
"(",
"\"",
"item",
"\"",
")",
";",
"JSONResponse",
"jsonResponse",
"=",
"new",
"JSONResponse",
"(",
")",
";",
"switch",
"(",
"action",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"\"",
"getform",
"\"",
":",
"switch",
"(",
"item",
".",
"toLowerCase",
"(",
")",
")",
"{",
"case",
"\"",
"basicmultiform",
"\"",
":",
"createMultiForm",
"(",
"jsonResponse",
")",
";",
"break",
";",
"default",
":",
"CFW",
".",
"Messages",
".",
"itemNotSupported",
"(",
"item",
")",
";",
"break",
";",
"}",
"break",
";",
"default",
":",
"CFW",
".",
"Messages",
".",
"actionNotSupported",
"(",
"action",
")",
";",
"break",
";",
"}",
"}",
"/******************************************************************\n\t *\n\t ******************************************************************/",
"private",
"void",
"createMultiForm",
"(",
"JSONResponse",
"json",
")",
"{",
"ArrayList",
"<",
"CFWObject",
">",
"personList",
"=",
"new",
"CFWSQL",
"(",
"new",
"Person",
"(",
")",
")",
".",
"select",
"(",
")",
".",
"limit",
"(",
"15",
")",
".",
"getAsObjectList",
"(",
")",
";",
"if",
"(",
"personList",
".",
"size",
"(",
")",
"!=",
"0",
")",
"{",
"CFWMultiForm",
"editPersonForm",
"=",
"new",
"CFWMultiForm",
"(",
"\"",
"cfwMultiFormExample",
"\"",
"+",
"CFW",
".",
"Random",
".",
"randomStringAlphaNumerical",
"(",
"12",
")",
",",
"\"",
"Save",
"\"",
",",
"personList",
")",
";",
"editPersonForm",
".",
"setMultiFormHandler",
"(",
"new",
"CFWMultiFormHandlerDefault",
"(",
")",
")",
";",
"editPersonForm",
".",
"appendToPayload",
"(",
"json",
")",
";",
"json",
".",
"setSuccess",
"(",
"true",
")",
";",
"}",
"}",
"}"
] | @author Reto Scheiwiller, (c) Copyright 2020 | [
"@author",
"Reto",
"Scheiwiller",
"(",
"c",
")",
"Copyright",
"2020"
] | [
"//int\tuserID = CFW.Context.Request.getUser().id();"
] | [
{
"param": "HttpServlet",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "HttpServlet",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8442bba0d89826b61c9617d91d6995e72abb2fcf | sclaridge/arcgis-runtime-samples-java | ogc/wmts-layer/src/main/java/com/esri/samples/wmts_layer/WmtsLayerLauncher.java | [
"Apache-2.0"
] | Java | WmtsLayerLauncher | /**
* Wrapper required for launching a JavaFX 11 app through Gradle or from a jar.
*/ | Wrapper required for launching a JavaFX 11 app through Gradle or from a jar. | [
"Wrapper",
"required",
"for",
"launching",
"a",
"JavaFX",
"11",
"app",
"through",
"Gradle",
"or",
"from",
"a",
"jar",
"."
] | public class WmtsLayerLauncher {
public static void main(String[] args) {
WmtsLayerSample.main(args);
}
} | [
"public",
"class",
"WmtsLayerLauncher",
"{",
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"WmtsLayerSample",
".",
"main",
"(",
"args",
")",
";",
"}",
"}"
] | Wrapper required for launching a JavaFX 11 app through Gradle or from a jar. | [
"Wrapper",
"required",
"for",
"launching",
"a",
"JavaFX",
"11",
"app",
"through",
"Gradle",
"or",
"from",
"a",
"jar",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8444ed8a3743ce78bb0cf139cedba85543aa1d63 | smarthi/vespa | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/Upgrader.java | [
"Apache-2.0"
] | Java | Upgrader | /**
* Maintenance job which schedules applications for Vespa version upgrade
*
* @author bratseth
* @author mpolden
*/ | Maintenance job which schedules applications for Vespa version upgrade
@author bratseth
@author mpolden | [
"Maintenance",
"job",
"which",
"schedules",
"applications",
"for",
"Vespa",
"version",
"upgrade",
"@author",
"bratseth",
"@author",
"mpolden"
] | public class Upgrader extends ControllerMaintainer {
private static final Logger log = Logger.getLogger(Upgrader.class.getName());
private final CuratorDb curator;
private final Random random;
public Upgrader(Controller controller, Duration interval) {
super(controller, interval);
this.curator = controller.curator();
this.random = new Random(controller.clock().instant().toEpochMilli()); // Seed with clock for test determinism
}
/**
* Schedule application upgrades. Note that this implementation must be idempotent.
*/
@Override
public double maintain() {
// Determine target versions for each upgrade policy
VersionStatus versionStatus = controller().readVersionStatus();
cancelBrokenUpgrades(versionStatus);
Optional<Integer> targetMajorVersion = targetMajorVersion();
InstanceList instances = instances(controller().systemVersion(versionStatus));
for (UpgradePolicy policy : UpgradePolicy.values())
updateTargets(versionStatus, instances, policy, targetMajorVersion);
return 1.0;
}
/** Returns a list of all production application instances, except those which are pinned, which we should not manipulate here. */
private InstanceList instances(Version systemVersion) {
return InstanceList.from(controller().jobController().deploymentStatuses(ApplicationList.from(controller().applications().readable()), systemVersion))
.withDeclaredJobs()
.shuffle(random)
.byIncreasingDeployedVersion()
.unpinned();
}
private void cancelBrokenUpgrades(VersionStatus versionStatus) {
// Cancel upgrades to broken targets (let other ongoing upgrades complete to avoid starvation)
InstanceList instances = instances(controller().systemVersion(versionStatus));
for (VespaVersion version : versionStatus.versions()) {
if (version.confidence() == Confidence.broken)
cancelUpgradesOf(instances.upgradingTo(version.versionNumber()).not().with(UpgradePolicy.canary),
version.versionNumber() + " is broken");
}
}
private void updateTargets(VersionStatus versionStatus, InstanceList instances, UpgradePolicy policy, Optional<Integer> targetMajorVersion) {
InstanceList remaining = instances.with(policy);
List<Version> targetAndNewer = new ArrayList<>();
UnaryOperator<InstanceList> cancellationCriterion = policy == UpgradePolicy.canary ? i -> i.not().upgradingTo(targetAndNewer)
: i -> i.failing()
.not().upgradingTo(targetAndNewer);
Map<ApplicationId, Version> targets = new LinkedHashMap<>();
for (Version version : targetsForPolicy(versionStatus, policy)) {
targetAndNewer.add(version);
InstanceList eligible = eligibleForVersion(remaining, version, cancellationCriterion, targetMajorVersion);
InstanceList outdated = cancellationCriterion.apply(eligible);
cancelUpgradesOf(outdated.upgrading(), "Upgrading to outdated versions");
// Prefer the newest target for each instance.
remaining = remaining.not().matching(eligible.asList()::contains);
for (ApplicationId id : outdated.and(eligible.not().upgrading()).not().changingRevision())
targets.put(id, version);
}
int numberToUpgrade = policy == UpgradePolicy.canary ? instances.size() : numberOfApplicationsToUpgrade();
for (ApplicationId id : instances.matching(targets.keySet()::contains).first(numberToUpgrade)) {
log.log(Level.INFO, "Triggering upgrade to " + targets.get(id) + " for " + id);
controller().applications().deploymentTrigger().triggerChange(id, Change.of(targets.get(id)));
}
}
/** Returns target versions for given confidence, by descending version number. */
private List<Version> targetsForPolicy(VersionStatus versions, UpgradePolicy policy) {
Version systemVersion = controller().systemVersion(versions);
if (policy == UpgradePolicy.canary)
return List.of(systemVersion);
Confidence target = policy == UpgradePolicy.defaultPolicy ? Confidence.normal : Confidence.high;
return versions.versions().stream()
.filter(version -> ! version.versionNumber().isAfter(systemVersion)
&& version.confidence().equalOrHigherThan(target))
.map(VespaVersion::versionNumber)
.sorted(reverseOrder())
.collect(Collectors.toList());
}
private InstanceList eligibleForVersion(InstanceList instances, Version version, UnaryOperator<InstanceList> cancellationCriterion, Optional<Integer> targetMajorVersion) {
Change change = Change.of(version);
return instances.not().failingOn(version)
.allowMajorVersion(version.getMajor(), targetMajorVersion.orElse(version.getMajor()))
.not().hasCompleted(change) // Avoid rescheduling change for instances without production steps.
.onLowerVersionThan(version)
.canUpgradeAt(version, controller().clock().instant());
}
private void cancelUpgradesOf(InstanceList instances, String reason) {
instances = instances.unpinned();
if (instances.isEmpty()) return;
log.info("Cancelling upgrading of " + instances.asList() + " instances: " + reason);
for (ApplicationId instance : instances.asList())
controller().applications().deploymentTrigger().cancelChange(instance, PLATFORM);
}
/** Returns the number of applications to upgrade in this run */
private int numberOfApplicationsToUpgrade() {
return numberOfApplicationsToUpgrade(interval().dividedBy(Math.max(1, controller().curator().cluster().size())).toMillis(),
controller().clock().millis(),
upgradesPerMinute());
}
/** Returns the number of applications to upgrade in the interval containing now */
static int numberOfApplicationsToUpgrade(long intervalMillis, long nowMillis, double upgradesPerMinute) {
long intervalStart = Math.round(nowMillis / (double) intervalMillis) * intervalMillis;
double upgradesPerMilli = upgradesPerMinute / 60_000;
long upgradesAtStart = (long) (intervalStart * upgradesPerMilli);
long upgradesAtEnd = (long) ((intervalStart + intervalMillis) * upgradesPerMilli);
return (int) (upgradesAtEnd - upgradesAtStart);
}
/** Returns number of upgrades per minute */
public double upgradesPerMinute() {
return curator.readUpgradesPerMinute();
}
/** Sets the number of upgrades per minute */
public void setUpgradesPerMinute(double n) {
if (n < 0)
throw new IllegalArgumentException("Upgrades per minute must be >= 0, got " + n);
curator.writeUpgradesPerMinute(n);
}
/** Returns the target major version for applications not specifying one */
public Optional<Integer> targetMajorVersion() {
return curator.readTargetMajorVersion();
}
/** Sets the default target major version. Set to empty to determine target version normally (by confidence) */
public void setTargetMajorVersion(Optional<Integer> targetMajorVersion) {
curator.writeTargetMajorVersion(targetMajorVersion);
}
/** Override confidence for given version. This will cause the computed confidence to be ignored */
public void overrideConfidence(Version version, Confidence confidence) {
if (confidence == Confidence.aborted && !version.isAfter(controller().readSystemVersion())) {
throw new IllegalArgumentException("Cannot override confidence to " + confidence +
" for version " + version.toFullString() +
": Version may be in use by applications");
}
try (Lock lock = curator.lockConfidenceOverrides()) {
Map<Version, Confidence> overrides = new LinkedHashMap<>(curator.readConfidenceOverrides());
overrides.put(version, confidence);
curator.writeConfidenceOverrides(overrides);
}
}
/** Returns all confidence overrides */
public Map<Version, Confidence> confidenceOverrides() {
return curator.readConfidenceOverrides();
}
/** Remove confidence override for given version */
public void removeConfidenceOverride(Version version) {
controller().removeConfidenceOverride(version::equals);
}
} | [
"public",
"class",
"Upgrader",
"extends",
"ControllerMaintainer",
"{",
"private",
"static",
"final",
"Logger",
"log",
"=",
"Logger",
".",
"getLogger",
"(",
"Upgrader",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"private",
"final",
"CuratorDb",
"curator",
";",
"private",
"final",
"Random",
"random",
";",
"public",
"Upgrader",
"(",
"Controller",
"controller",
",",
"Duration",
"interval",
")",
"{",
"super",
"(",
"controller",
",",
"interval",
")",
";",
"this",
".",
"curator",
"=",
"controller",
".",
"curator",
"(",
")",
";",
"this",
".",
"random",
"=",
"new",
"Random",
"(",
"controller",
".",
"clock",
"(",
")",
".",
"instant",
"(",
")",
".",
"toEpochMilli",
"(",
")",
")",
";",
"}",
"/**\n * Schedule application upgrades. Note that this implementation must be idempotent.\n */",
"@",
"Override",
"public",
"double",
"maintain",
"(",
")",
"{",
"VersionStatus",
"versionStatus",
"=",
"controller",
"(",
")",
".",
"readVersionStatus",
"(",
")",
";",
"cancelBrokenUpgrades",
"(",
"versionStatus",
")",
";",
"Optional",
"<",
"Integer",
">",
"targetMajorVersion",
"=",
"targetMajorVersion",
"(",
")",
";",
"InstanceList",
"instances",
"=",
"instances",
"(",
"controller",
"(",
")",
".",
"systemVersion",
"(",
"versionStatus",
")",
")",
";",
"for",
"(",
"UpgradePolicy",
"policy",
":",
"UpgradePolicy",
".",
"values",
"(",
")",
")",
"updateTargets",
"(",
"versionStatus",
",",
"instances",
",",
"policy",
",",
"targetMajorVersion",
")",
";",
"return",
"1.0",
";",
"}",
"/** Returns a list of all production application instances, except those which are pinned, which we should not manipulate here. */",
"private",
"InstanceList",
"instances",
"(",
"Version",
"systemVersion",
")",
"{",
"return",
"InstanceList",
".",
"from",
"(",
"controller",
"(",
")",
".",
"jobController",
"(",
")",
".",
"deploymentStatuses",
"(",
"ApplicationList",
".",
"from",
"(",
"controller",
"(",
")",
".",
"applications",
"(",
")",
".",
"readable",
"(",
")",
")",
",",
"systemVersion",
")",
")",
".",
"withDeclaredJobs",
"(",
")",
".",
"shuffle",
"(",
"random",
")",
".",
"byIncreasingDeployedVersion",
"(",
")",
".",
"unpinned",
"(",
")",
";",
"}",
"private",
"void",
"cancelBrokenUpgrades",
"(",
"VersionStatus",
"versionStatus",
")",
"{",
"InstanceList",
"instances",
"=",
"instances",
"(",
"controller",
"(",
")",
".",
"systemVersion",
"(",
"versionStatus",
")",
")",
";",
"for",
"(",
"VespaVersion",
"version",
":",
"versionStatus",
".",
"versions",
"(",
")",
")",
"{",
"if",
"(",
"version",
".",
"confidence",
"(",
")",
"==",
"Confidence",
".",
"broken",
")",
"cancelUpgradesOf",
"(",
"instances",
".",
"upgradingTo",
"(",
"version",
".",
"versionNumber",
"(",
")",
")",
".",
"not",
"(",
")",
".",
"with",
"(",
"UpgradePolicy",
".",
"canary",
")",
",",
"version",
".",
"versionNumber",
"(",
")",
"+",
"\"",
" is broken",
"\"",
")",
";",
"}",
"}",
"private",
"void",
"updateTargets",
"(",
"VersionStatus",
"versionStatus",
",",
"InstanceList",
"instances",
",",
"UpgradePolicy",
"policy",
",",
"Optional",
"<",
"Integer",
">",
"targetMajorVersion",
")",
"{",
"InstanceList",
"remaining",
"=",
"instances",
".",
"with",
"(",
"policy",
")",
";",
"List",
"<",
"Version",
">",
"targetAndNewer",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"UnaryOperator",
"<",
"InstanceList",
">",
"cancellationCriterion",
"=",
"policy",
"==",
"UpgradePolicy",
".",
"canary",
"?",
"i",
"->",
"i",
".",
"not",
"(",
")",
".",
"upgradingTo",
"(",
"targetAndNewer",
")",
":",
"i",
"->",
"i",
".",
"failing",
"(",
")",
".",
"not",
"(",
")",
".",
"upgradingTo",
"(",
"targetAndNewer",
")",
";",
"Map",
"<",
"ApplicationId",
",",
"Version",
">",
"targets",
"=",
"new",
"LinkedHashMap",
"<",
">",
"(",
")",
";",
"for",
"(",
"Version",
"version",
":",
"targetsForPolicy",
"(",
"versionStatus",
",",
"policy",
")",
")",
"{",
"targetAndNewer",
".",
"add",
"(",
"version",
")",
";",
"InstanceList",
"eligible",
"=",
"eligibleForVersion",
"(",
"remaining",
",",
"version",
",",
"cancellationCriterion",
",",
"targetMajorVersion",
")",
";",
"InstanceList",
"outdated",
"=",
"cancellationCriterion",
".",
"apply",
"(",
"eligible",
")",
";",
"cancelUpgradesOf",
"(",
"outdated",
".",
"upgrading",
"(",
")",
",",
"\"",
"Upgrading to outdated versions",
"\"",
")",
";",
"remaining",
"=",
"remaining",
".",
"not",
"(",
")",
".",
"matching",
"(",
"eligible",
".",
"asList",
"(",
")",
"::",
"contains",
")",
";",
"for",
"(",
"ApplicationId",
"id",
":",
"outdated",
".",
"and",
"(",
"eligible",
".",
"not",
"(",
")",
".",
"upgrading",
"(",
")",
")",
".",
"not",
"(",
")",
".",
"changingRevision",
"(",
")",
")",
"targets",
".",
"put",
"(",
"id",
",",
"version",
")",
";",
"}",
"int",
"numberToUpgrade",
"=",
"policy",
"==",
"UpgradePolicy",
".",
"canary",
"?",
"instances",
".",
"size",
"(",
")",
":",
"numberOfApplicationsToUpgrade",
"(",
")",
";",
"for",
"(",
"ApplicationId",
"id",
":",
"instances",
".",
"matching",
"(",
"targets",
".",
"keySet",
"(",
")",
"::",
"contains",
")",
".",
"first",
"(",
"numberToUpgrade",
")",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"INFO",
",",
"\"",
"Triggering upgrade to ",
"\"",
"+",
"targets",
".",
"get",
"(",
"id",
")",
"+",
"\"",
" for ",
"\"",
"+",
"id",
")",
";",
"controller",
"(",
")",
".",
"applications",
"(",
")",
".",
"deploymentTrigger",
"(",
")",
".",
"triggerChange",
"(",
"id",
",",
"Change",
".",
"of",
"(",
"targets",
".",
"get",
"(",
"id",
")",
")",
")",
";",
"}",
"}",
"/** Returns target versions for given confidence, by descending version number. */",
"private",
"List",
"<",
"Version",
">",
"targetsForPolicy",
"(",
"VersionStatus",
"versions",
",",
"UpgradePolicy",
"policy",
")",
"{",
"Version",
"systemVersion",
"=",
"controller",
"(",
")",
".",
"systemVersion",
"(",
"versions",
")",
";",
"if",
"(",
"policy",
"==",
"UpgradePolicy",
".",
"canary",
")",
"return",
"List",
".",
"of",
"(",
"systemVersion",
")",
";",
"Confidence",
"target",
"=",
"policy",
"==",
"UpgradePolicy",
".",
"defaultPolicy",
"?",
"Confidence",
".",
"normal",
":",
"Confidence",
".",
"high",
";",
"return",
"versions",
".",
"versions",
"(",
")",
".",
"stream",
"(",
")",
".",
"filter",
"(",
"version",
"->",
"!",
"version",
".",
"versionNumber",
"(",
")",
".",
"isAfter",
"(",
"systemVersion",
")",
"&&",
"version",
".",
"confidence",
"(",
")",
".",
"equalOrHigherThan",
"(",
"target",
")",
")",
".",
"map",
"(",
"VespaVersion",
"::",
"versionNumber",
")",
".",
"sorted",
"(",
"reverseOrder",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}",
"private",
"InstanceList",
"eligibleForVersion",
"(",
"InstanceList",
"instances",
",",
"Version",
"version",
",",
"UnaryOperator",
"<",
"InstanceList",
">",
"cancellationCriterion",
",",
"Optional",
"<",
"Integer",
">",
"targetMajorVersion",
")",
"{",
"Change",
"change",
"=",
"Change",
".",
"of",
"(",
"version",
")",
";",
"return",
"instances",
".",
"not",
"(",
")",
".",
"failingOn",
"(",
"version",
")",
".",
"allowMajorVersion",
"(",
"version",
".",
"getMajor",
"(",
")",
",",
"targetMajorVersion",
".",
"orElse",
"(",
"version",
".",
"getMajor",
"(",
")",
")",
")",
".",
"not",
"(",
")",
".",
"hasCompleted",
"(",
"change",
")",
".",
"onLowerVersionThan",
"(",
"version",
")",
".",
"canUpgradeAt",
"(",
"version",
",",
"controller",
"(",
")",
".",
"clock",
"(",
")",
".",
"instant",
"(",
")",
")",
";",
"}",
"private",
"void",
"cancelUpgradesOf",
"(",
"InstanceList",
"instances",
",",
"String",
"reason",
")",
"{",
"instances",
"=",
"instances",
".",
"unpinned",
"(",
")",
";",
"if",
"(",
"instances",
".",
"isEmpty",
"(",
")",
")",
"return",
";",
"log",
".",
"info",
"(",
"\"",
"Cancelling upgrading of ",
"\"",
"+",
"instances",
".",
"asList",
"(",
")",
"+",
"\"",
" instances: ",
"\"",
"+",
"reason",
")",
";",
"for",
"(",
"ApplicationId",
"instance",
":",
"instances",
".",
"asList",
"(",
")",
")",
"controller",
"(",
")",
".",
"applications",
"(",
")",
".",
"deploymentTrigger",
"(",
")",
".",
"cancelChange",
"(",
"instance",
",",
"PLATFORM",
")",
";",
"}",
"/** Returns the number of applications to upgrade in this run */",
"private",
"int",
"numberOfApplicationsToUpgrade",
"(",
")",
"{",
"return",
"numberOfApplicationsToUpgrade",
"(",
"interval",
"(",
")",
".",
"dividedBy",
"(",
"Math",
".",
"max",
"(",
"1",
",",
"controller",
"(",
")",
".",
"curator",
"(",
")",
".",
"cluster",
"(",
")",
".",
"size",
"(",
")",
")",
")",
".",
"toMillis",
"(",
")",
",",
"controller",
"(",
")",
".",
"clock",
"(",
")",
".",
"millis",
"(",
")",
",",
"upgradesPerMinute",
"(",
")",
")",
";",
"}",
"/** Returns the number of applications to upgrade in the interval containing now */",
"static",
"int",
"numberOfApplicationsToUpgrade",
"(",
"long",
"intervalMillis",
",",
"long",
"nowMillis",
",",
"double",
"upgradesPerMinute",
")",
"{",
"long",
"intervalStart",
"=",
"Math",
".",
"round",
"(",
"nowMillis",
"/",
"(",
"double",
")",
"intervalMillis",
")",
"*",
"intervalMillis",
";",
"double",
"upgradesPerMilli",
"=",
"upgradesPerMinute",
"/",
"60_000",
";",
"long",
"upgradesAtStart",
"=",
"(",
"long",
")",
"(",
"intervalStart",
"*",
"upgradesPerMilli",
")",
";",
"long",
"upgradesAtEnd",
"=",
"(",
"long",
")",
"(",
"(",
"intervalStart",
"+",
"intervalMillis",
")",
"*",
"upgradesPerMilli",
")",
";",
"return",
"(",
"int",
")",
"(",
"upgradesAtEnd",
"-",
"upgradesAtStart",
")",
";",
"}",
"/** Returns number of upgrades per minute */",
"public",
"double",
"upgradesPerMinute",
"(",
")",
"{",
"return",
"curator",
".",
"readUpgradesPerMinute",
"(",
")",
";",
"}",
"/** Sets the number of upgrades per minute */",
"public",
"void",
"setUpgradesPerMinute",
"(",
"double",
"n",
")",
"{",
"if",
"(",
"n",
"<",
"0",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Upgrades per minute must be >= 0, got ",
"\"",
"+",
"n",
")",
";",
"curator",
".",
"writeUpgradesPerMinute",
"(",
"n",
")",
";",
"}",
"/** Returns the target major version for applications not specifying one */",
"public",
"Optional",
"<",
"Integer",
">",
"targetMajorVersion",
"(",
")",
"{",
"return",
"curator",
".",
"readTargetMajorVersion",
"(",
")",
";",
"}",
"/** Sets the default target major version. Set to empty to determine target version normally (by confidence) */",
"public",
"void",
"setTargetMajorVersion",
"(",
"Optional",
"<",
"Integer",
">",
"targetMajorVersion",
")",
"{",
"curator",
".",
"writeTargetMajorVersion",
"(",
"targetMajorVersion",
")",
";",
"}",
"/** Override confidence for given version. This will cause the computed confidence to be ignored */",
"public",
"void",
"overrideConfidence",
"(",
"Version",
"version",
",",
"Confidence",
"confidence",
")",
"{",
"if",
"(",
"confidence",
"==",
"Confidence",
".",
"aborted",
"&&",
"!",
"version",
".",
"isAfter",
"(",
"controller",
"(",
")",
".",
"readSystemVersion",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"Cannot override confidence to ",
"\"",
"+",
"confidence",
"+",
"\"",
" for version ",
"\"",
"+",
"version",
".",
"toFullString",
"(",
")",
"+",
"\"",
": Version may be in use by applications",
"\"",
")",
";",
"}",
"try",
"(",
"Lock",
"lock",
"=",
"curator",
".",
"lockConfidenceOverrides",
"(",
")",
")",
"{",
"Map",
"<",
"Version",
",",
"Confidence",
">",
"overrides",
"=",
"new",
"LinkedHashMap",
"<",
">",
"(",
"curator",
".",
"readConfidenceOverrides",
"(",
")",
")",
";",
"overrides",
".",
"put",
"(",
"version",
",",
"confidence",
")",
";",
"curator",
".",
"writeConfidenceOverrides",
"(",
"overrides",
")",
";",
"}",
"}",
"/** Returns all confidence overrides */",
"public",
"Map",
"<",
"Version",
",",
"Confidence",
">",
"confidenceOverrides",
"(",
")",
"{",
"return",
"curator",
".",
"readConfidenceOverrides",
"(",
")",
";",
"}",
"/** Remove confidence override for given version */",
"public",
"void",
"removeConfidenceOverride",
"(",
"Version",
"version",
")",
"{",
"controller",
"(",
")",
".",
"removeConfidenceOverride",
"(",
"version",
"::",
"equals",
")",
";",
"}",
"}"
] | Maintenance job which schedules applications for Vespa version upgrade
@author bratseth
@author mpolden | [
"Maintenance",
"job",
"which",
"schedules",
"applications",
"for",
"Vespa",
"version",
"upgrade",
"@author",
"bratseth",
"@author",
"mpolden"
] | [
"// Seed with clock for test determinism",
"// Determine target versions for each upgrade policy",
"// Cancel upgrades to broken targets (let other ongoing upgrades complete to avoid starvation)",
"// Prefer the newest target for each instance.",
"// Avoid rescheduling change for instances without production steps."
] | [
{
"param": "ControllerMaintainer",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ControllerMaintainer",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8445b6000b78b2b917045b7b2d81384b45055e47 | ivanpaniagua/Poryecto-de-grado | BUSINESS/Cargar.java | [
"MIT"
] | Java | Cargar | /**
* Title: Business Services
* Description: Clases encargadas de la aplicacion o logica de negocios
* Copyright: Copyright (c) 2003
* Company: Entidad Financiera
* @author Ivan Paniagua
* @version 1.0
*/ | Business Services
Description: Clases encargadas de la aplicacion o logica de negocios
Copyright: Copyright (c) 2003
Company: Entidad Financiera
@author Ivan Paniagua
@version 1.0 | [
"Business",
"Services",
"Description",
":",
"Clases",
"encargadas",
"de",
"la",
"aplicacion",
"o",
"logica",
"de",
"negocios",
"Copyright",
":",
"Copyright",
"(",
"c",
")",
"2003",
"Company",
":",
"Entidad",
"Financiera",
"@author",
"Ivan",
"Paniagua",
"@version",
"1",
".",
"0"
] | public class Cargar extends ClassLoader
{
// These are set up in the constructor, and later
// used in the loadClass() method for decrypting the classes
private SecretKey key;
private Cipher cipher;
// Constructor: set up the objects we need for decryption
public Cargar( SecretKey key ) throws GeneralSecurityException, IOException {
this.key = key;
String algorithm = "Twofish/ECB/PKCS5Padding";
cipher = Cipher.getInstance( algorithm );
cipher.init( Cipher.DECRYPT_MODE, key);
}
// Main routine: here, we read in the key, and create
// an instance of DecryptRun, which is our custom ClassLoader.
// After we've set up the ClassLoader, we use it to
// load up an instance of the main class of the application.
// Finally, we call the main method of this class via
// the Java Reflection API
static public void main( String args[] ) throws Exception {
String keyFilename = "llave.key";//args[0];
String appName = "Borrar";//"classes/business/Borrar";//args[1];
// Read in the key
System.err.println( "[Leyendo llave]" );
byte rawKey[] = Util.leerArchivo( keyFilename );
SecretKeySpec key = new SecretKeySpec(rawKey,"Twofish");
// Create a decrypting ClassLoader
Cargar dr = new Cargar( key );
// Create an instance of the application's main class,
// loading it through the ClassLoader
System.err.println( "[DecryptRun: loading "+appName+"]" );
Class clasz = dr.mio(appName);//dr.loadClass( appName );
for (int i = 0; i < clasz.getMethods().length; i++) {
System.out.println("este un metodo" + clasz.getMethods()[i]);
}
Mio algo = (Mio)clasz.newInstance();
Usuario u= algo.getUsuario("ivan");
if ( algo == null ) {
System.out.println("la clase es nula");
}
System.out.println("es el password de mio"+u.getPassword());
/*RECIEN
Mio a = (Mio)clasz.newInstance();
Usuario uu= a.getUsuario("mio");
System.out.println("es el password de mio"+uu.getPassword());*/
// Finally, call the main() routine of this instance
// using the Reflection API
// These are the arguments to the application itself
// String realArgs[] = new String[args.length-2];
// System.arraycopy( args, 2, realArgs, 0, args.length-2 );
// Grab a reference to main()
// String proto[] = new String[1];
// Class mainArgs[] = { (new String[1]).getClass() };
// Method main = clasz.getMethod( "main", mainArgs );
//
// Create an array containing the arguments to main()
// Object argsArray[] = { realArgs };
// System.err.println( "[DecryptRun: running "+appName+".main()]" );
//
// // Call main(). We've handed execution off to the
// // application, and we're done!
// main.invoke( null, argsArray );
}
public Class mio(String name) throws Exception {
Class clasz= null;
try {
byte classData[] = Util.leerArchivo( name+".class" );
byte decryptedClassData[] = cipher.doFinal( classData );
clasz = defineClass( "business."+name, decryptedClassData,0, decryptedClassData.length );
}
catch (IOException io) {
System.out.println("Error al leer el archivo" + io);
}
catch (Exception e) {
System.out.println("Error al desencriptar o al convertir a clase el archivo" + e);
}
return clasz;
}
public Class loadClass( String name, boolean resolve ) throws ClassNotFoundException {
try {
// This will be the Class object that we create.
// Note that we call it "clasz" instead of "class"
// because "class" is a reserved word in Java
Class clasz = null;
// Obligatory step 1: if the class is already in the
// system cache, we don't need to load it again
clasz = findLoadedClass( name );
if (clasz != null)
return clasz;
// Now we get to the custom part
try {
// Read the encrypted class file
byte classData[] = Util.leerArchivo( name+".class" );
// RandomAccessFile randomaccessfile = new RandomAccessFile(getClass().getName() + ".bin", "r");
// randomaccessfile.seek(randomaccessfile.readInt() != 0xdeadfeed ? 0 : randomaccessfile.readInt());
// String s1;
if (classData != null) {
// decrypt it ...
byte decryptedClassData[] = cipher.doFinal( classData );
// ... and turn it into a class
clasz = defineClass( name+".class", decryptedClassData,0, decryptedClassData.length );
System.err.println( "[DecryptRun: decrypting class "+name+"]" );
}
} catch( FileNotFoundException fnfe ) {
// It's probably a system file, so this isn't an error
}
// Obligatory step 2: if our decryption didn't work,
// maybe the class is to be found on the filesystem, so we
// try to load it using the default ClassLoader
if (clasz == null)
clasz = findSystemClass( name );
// Obligatory step 3: if we've been asked to,
// resolve the class
if (resolve && clasz != null)
resolveClass( clasz );
// Return the class to the caller
return clasz;
} catch( IOException ie ) {
throw new ClassNotFoundException( ie.toString() );
} catch( GeneralSecurityException gse ) {
throw new ClassNotFoundException( gse.toString() );
}
}
} | [
"public",
"class",
"Cargar",
"extends",
"ClassLoader",
"{",
"private",
"SecretKey",
"key",
";",
"private",
"Cipher",
"cipher",
";",
"public",
"Cargar",
"(",
"SecretKey",
"key",
")",
"throws",
"GeneralSecurityException",
",",
"IOException",
"{",
"this",
".",
"key",
"=",
"key",
";",
"String",
"algorithm",
"=",
"\"",
"Twofish/ECB/PKCS5Padding",
"\"",
";",
"cipher",
"=",
"Cipher",
".",
"getInstance",
"(",
"algorithm",
")",
";",
"cipher",
".",
"init",
"(",
"Cipher",
".",
"DECRYPT_MODE",
",",
"key",
")",
";",
"}",
"static",
"public",
"void",
"main",
"(",
"String",
"args",
"[",
"]",
")",
"throws",
"Exception",
"{",
"String",
"keyFilename",
"=",
"\"",
"llave.key",
"\"",
";",
"String",
"appName",
"=",
"\"",
"Borrar",
"\"",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"[Leyendo llave]",
"\"",
")",
";",
"byte",
"rawKey",
"[",
"]",
"=",
"Util",
".",
"leerArchivo",
"(",
"keyFilename",
")",
";",
"SecretKeySpec",
"key",
"=",
"new",
"SecretKeySpec",
"(",
"rawKey",
",",
"\"",
"Twofish",
"\"",
")",
";",
"Cargar",
"dr",
"=",
"new",
"Cargar",
"(",
"key",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"[DecryptRun: loading ",
"\"",
"+",
"appName",
"+",
"\"",
"]",
"\"",
")",
";",
"Class",
"clasz",
"=",
"dr",
".",
"mio",
"(",
"appName",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"clasz",
".",
"getMethods",
"(",
")",
".",
"length",
";",
"i",
"++",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"este un metodo",
"\"",
"+",
"clasz",
".",
"getMethods",
"(",
")",
"[",
"i",
"]",
")",
";",
"}",
"Mio",
"algo",
"=",
"(",
"Mio",
")",
"clasz",
".",
"newInstance",
"(",
")",
";",
"Usuario",
"u",
"=",
"algo",
".",
"getUsuario",
"(",
"\"",
"ivan",
"\"",
")",
";",
"if",
"(",
"algo",
"==",
"null",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"la clase es nula",
"\"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"es el password de mio",
"\"",
"+",
"u",
".",
"getPassword",
"(",
")",
")",
";",
"/*RECIEN\n Mio a = (Mio)clasz.newInstance();\n Usuario uu= a.getUsuario(\"mio\");\n System.out.println(\"es el password de mio\"+uu.getPassword());*/",
"}",
"public",
"Class",
"mio",
"(",
"String",
"name",
")",
"throws",
"Exception",
"{",
"Class",
"clasz",
"=",
"null",
";",
"try",
"{",
"byte",
"classData",
"[",
"]",
"=",
"Util",
".",
"leerArchivo",
"(",
"name",
"+",
"\"",
".class",
"\"",
")",
";",
"byte",
"decryptedClassData",
"[",
"]",
"=",
"cipher",
".",
"doFinal",
"(",
"classData",
")",
";",
"clasz",
"=",
"defineClass",
"(",
"\"",
"business.",
"\"",
"+",
"name",
",",
"decryptedClassData",
",",
"0",
",",
"decryptedClassData",
".",
"length",
")",
";",
"}",
"catch",
"(",
"IOException",
"io",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error al leer el archivo",
"\"",
"+",
"io",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"",
"Error al desencriptar o al convertir a clase el archivo",
"\"",
"+",
"e",
")",
";",
"}",
"return",
"clasz",
";",
"}",
"public",
"Class",
"loadClass",
"(",
"String",
"name",
",",
"boolean",
"resolve",
")",
"throws",
"ClassNotFoundException",
"{",
"try",
"{",
"Class",
"clasz",
"=",
"null",
";",
"clasz",
"=",
"findLoadedClass",
"(",
"name",
")",
";",
"if",
"(",
"clasz",
"!=",
"null",
")",
"return",
"clasz",
";",
"try",
"{",
"byte",
"classData",
"[",
"]",
"=",
"Util",
".",
"leerArchivo",
"(",
"name",
"+",
"\"",
".class",
"\"",
")",
";",
"if",
"(",
"classData",
"!=",
"null",
")",
"{",
"byte",
"decryptedClassData",
"[",
"]",
"=",
"cipher",
".",
"doFinal",
"(",
"classData",
")",
";",
"clasz",
"=",
"defineClass",
"(",
"name",
"+",
"\"",
".class",
"\"",
",",
"decryptedClassData",
",",
"0",
",",
"decryptedClassData",
".",
"length",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"",
"[DecryptRun: decrypting class ",
"\"",
"+",
"name",
"+",
"\"",
"]",
"\"",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"fnfe",
")",
"{",
"}",
"if",
"(",
"clasz",
"==",
"null",
")",
"clasz",
"=",
"findSystemClass",
"(",
"name",
")",
";",
"if",
"(",
"resolve",
"&&",
"clasz",
"!=",
"null",
")",
"resolveClass",
"(",
"clasz",
")",
";",
"return",
"clasz",
";",
"}",
"catch",
"(",
"IOException",
"ie",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"ie",
".",
"toString",
"(",
")",
")",
";",
"}",
"catch",
"(",
"GeneralSecurityException",
"gse",
")",
"{",
"throw",
"new",
"ClassNotFoundException",
"(",
"gse",
".",
"toString",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Title: Business Services
Description: Clases encargadas de la aplicacion o logica de negocios
Copyright: Copyright (c) 2003
Company: Entidad Financiera
@author Ivan Paniagua
@version 1.0 | [
"Title",
":",
"Business",
"Services",
"Description",
":",
"Clases",
"encargadas",
"de",
"la",
"aplicacion",
"o",
"logica",
"de",
"negocios",
"Copyright",
":",
"Copyright",
"(",
"c",
")",
"2003",
"Company",
":",
"Entidad",
"Financiera",
"@author",
"Ivan",
"Paniagua",
"@version",
"1",
".",
"0"
] | [
"// These are set up in the constructor, and later",
"// used in the loadClass() method for decrypting the classes",
"// Constructor: set up the objects we need for decryption",
"// Main routine: here, we read in the key, and create",
"// an instance of DecryptRun, which is our custom ClassLoader.",
"// After we've set up the ClassLoader, we use it to",
"// load up an instance of the main class of the application.",
"// Finally, we call the main method of this class via",
"// the Java Reflection API",
"//args[0];",
"//\"classes/business/Borrar\";//args[1];",
"// Read in the key",
"// Create a decrypting ClassLoader",
"// Create an instance of the application's main class,",
"// loading it through the ClassLoader",
"//dr.loadClass( appName );",
"// Finally, call the main() routine of this instance",
"// using the Reflection API",
"// These are the arguments to the application itself",
"// String realArgs[] = new String[args.length-2];",
"// System.arraycopy( args, 2, realArgs, 0, args.length-2 );",
"// Grab a reference to main()",
"// String proto[] = new String[1];",
"// Class mainArgs[] = { (new String[1]).getClass() };",
"// Method main = clasz.getMethod( \"main\", mainArgs );",
"//",
"// Create an array containing the arguments to main()",
"// Object argsArray[] = { realArgs };",
"// System.err.println( \"[DecryptRun: running \"+appName+\".main()]\" );",
"//",
"// // Call main(). We've handed execution off to the",
"// // application, and we're done!",
"// main.invoke( null, argsArray );",
"// This will be the Class object that we create.",
"// Note that we call it \"clasz\" instead of \"class\"",
"// because \"class\" is a reserved word in Java",
"// Obligatory step 1: if the class is already in the",
"// system cache, we don't need to load it again",
"// Now we get to the custom part",
"// Read the encrypted class file",
"// RandomAccessFile randomaccessfile = new RandomAccessFile(getClass().getName() + \".bin\", \"r\");",
"// randomaccessfile.seek(randomaccessfile.readInt() != 0xdeadfeed ? 0 : randomaccessfile.readInt());",
"// String s1;",
"// decrypt it ...",
"// ... and turn it into a class",
"// It's probably a system file, so this isn't an error",
"// Obligatory step 2: if our decryption didn't work,",
"// maybe the class is to be found on the filesystem, so we",
"// try to load it using the default ClassLoader",
"// Obligatory step 3: if we've been asked to,",
"// resolve the class",
"// Return the class to the caller"
] | [
{
"param": "ClassLoader",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "ClassLoader",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
84478fb4cf2baac4d06c93d8d03fad60d0537450 | CodingCodersCode/EvolvingNetLib | EvolvingNet/src/main/java/com/codingcoderscode/lib/net/request/entity/CCDownloadPiece.java | [
"Apache-2.0"
] | Java | CCDownloadPiece | /**
* Created by CodingCodersCode on 2017/11/5.
*/ | Created by CodingCodersCode on 2017/11/5. | [
"Created",
"by",
"CodingCodersCode",
"on",
"2017",
"/",
"11",
"/",
"5",
"."
] | public class CCDownloadPiece {
private long rawRangeStart;
private long rawRangeEnd;
private long realRangeStart;
private long realRangeEnd;
public CCDownloadPiece(long rawRangeStart, long rawRangeEnd) {
this.rawRangeStart = rawRangeStart;
this.rawRangeEnd = rawRangeEnd;
}
public long getRawRangeStart() {
return rawRangeStart;
}
public void setRawRangeStart(long rawRangeStart) {
this.rawRangeStart = rawRangeStart;
}
public long getRawRangeEnd() {
return rawRangeEnd;
}
public void setRawRangeEnd(long rawRangeEnd) {
this.rawRangeEnd = rawRangeEnd;
}
public long getRealRangeStart() {
return realRangeStart;
}
public void setRealRangeStart(long realRangeStart) {
this.realRangeStart = realRangeStart;
}
public long getRealRangeEnd() {
return realRangeEnd;
}
public void setRealRangeEnd(long realRangeEnd) {
this.realRangeEnd = realRangeEnd;
}
} | [
"public",
"class",
"CCDownloadPiece",
"{",
"private",
"long",
"rawRangeStart",
";",
"private",
"long",
"rawRangeEnd",
";",
"private",
"long",
"realRangeStart",
";",
"private",
"long",
"realRangeEnd",
";",
"public",
"CCDownloadPiece",
"(",
"long",
"rawRangeStart",
",",
"long",
"rawRangeEnd",
")",
"{",
"this",
".",
"rawRangeStart",
"=",
"rawRangeStart",
";",
"this",
".",
"rawRangeEnd",
"=",
"rawRangeEnd",
";",
"}",
"public",
"long",
"getRawRangeStart",
"(",
")",
"{",
"return",
"rawRangeStart",
";",
"}",
"public",
"void",
"setRawRangeStart",
"(",
"long",
"rawRangeStart",
")",
"{",
"this",
".",
"rawRangeStart",
"=",
"rawRangeStart",
";",
"}",
"public",
"long",
"getRawRangeEnd",
"(",
")",
"{",
"return",
"rawRangeEnd",
";",
"}",
"public",
"void",
"setRawRangeEnd",
"(",
"long",
"rawRangeEnd",
")",
"{",
"this",
".",
"rawRangeEnd",
"=",
"rawRangeEnd",
";",
"}",
"public",
"long",
"getRealRangeStart",
"(",
")",
"{",
"return",
"realRangeStart",
";",
"}",
"public",
"void",
"setRealRangeStart",
"(",
"long",
"realRangeStart",
")",
"{",
"this",
".",
"realRangeStart",
"=",
"realRangeStart",
";",
"}",
"public",
"long",
"getRealRangeEnd",
"(",
")",
"{",
"return",
"realRangeEnd",
";",
"}",
"public",
"void",
"setRealRangeEnd",
"(",
"long",
"realRangeEnd",
")",
"{",
"this",
".",
"realRangeEnd",
"=",
"realRangeEnd",
";",
"}",
"}"
] | Created by CodingCodersCode on 2017/11/5. | [
"Created",
"by",
"CodingCodersCode",
"on",
"2017",
"/",
"11",
"/",
"5",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
844a8ebb2f9d31930e3447624befec113938a5f4 | mrudulpolus/kc | coeus-code/src/main/java/org/kuali/kra/s2s/generator/impl/S2SAdobeFormAttachmentBaseGenerator.java | [
"ECL-2.0"
] | Java | S2SAdobeFormAttachmentBaseGenerator | /**
* This abstract class has methods that are common to all the versions of RRSubAwardBudget form.
*
* @author Kuali Research Administration Team ([email protected])
*/ | This abstract class has methods that are common to all the versions of RRSubAwardBudget form.
@author Kuali Research Administration Team ([email protected]) | [
"This",
"abstract",
"class",
"has",
"methods",
"that",
"are",
"common",
"to",
"all",
"the",
"versions",
"of",
"RRSubAwardBudget",
"form",
".",
"@author",
"Kuali",
"Research",
"Administration",
"Team",
"(",
"kualidev@oncourse",
".",
"iu",
".",
"edu",
")"
] | public abstract class S2SAdobeFormAttachmentBaseGenerator extends S2SBaseFormGenerator {
protected static final String RR_BUDGET_10_NAMESPACE_URI = "http://apply.grants.gov/forms/RR_Budget-V1.0";
protected static final String RR_BUDGET_11_NAMESPACE_URI = "http://apply.grants.gov/forms/RR_Budget-V1.1";
protected static final String LOCAL_NAME = "RR_Budget";
private KcAttachmentService kcAttachmentService;
public ArrayList <String> attachmentList = new ArrayList<String> ();
public ArrayList <String> budgetIdList = new ArrayList<String> ();
public ArrayList <String> budgetSubawardNumberList = new ArrayList<String> ();
/**
* This method convert node of form in to a Document
*
* @param node n {Node} node entry.
* @return Document containing doc information
*/
public Document nodeToDom(org.w3c.dom.Node node) throws S2SException {
try {
javax.xml.transform.TransformerFactory tf = javax.xml.transform.TransformerFactory.newInstance();
javax.xml.transform.Transformer xf = tf.newTransformer();
javax.xml.transform.dom.DOMResult dr = new javax.xml.transform.dom.DOMResult();
xf.transform(new javax.xml.transform.dom.DOMSource(node), dr);
return (Document) dr.getNode();
}
catch (javax.xml.transform.TransformerException ex) {
throw new S2SException(ex.getMessage());
}
}
/**
* This method convert xml string in to a Document
*
* @param xmlSource {xml String} xml source entry.
* @return Document containing doc information
*/
public Document stringToDom(String xmlSource) throws S2SException {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
return builder.parse(new InputSource(new StringReader(xmlSource)));
}
catch (SAXException ex) {
throw new S2SException(ex.getMessage());
}
catch (ParserConfigurationException ex) {
throw new S2SException(ex.getMessage());
}
catch (IOException ex) {
throw new S2SException(ex.getMessage());
}
}
/**
* This method convert Document to a byte Array
*
* @param node {Document} node entry.
* @return byte Array containing doc information
*/
public byte[] docToBytes(Document node) throws S2SException {
return docToString(node).getBytes();
}
/**
* This method convert Document to a String
*
* @param node {Document} node entry.
* @return String containing doc information
*/
public String docToString(Document node) throws S2SException {
try {
DOMSource domSource = new DOMSource(node);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
Transformer transformer = tf.newTransformer();
transformer.transform(domSource, result);
return writer.toString();
}
catch (Exception e) {
throw new S2SException(e.getMessage(),e);
}
}
/**
*
* This method is used to return the attachment name which comes from BudgetSubawards
*
* @param budgetSubAwards(BudgetSubAwards) budget sub award entry.
* @return String attachment name for the budget sub awards.
*/
protected String prepareAttName(BudgetSubAwards budgetSubAwards) {
StringBuilder attachmentName = new StringBuilder();
boolean hasSameFileName = false;
boolean isAlreadyprinted = false;
int attachmentCount=0;
int suffix=1;
int index =0;
for(String budgetId : budgetIdList){
if(budgetSubAwards.getBudgetId().toString().equals(budgetId)){
if(budgetSubawardNumberList.get(index).equals(budgetSubAwards.getSubAwardNumber().toString())){
attachmentList.clear();
isAlreadyprinted = true;
break;
}
}
index++;
}
if(isAlreadyprinted){
budgetIdList.clear();
budgetSubawardNumberList.clear();
}
//checking organization name and replacing invalid characters
// with underscores.
String cleanSubAwardOrganizationName = getKcAttachmentService()
.checkAndReplaceInvalidCharacters(budgetSubAwards.getOrganizationName());
attachmentName.append(cleanSubAwardOrganizationName);
List<BudgetSubAwards> budgetSubAwardsList = getBudgetSubAwardsService().findBudgetSubAwardsByBudgetId(budgetSubAwards.getBudgetId());
ArrayList<String> attachments = new ArrayList<String> ();
for (BudgetSubAwards budgetSubAward: budgetSubAwardsList) {
StringBuilder existingAttachmentName = new StringBuilder();
String subAward_OrganizationName = getKcAttachmentService()
.checkAndReplaceInvalidCharacters(budgetSubAward.getOrganizationName());
existingAttachmentName.append(subAward_OrganizationName);
attachments.add(existingAttachmentName.toString());
}
for (String attachment : attachments) {
if (attachment.equals(attachmentName.toString())) {
attachmentCount++;
}
}
if (attachmentCount>1 && !attachmentList.contains(attachmentName.toString())) {
attachmentList.add(attachmentName.toString());
attachmentName.append(1);
hasSameFileName = true;
} else {
for (String attachment:attachmentList) {
if (attachment.equals(attachmentName.toString())) {
suffix++;
}
}
}
if (attachmentList.contains(attachmentName.toString()) && !hasSameFileName) {
attachmentList.add(attachmentName.toString());
attachmentName.append(suffix);
} else {
attachmentList.add(attachmentName.toString());
}
budgetIdList.add(budgetSubAwards.getBudgetId().toString());
budgetSubawardNumberList.add(budgetSubAwards.getSubAwardNumber().toString());
return attachmentName.toString();
}
/**
* This method gets the attachment service
* @return
*/
protected KcAttachmentService getKcAttachmentService() {
if (kcAttachmentService == null) {
kcAttachmentService = KcServiceLocator.getService(KcAttachmentService.class);
}
return kcAttachmentService;
}
/**
* Adding attachments to subaward
*/
protected void addSubAwdAttachments(BudgetSubAwards budgetSubAwards) {
budgetSubAwards.refreshReferenceObject("budgetSubAwardAttachments");
List<BudgetSubAwardAttachment> subAwardAttachments = budgetSubAwards.getBudgetSubAwardAttachments();
for (BudgetSubAwardAttachment budgetSubAwardAttachment : subAwardAttachments) {
AttachmentData attachmentData = new AttachmentData();
attachmentData.setContent(budgetSubAwardAttachment.getAttachment());
attachmentData.setContentId(budgetSubAwardAttachment.getContentId());
attachmentData.setContentType(budgetSubAwardAttachment.getContentType());
attachmentData.setFileName(budgetSubAwardAttachment.getContentId());
addAttachment(attachmentData);
}
}
/**
*
* This method is used to get BudgetSubAwrads from ProposalDevelopmentDocument
*
* @param proposalDevelopmentDocument (ProposalDevelopmentDocument)
* @return List<BudgetSubAwards> list of budget sub awards.
*/
protected List<BudgetSubAwards> getBudgetSubAwards(ProposalDevelopmentDocument proposalDevelopmentDocument,
String namespace,boolean checkNull) {
List<BudgetSubAwards> budgetSubAwardsList = new ArrayList<BudgetSubAwards>();
Budget budget = findBudgetFromProposal(proposalDevelopmentDocument);
if(budget==null){
getAuditErrors().add(S2SErrorHandler.getError(S2SConstants.SUB_AWARD_BUDGET_NOT_FOUND));
}else{
budgetSubAwardsList = findBudgetSubawards(namespace, budget,checkNull);
if(budgetSubAwardsList.isEmpty()){
getAuditErrors().add(S2SErrorHandler.getError(S2SConstants.SUB_AWARD_BUDGET_NOT_FOUND));
}
}
return budgetSubAwardsList;
}
/**
* This method is to find the subaward budget BOs for the given namespace
* @param namespace
* @param budget
* @return
*/
@SuppressWarnings("unchecked")
private List<BudgetSubAwards> findBudgetSubawards(String namespace, Budget budget,boolean checkNull) {
List<BudgetSubAwards> budgetSubAwardsList = new ArrayList<>();
budgetSubAwardsList.addAll(getBudgetSubAwardsService().findBudgetSubAwardsByBudgetIdAndNamespace(budget.getBudgetId(), namespace));
if(checkNull){
budgetSubAwardsList.addAll(getBudgetSubAwardsService().findBudgetSubAwardsByBudgetIdAndNullNamespace(budget.getBudgetId()));
}
return budgetSubAwardsList;
}
private Budget findBudgetFromProposal(ProposalDevelopmentDocument proposalDevelopmentDocument) {
Budget finalBudget = proposalDevelopmentDocument.getFinalBudgetForThisProposal();
if(finalBudget==null){
List<BudgetDocumentVersion> budgetDocumentVersions = proposalDevelopmentDocument.getBudgetDocumentVersions();
BudgetVersionOverview budgetVersionOverview = null;
for (BudgetDocumentVersion budgetDocumentVersion : budgetDocumentVersions) {
if(budgetDocumentVersion.isBudgetComplete()){
budgetVersionOverview = budgetDocumentVersion.getBudgetVersionOverview();
return budgetDocumentVersion.findBudget();
}
}
if(!budgetDocumentVersions.isEmpty()){
finalBudget = budgetDocumentVersions.get(0).findBudget();
}
}
return finalBudget;
}
public BudgetSubAwardsService getBudgetSubAwardsService() {
return KcServiceLocator.getService(BudgetSubAwardsService.class);
}
} | [
"public",
"abstract",
"class",
"S2SAdobeFormAttachmentBaseGenerator",
"extends",
"S2SBaseFormGenerator",
"{",
"protected",
"static",
"final",
"String",
"RR_BUDGET_10_NAMESPACE_URI",
"=",
"\"",
"http://apply.grants.gov/forms/RR_Budget-V1.0",
"\"",
";",
"protected",
"static",
"final",
"String",
"RR_BUDGET_11_NAMESPACE_URI",
"=",
"\"",
"http://apply.grants.gov/forms/RR_Budget-V1.1",
"\"",
";",
"protected",
"static",
"final",
"String",
"LOCAL_NAME",
"=",
"\"",
"RR_Budget",
"\"",
";",
"private",
"KcAttachmentService",
"kcAttachmentService",
";",
"public",
"ArrayList",
"<",
"String",
">",
"attachmentList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"public",
"ArrayList",
"<",
"String",
">",
"budgetIdList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"public",
"ArrayList",
"<",
"String",
">",
"budgetSubawardNumberList",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"/**\n * This method convert node of form in to a Document\n * \n * @param node n {Node} node entry.\n * @return Document containing doc information\n */",
"public",
"Document",
"nodeToDom",
"(",
"org",
".",
"w3c",
".",
"dom",
".",
"Node",
"node",
")",
"throws",
"S2SException",
"{",
"try",
"{",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerFactory",
"tf",
"=",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"javax",
".",
"xml",
".",
"transform",
".",
"Transformer",
"xf",
"=",
"tf",
".",
"newTransformer",
"(",
")",
";",
"javax",
".",
"xml",
".",
"transform",
".",
"dom",
".",
"DOMResult",
"dr",
"=",
"new",
"javax",
".",
"xml",
".",
"transform",
".",
"dom",
".",
"DOMResult",
"(",
")",
";",
"xf",
".",
"transform",
"(",
"new",
"javax",
".",
"xml",
".",
"transform",
".",
"dom",
".",
"DOMSource",
"(",
"node",
")",
",",
"dr",
")",
";",
"return",
"(",
"Document",
")",
"dr",
".",
"getNode",
"(",
")",
";",
"}",
"catch",
"(",
"javax",
".",
"xml",
".",
"transform",
".",
"TransformerException",
"ex",
")",
"{",
"throw",
"new",
"S2SException",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"/**\n * This method convert xml string in to a Document\n * \n * @param xmlSource {xml String} xml source entry.\n * @return Document containing doc information\n */",
"public",
"Document",
"stringToDom",
"(",
"String",
"xmlSource",
")",
"throws",
"S2SException",
"{",
"try",
"{",
"DocumentBuilderFactory",
"factory",
"=",
"DocumentBuilderFactory",
".",
"newInstance",
"(",
")",
";",
"factory",
".",
"setNamespaceAware",
"(",
"true",
")",
";",
"DocumentBuilder",
"builder",
"=",
"factory",
".",
"newDocumentBuilder",
"(",
")",
";",
"return",
"builder",
".",
"parse",
"(",
"new",
"InputSource",
"(",
"new",
"StringReader",
"(",
"xmlSource",
")",
")",
")",
";",
"}",
"catch",
"(",
"SAXException",
"ex",
")",
"{",
"throw",
"new",
"S2SException",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ParserConfigurationException",
"ex",
")",
"{",
"throw",
"new",
"S2SException",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"throw",
"new",
"S2SException",
"(",
"ex",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"/**\n * This method convert Document to a byte Array\n * \n * @param node {Document} node entry.\n * @return byte Array containing doc information\n */",
"public",
"byte",
"[",
"]",
"docToBytes",
"(",
"Document",
"node",
")",
"throws",
"S2SException",
"{",
"return",
"docToString",
"(",
"node",
")",
".",
"getBytes",
"(",
")",
";",
"}",
"/**\n * This method convert Document to a String\n * \n * @param node {Document} node entry.\n * @return String containing doc information\n */",
"public",
"String",
"docToString",
"(",
"Document",
"node",
")",
"throws",
"S2SException",
"{",
"try",
"{",
"DOMSource",
"domSource",
"=",
"new",
"DOMSource",
"(",
"node",
")",
";",
"StringWriter",
"writer",
"=",
"new",
"StringWriter",
"(",
")",
";",
"StreamResult",
"result",
"=",
"new",
"StreamResult",
"(",
"writer",
")",
";",
"TransformerFactory",
"tf",
"=",
"TransformerFactory",
".",
"newInstance",
"(",
")",
";",
"Transformer",
"transformer",
"=",
"tf",
".",
"newTransformer",
"(",
")",
";",
"transformer",
".",
"transform",
"(",
"domSource",
",",
"result",
")",
";",
"return",
"writer",
".",
"toString",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"S2SException",
"(",
"e",
".",
"getMessage",
"(",
")",
",",
"e",
")",
";",
"}",
"}",
"/**\n * \n * This method is used to return the attachment name which comes from BudgetSubawards\n * \n * @param budgetSubAwards(BudgetSubAwards) budget sub award entry.\n * @return String attachment name for the budget sub awards.\n */",
"protected",
"String",
"prepareAttName",
"(",
"BudgetSubAwards",
"budgetSubAwards",
")",
"{",
"StringBuilder",
"attachmentName",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"boolean",
"hasSameFileName",
"=",
"false",
";",
"boolean",
"isAlreadyprinted",
"=",
"false",
";",
"int",
"attachmentCount",
"=",
"0",
";",
"int",
"suffix",
"=",
"1",
";",
"int",
"index",
"=",
"0",
";",
"for",
"(",
"String",
"budgetId",
":",
"budgetIdList",
")",
"{",
"if",
"(",
"budgetSubAwards",
".",
"getBudgetId",
"(",
")",
".",
"toString",
"(",
")",
".",
"equals",
"(",
"budgetId",
")",
")",
"{",
"if",
"(",
"budgetSubawardNumberList",
".",
"get",
"(",
"index",
")",
".",
"equals",
"(",
"budgetSubAwards",
".",
"getSubAwardNumber",
"(",
")",
".",
"toString",
"(",
")",
")",
")",
"{",
"attachmentList",
".",
"clear",
"(",
")",
";",
"isAlreadyprinted",
"=",
"true",
";",
"break",
";",
"}",
"}",
"index",
"++",
";",
"}",
"if",
"(",
"isAlreadyprinted",
")",
"{",
"budgetIdList",
".",
"clear",
"(",
")",
";",
"budgetSubawardNumberList",
".",
"clear",
"(",
")",
";",
"}",
"String",
"cleanSubAwardOrganizationName",
"=",
"getKcAttachmentService",
"(",
")",
".",
"checkAndReplaceInvalidCharacters",
"(",
"budgetSubAwards",
".",
"getOrganizationName",
"(",
")",
")",
";",
"attachmentName",
".",
"append",
"(",
"cleanSubAwardOrganizationName",
")",
";",
"List",
"<",
"BudgetSubAwards",
">",
"budgetSubAwardsList",
"=",
"getBudgetSubAwardsService",
"(",
")",
".",
"findBudgetSubAwardsByBudgetId",
"(",
"budgetSubAwards",
".",
"getBudgetId",
"(",
")",
")",
";",
"ArrayList",
"<",
"String",
">",
"attachments",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"BudgetSubAwards",
"budgetSubAward",
":",
"budgetSubAwardsList",
")",
"{",
"StringBuilder",
"existingAttachmentName",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"String",
"subAward_OrganizationName",
"=",
"getKcAttachmentService",
"(",
")",
".",
"checkAndReplaceInvalidCharacters",
"(",
"budgetSubAward",
".",
"getOrganizationName",
"(",
")",
")",
";",
"existingAttachmentName",
".",
"append",
"(",
"subAward_OrganizationName",
")",
";",
"attachments",
".",
"add",
"(",
"existingAttachmentName",
".",
"toString",
"(",
")",
")",
";",
"}",
"for",
"(",
"String",
"attachment",
":",
"attachments",
")",
"{",
"if",
"(",
"attachment",
".",
"equals",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
")",
"{",
"attachmentCount",
"++",
";",
"}",
"}",
"if",
"(",
"attachmentCount",
">",
"1",
"&&",
"!",
"attachmentList",
".",
"contains",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
")",
"{",
"attachmentList",
".",
"add",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
";",
"attachmentName",
".",
"append",
"(",
"1",
")",
";",
"hasSameFileName",
"=",
"true",
";",
"}",
"else",
"{",
"for",
"(",
"String",
"attachment",
":",
"attachmentList",
")",
"{",
"if",
"(",
"attachment",
".",
"equals",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
")",
"{",
"suffix",
"++",
";",
"}",
"}",
"}",
"if",
"(",
"attachmentList",
".",
"contains",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
"&&",
"!",
"hasSameFileName",
")",
"{",
"attachmentList",
".",
"add",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
";",
"attachmentName",
".",
"append",
"(",
"suffix",
")",
";",
"}",
"else",
"{",
"attachmentList",
".",
"add",
"(",
"attachmentName",
".",
"toString",
"(",
")",
")",
";",
"}",
"budgetIdList",
".",
"add",
"(",
"budgetSubAwards",
".",
"getBudgetId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"budgetSubawardNumberList",
".",
"add",
"(",
"budgetSubAwards",
".",
"getSubAwardNumber",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"return",
"attachmentName",
".",
"toString",
"(",
")",
";",
"}",
"/**\n * This method gets the attachment service\n * @return\n */",
"protected",
"KcAttachmentService",
"getKcAttachmentService",
"(",
")",
"{",
"if",
"(",
"kcAttachmentService",
"==",
"null",
")",
"{",
"kcAttachmentService",
"=",
"KcServiceLocator",
".",
"getService",
"(",
"KcAttachmentService",
".",
"class",
")",
";",
"}",
"return",
"kcAttachmentService",
";",
"}",
"/**\n * Adding attachments to subaward\n */",
"protected",
"void",
"addSubAwdAttachments",
"(",
"BudgetSubAwards",
"budgetSubAwards",
")",
"{",
"budgetSubAwards",
".",
"refreshReferenceObject",
"(",
"\"",
"budgetSubAwardAttachments",
"\"",
")",
";",
"List",
"<",
"BudgetSubAwardAttachment",
">",
"subAwardAttachments",
"=",
"budgetSubAwards",
".",
"getBudgetSubAwardAttachments",
"(",
")",
";",
"for",
"(",
"BudgetSubAwardAttachment",
"budgetSubAwardAttachment",
":",
"subAwardAttachments",
")",
"{",
"AttachmentData",
"attachmentData",
"=",
"new",
"AttachmentData",
"(",
")",
";",
"attachmentData",
".",
"setContent",
"(",
"budgetSubAwardAttachment",
".",
"getAttachment",
"(",
")",
")",
";",
"attachmentData",
".",
"setContentId",
"(",
"budgetSubAwardAttachment",
".",
"getContentId",
"(",
")",
")",
";",
"attachmentData",
".",
"setContentType",
"(",
"budgetSubAwardAttachment",
".",
"getContentType",
"(",
")",
")",
";",
"attachmentData",
".",
"setFileName",
"(",
"budgetSubAwardAttachment",
".",
"getContentId",
"(",
")",
")",
";",
"addAttachment",
"(",
"attachmentData",
")",
";",
"}",
"}",
"/**\n * \n * This method is used to get BudgetSubAwrads from ProposalDevelopmentDocument\n * \n * @param proposalDevelopmentDocument (ProposalDevelopmentDocument)\n * @return List<BudgetSubAwards> list of budget sub awards.\n */",
"protected",
"List",
"<",
"BudgetSubAwards",
">",
"getBudgetSubAwards",
"(",
"ProposalDevelopmentDocument",
"proposalDevelopmentDocument",
",",
"String",
"namespace",
",",
"boolean",
"checkNull",
")",
"{",
"List",
"<",
"BudgetSubAwards",
">",
"budgetSubAwardsList",
"=",
"new",
"ArrayList",
"<",
"BudgetSubAwards",
">",
"(",
")",
";",
"Budget",
"budget",
"=",
"findBudgetFromProposal",
"(",
"proposalDevelopmentDocument",
")",
";",
"if",
"(",
"budget",
"==",
"null",
")",
"{",
"getAuditErrors",
"(",
")",
".",
"add",
"(",
"S2SErrorHandler",
".",
"getError",
"(",
"S2SConstants",
".",
"SUB_AWARD_BUDGET_NOT_FOUND",
")",
")",
";",
"}",
"else",
"{",
"budgetSubAwardsList",
"=",
"findBudgetSubawards",
"(",
"namespace",
",",
"budget",
",",
"checkNull",
")",
";",
"if",
"(",
"budgetSubAwardsList",
".",
"isEmpty",
"(",
")",
")",
"{",
"getAuditErrors",
"(",
")",
".",
"add",
"(",
"S2SErrorHandler",
".",
"getError",
"(",
"S2SConstants",
".",
"SUB_AWARD_BUDGET_NOT_FOUND",
")",
")",
";",
"}",
"}",
"return",
"budgetSubAwardsList",
";",
"}",
"/**\n * This method is to find the subaward budget BOs for the given namespace\n * @param namespace\n * @param budget\n * @return\n */",
"@",
"SuppressWarnings",
"(",
"\"",
"unchecked",
"\"",
")",
"private",
"List",
"<",
"BudgetSubAwards",
">",
"findBudgetSubawards",
"(",
"String",
"namespace",
",",
"Budget",
"budget",
",",
"boolean",
"checkNull",
")",
"{",
"List",
"<",
"BudgetSubAwards",
">",
"budgetSubAwardsList",
"=",
"new",
"ArrayList",
"<",
">",
"(",
")",
";",
"budgetSubAwardsList",
".",
"addAll",
"(",
"getBudgetSubAwardsService",
"(",
")",
".",
"findBudgetSubAwardsByBudgetIdAndNamespace",
"(",
"budget",
".",
"getBudgetId",
"(",
")",
",",
"namespace",
")",
")",
";",
"if",
"(",
"checkNull",
")",
"{",
"budgetSubAwardsList",
".",
"addAll",
"(",
"getBudgetSubAwardsService",
"(",
")",
".",
"findBudgetSubAwardsByBudgetIdAndNullNamespace",
"(",
"budget",
".",
"getBudgetId",
"(",
")",
")",
")",
";",
"}",
"return",
"budgetSubAwardsList",
";",
"}",
"private",
"Budget",
"findBudgetFromProposal",
"(",
"ProposalDevelopmentDocument",
"proposalDevelopmentDocument",
")",
"{",
"Budget",
"finalBudget",
"=",
"proposalDevelopmentDocument",
".",
"getFinalBudgetForThisProposal",
"(",
")",
";",
"if",
"(",
"finalBudget",
"==",
"null",
")",
"{",
"List",
"<",
"BudgetDocumentVersion",
">",
"budgetDocumentVersions",
"=",
"proposalDevelopmentDocument",
".",
"getBudgetDocumentVersions",
"(",
")",
";",
"BudgetVersionOverview",
"budgetVersionOverview",
"=",
"null",
";",
"for",
"(",
"BudgetDocumentVersion",
"budgetDocumentVersion",
":",
"budgetDocumentVersions",
")",
"{",
"if",
"(",
"budgetDocumentVersion",
".",
"isBudgetComplete",
"(",
")",
")",
"{",
"budgetVersionOverview",
"=",
"budgetDocumentVersion",
".",
"getBudgetVersionOverview",
"(",
")",
";",
"return",
"budgetDocumentVersion",
".",
"findBudget",
"(",
")",
";",
"}",
"}",
"if",
"(",
"!",
"budgetDocumentVersions",
".",
"isEmpty",
"(",
")",
")",
"{",
"finalBudget",
"=",
"budgetDocumentVersions",
".",
"get",
"(",
"0",
")",
".",
"findBudget",
"(",
")",
";",
"}",
"}",
"return",
"finalBudget",
";",
"}",
"public",
"BudgetSubAwardsService",
"getBudgetSubAwardsService",
"(",
")",
"{",
"return",
"KcServiceLocator",
".",
"getService",
"(",
"BudgetSubAwardsService",
".",
"class",
")",
";",
"}",
"}"
] | This abstract class has methods that are common to all the versions of RRSubAwardBudget form. | [
"This",
"abstract",
"class",
"has",
"methods",
"that",
"are",
"common",
"to",
"all",
"the",
"versions",
"of",
"RRSubAwardBudget",
"form",
"."
] | [
"//checking organization name and replacing invalid characters",
"// with underscores."
] | [
{
"param": "S2SBaseFormGenerator",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "S2SBaseFormGenerator",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
844c1c8b7a4065984817a3a780dba6d95e6d7f56 | jbrandwood/kickc | src/main/java/dk/camelot64/kickc/model/DominatorsBlock.java | [
"MIT"
] | Java | DominatorsBlock | /**
* The Dominators for a specific block.
* <p>
* Definition: Block d dominates block i if all paths from entry to block i includes block d
* <p>
* See http://www.cs.colostate.edu/~cs553/ClassNotes/lecture09-control-dominators.ppt.pdf
*/ | The Dominators for a specific block. | [
"The",
"Dominators",
"for",
"a",
"specific",
"block",
"."
] | public class DominatorsBlock {
/**
* Set containing the labels of all blocks that are dominators of the block.
*/
Set<LabelRef> dominators;
public DominatorsBlock() {
this.dominators = new HashSet<>();
}
/**
* Add a single dominator
*
* @param dominator The dominator to add
*/
public void add(LabelRef dominator) {
dominators.add(dominator);
}
/**
* Adds a bunch of dominators
*
* @param dominators The dominators to add
*/
public void addAll(Collection<LabelRef> dominators) {
for(LabelRef dominator : dominators) {
add(dominator);
}
}
/**
* Modifies this set of dominators to be the intersection between this set and the passed set.
* Effectively removes all labels from this set that is not also present in the passed set.
*
* @param other The dominator set to intersect with
*/
public void intersect(DominatorsBlock other) {
dominators.removeIf(dominator -> !other.contains(dominator));
}
/**
* Determines if the dominator set contains a specific block
*
* @param block The block to look for
* @return true if the dominator set contains the block
*/
public boolean contains(LabelRef block) {
return dominators.contains(block);
}
public Set<LabelRef> getDominators() {
return dominators;
}
@Override
public boolean equals(Object o) {
if(this == o) return true;
if(o == null || getClass() != o.getClass()) return false;
DominatorsBlock that = (DominatorsBlock) o;
return Objects.equals(dominators, that.dominators);
}
@Override
public int hashCode() {
return Objects.hash(dominators);
}
@Override
public String toString() {
StringBuilder out = new StringBuilder();
for(LabelRef dominator : dominators) {
out.append(dominator);
out.append(" ");
}
return out.toString();
}
} | [
"public",
"class",
"DominatorsBlock",
"{",
"/**\n * Set containing the labels of all blocks that are dominators of the block.\n */",
"Set",
"<",
"LabelRef",
">",
"dominators",
";",
"public",
"DominatorsBlock",
"(",
")",
"{",
"this",
".",
"dominators",
"=",
"new",
"HashSet",
"<",
">",
"(",
")",
";",
"}",
"/**\n * Add a single dominator\n *\n * @param dominator The dominator to add\n */",
"public",
"void",
"add",
"(",
"LabelRef",
"dominator",
")",
"{",
"dominators",
".",
"add",
"(",
"dominator",
")",
";",
"}",
"/**\n * Adds a bunch of dominators\n *\n * @param dominators The dominators to add\n */",
"public",
"void",
"addAll",
"(",
"Collection",
"<",
"LabelRef",
">",
"dominators",
")",
"{",
"for",
"(",
"LabelRef",
"dominator",
":",
"dominators",
")",
"{",
"add",
"(",
"dominator",
")",
";",
"}",
"}",
"/**\n * Modifies this set of dominators to be the intersection between this set and the passed set.\n * Effectively removes all labels from this set that is not also present in the passed set.\n *\n * @param other The dominator set to intersect with\n */",
"public",
"void",
"intersect",
"(",
"DominatorsBlock",
"other",
")",
"{",
"dominators",
".",
"removeIf",
"(",
"dominator",
"->",
"!",
"other",
".",
"contains",
"(",
"dominator",
")",
")",
";",
"}",
"/**\n * Determines if the dominator set contains a specific block\n *\n * @param block The block to look for\n * @return true if the dominator set contains the block\n */",
"public",
"boolean",
"contains",
"(",
"LabelRef",
"block",
")",
"{",
"return",
"dominators",
".",
"contains",
"(",
"block",
")",
";",
"}",
"public",
"Set",
"<",
"LabelRef",
">",
"getDominators",
"(",
")",
"{",
"return",
"dominators",
";",
"}",
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"this",
"==",
"o",
")",
"return",
"true",
";",
"if",
"(",
"o",
"==",
"null",
"||",
"getClass",
"(",
")",
"!=",
"o",
".",
"getClass",
"(",
")",
")",
"return",
"false",
";",
"DominatorsBlock",
"that",
"=",
"(",
"DominatorsBlock",
")",
"o",
";",
"return",
"Objects",
".",
"equals",
"(",
"dominators",
",",
"that",
".",
"dominators",
")",
";",
"}",
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"return",
"Objects",
".",
"hash",
"(",
"dominators",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"StringBuilder",
"out",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"for",
"(",
"LabelRef",
"dominator",
":",
"dominators",
")",
"{",
"out",
".",
"append",
"(",
"dominator",
")",
";",
"out",
".",
"append",
"(",
"\"",
" ",
"\"",
")",
";",
"}",
"return",
"out",
".",
"toString",
"(",
")",
";",
"}",
"}"
] | The Dominators for a specific block. | [
"The",
"Dominators",
"for",
"a",
"specific",
"block",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
844e89b27ce7cbc002e9eaf2f234345d05537e7e | ykulbashian/LiquidSurface | liquidview/src/main/java/com/google/fpl/liquidfunpaint/shader/Material.java | [
"Apache-2.0"
] | Java | Material | /**
* A layer on top of ShaderProgram to store specific parameters to be reused.
* It stores render states and textures that we will set in conjunction with
* a specific ShaderProgram -- allowing the ShaderProgram to be reused with
* different parameters.
*/ | A layer on top of ShaderProgram to store specific parameters to be reused.
It stores render states and textures that we will set in conjunction with
a specific ShaderProgram -- allowing the ShaderProgram to be reused with
different parameters. | [
"A",
"layer",
"on",
"top",
"of",
"ShaderProgram",
"to",
"store",
"specific",
"parameters",
"to",
"be",
"reused",
".",
"It",
"stores",
"render",
"states",
"and",
"textures",
"that",
"we",
"will",
"set",
"in",
"conjunction",
"with",
"a",
"specific",
"ShaderProgram",
"--",
"allowing",
"the",
"ShaderProgram",
"to",
"be",
"reused",
"with",
"different",
"parameters",
"."
] | public class Material {
private static final String TAG = "Material";
/**
* Defines which component types are accepted.
* OpenGL ES simply has these as global constants but we want to type check.
* According to some sources (not benchmarked), enums can take up space
* and are slower. Investigate these if we see related performance issues.
*/
public enum AttrComponentType {
BYTE(GLES20.GL_BYTE),
UNSIGNED_BYTE(GLES20.GL_UNSIGNED_BYTE),
SHORT(GLES20.GL_SHORT),
UNSIGNED_SHORT(GLES20.GL_UNSIGNED_SHORT),
FIXED(GLES20.GL_FIXED),
FLOAT(GLES20.GL_FLOAT);
private final int mGlComponentType;
private AttrComponentType(int glComponentType) {
mGlComponentType = glComponentType;
}
protected int getGlType() {
return mGlComponentType;
}
}
/**
* Defines which blend types are accepted.
* OpenGL ES simply has these as global constants but we want to type check.
*/
public enum BlendFactor {
ZERO(GLES20.GL_ZERO),
ONE(GLES20.GL_ONE),
SRC_COLOR(GLES20.GL_SRC_COLOR),
ONE_MINUS_SRC_COLOR(GLES20.GL_ONE_MINUS_SRC_COLOR),
DST_COLOR(GLES20.GL_DST_COLOR),
ONE_MINUS_DST_COLOR(GLES20.GL_ONE_MINUS_DST_COLOR),
SRC_ALPHA(GLES20.GL_SRC_ALPHA),
ONE_MINUS_SRC_ALPHA(GLES20.GL_ONE_MINUS_SRC_ALPHA),
DST_ALPHA(GLES20.GL_DST_ALPHA),
ONE_MINUS_DST_ALPHA(GLES20.GL_ONE_MINUS_DST_ALPHA),
CONSTANT_COLOR(GLES20.GL_CONSTANT_COLOR),
ONE_MINUS_CONSTANT_COLOR(GLES20.GL_ONE_MINUS_CONSTANT_COLOR),
CONSTANT_ALPHA(GLES20.GL_CONSTANT_ALPHA),
ONE_MINUS_CONSTANT_ALPHA(GLES20.GL_ONE_MINUS_CONSTANT_ALPHA);
private final int mGlBlendFactor;
private BlendFactor(int glBlendFactor) {
mGlBlendFactor = glBlendFactor;
}
protected int getGlType() {
return mGlBlendFactor;
}
}
/**
* A class for defining the specific attribute's extra info
* like type, stride, etc
*/
public class AttributeInfo {
String mName;
int mNumComponents;
AttrComponentType mComponentType;
int mComponentSize;
boolean mNormalized;
int mStride;
int mLocation;
public AttributeInfo(
String name, int numComponents, AttrComponentType componentType,
int componentSize, boolean normalized, int stride, int location) {
mName = name;
mNumComponents = numComponents;
mComponentType = componentType;
mComponentSize = componentSize;
mNormalized = normalized;
mStride = stride;
mLocation = location;
if (location < 0) {
Log.e(TAG, "Invalid vertex attribute location" + name +
"! Is the name spelled correctly?");
}
}
}
/**
* A class for storing render states to be set at the beginning of render.
*/
private class RenderState {
boolean mEnableBlend = false;
// These defaults are the OpenGL defaults
BlendFactor mBlendColorSFactor = BlendFactor.ONE;
BlendFactor mBlendColorDFactor = BlendFactor.ZERO;
}
/// Member variables
protected ShaderProgram mShader = null;
private Map<String, AttributeInfo> mVertexAttributes =
new HashMap<String, AttributeInfo>();
private Map<String, Texture> mTextures = new HashMap<String, Texture>(1);
private RenderState mRenderState = new RenderState();
/// Member methods
public Material(ShaderProgram shader) {
// Don't take the shader if it's not generated correctly
if (shader != null && shader.isShaderCompiled()) {
mShader = shader;
} else {
throw new IllegalArgumentException(
"ShaderProgram " + shader + " is not valid! Failed to " +
"assign to new Material.");
}
}
public AttributeInfo addAttribute(
String name, int numComponents, AttrComponentType componentType,
int componentSize, boolean normalized, int stride) {
int location = mShader.getAttributeLocation(name);
AttributeInfo attr = new AttributeInfo(
name, numComponents, componentType,
componentSize, normalized, stride, location);
mVertexAttributes.put(name, attr);
return attr;
}
public void addTexture(String textureUniformName, Texture texture) {
mTextures.put(textureUniformName, texture);
if (GLES20.GL_TEXTURE0 + mTextures.size() >
GLES20.GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS) {
Log.e(TAG, "Too many textures in material! Failed to add: " +
texture);
}
}
public void beginRender() {
mShader.beginRender();
// Set render states
if (mRenderState.mEnableBlend) {
GLES20.glEnable(GLES20.GL_BLEND);
GLES20.glBlendFunc(
mRenderState.mBlendColorSFactor.getGlType(),
mRenderState.mBlendColorDFactor.getGlType());
}
// enable all vertex attributes we have info on
for (AttributeInfo attr : mVertexAttributes.values()) {
GLES20.glEnableVertexAttribArray(attr.mLocation);
}
// enable all textures
int textureIdx = 0;
for (Entry<String, Texture> texture : mTextures.entrySet()) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + textureIdx);
GLES20.glBindTexture(
GLES20.GL_TEXTURE_2D, texture.getValue().getTextureId());
// Set the correct uniform
GLES20.glUniform1i(
getUniformLocation(texture.getKey()), textureIdx);
// Get next texture index
++textureIdx;
}
}
public void endRender() {
// disable all textures
for (int i = 0; i < mTextures.size(); ++i) {
GLES20.glActiveTexture(GLES20.GL_TEXTURE0 + i);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, 0);
}
// enable all vertex attributes
for (AttributeInfo attr : mVertexAttributes.values()) {
GLES20.glDisableVertexAttribArray(attr.mLocation);
}
// Reset render states
if (mRenderState.mEnableBlend) {
GLES20.glDisable(GLES20.GL_BLEND);
}
mShader.endRender();
}
public void setVertexAttributeBuffer(
AttributeInfo attr, Buffer buffer, int offset) {
buffer.position(offset);
GLES20.glVertexAttribPointer(
attr.mLocation, attr.mNumComponents,
attr.mComponentType.getGlType(), attr.mNormalized,
attr.mStride, buffer);
}
public void setVertexAttributeBuffer(
String name, Buffer buffer, int offset) {
AttributeInfo attr = mVertexAttributes.get(name);
buffer.position(offset);
GLES20.glVertexAttribPointer(
attr.mLocation, attr.mNumComponents,
attr.mComponentType.getGlType(), attr.mNormalized,
attr.mStride, buffer);
}
/**
* Provide access to the ShaderProgram function
*/
public int getUniformLocation(String name) {
int location = mShader.getUniformLocation(name);
if (location < 0) {
Log.e(TAG, "Invalid uniform location for " + name +
" Is the name spelled correctly?");
}
return location;
}
public void setBlendFunc(BlendFactor sFactor, BlendFactor dFactor) {
// Optimize for (ONE, ZERO) -- that's the same as no blending.
if (sFactor == BlendFactor.ONE && dFactor == BlendFactor.ZERO) {
mRenderState.mEnableBlend = false;
} else {
mRenderState.mEnableBlend = true;
mRenderState.mBlendColorSFactor = sFactor;
mRenderState.mBlendColorDFactor = dFactor;
}
}
} | [
"public",
"class",
"Material",
"{",
"private",
"static",
"final",
"String",
"TAG",
"=",
"\"",
"Material",
"\"",
";",
"/**\n * Defines which component types are accepted.\n * OpenGL ES simply has these as global constants but we want to type check.\n * According to some sources (not benchmarked), enums can take up space\n * and are slower. Investigate these if we see related performance issues.\n */",
"public",
"enum",
"AttrComponentType",
"{",
"BYTE",
"(",
"GLES20",
".",
"GL_BYTE",
")",
",",
"UNSIGNED_BYTE",
"(",
"GLES20",
".",
"GL_UNSIGNED_BYTE",
")",
",",
"SHORT",
"(",
"GLES20",
".",
"GL_SHORT",
")",
",",
"UNSIGNED_SHORT",
"(",
"GLES20",
".",
"GL_UNSIGNED_SHORT",
")",
",",
"FIXED",
"(",
"GLES20",
".",
"GL_FIXED",
")",
",",
"FLOAT",
"(",
"GLES20",
".",
"GL_FLOAT",
")",
";",
"private",
"final",
"int",
"mGlComponentType",
";",
"private",
"AttrComponentType",
"(",
"int",
"glComponentType",
")",
"{",
"mGlComponentType",
"=",
"glComponentType",
";",
"}",
"protected",
"int",
"getGlType",
"(",
")",
"{",
"return",
"mGlComponentType",
";",
"}",
"}",
"/**\n * Defines which blend types are accepted.\n * OpenGL ES simply has these as global constants but we want to type check.\n */",
"public",
"enum",
"BlendFactor",
"{",
"ZERO",
"(",
"GLES20",
".",
"GL_ZERO",
")",
",",
"ONE",
"(",
"GLES20",
".",
"GL_ONE",
")",
",",
"SRC_COLOR",
"(",
"GLES20",
".",
"GL_SRC_COLOR",
")",
",",
"ONE_MINUS_SRC_COLOR",
"(",
"GLES20",
".",
"GL_ONE_MINUS_SRC_COLOR",
")",
",",
"DST_COLOR",
"(",
"GLES20",
".",
"GL_DST_COLOR",
")",
",",
"ONE_MINUS_DST_COLOR",
"(",
"GLES20",
".",
"GL_ONE_MINUS_DST_COLOR",
")",
",",
"SRC_ALPHA",
"(",
"GLES20",
".",
"GL_SRC_ALPHA",
")",
",",
"ONE_MINUS_SRC_ALPHA",
"(",
"GLES20",
".",
"GL_ONE_MINUS_SRC_ALPHA",
")",
",",
"DST_ALPHA",
"(",
"GLES20",
".",
"GL_DST_ALPHA",
")",
",",
"ONE_MINUS_DST_ALPHA",
"(",
"GLES20",
".",
"GL_ONE_MINUS_DST_ALPHA",
")",
",",
"CONSTANT_COLOR",
"(",
"GLES20",
".",
"GL_CONSTANT_COLOR",
")",
",",
"ONE_MINUS_CONSTANT_COLOR",
"(",
"GLES20",
".",
"GL_ONE_MINUS_CONSTANT_COLOR",
")",
",",
"CONSTANT_ALPHA",
"(",
"GLES20",
".",
"GL_CONSTANT_ALPHA",
")",
",",
"ONE_MINUS_CONSTANT_ALPHA",
"(",
"GLES20",
".",
"GL_ONE_MINUS_CONSTANT_ALPHA",
")",
";",
"private",
"final",
"int",
"mGlBlendFactor",
";",
"private",
"BlendFactor",
"(",
"int",
"glBlendFactor",
")",
"{",
"mGlBlendFactor",
"=",
"glBlendFactor",
";",
"}",
"protected",
"int",
"getGlType",
"(",
")",
"{",
"return",
"mGlBlendFactor",
";",
"}",
"}",
"/**\n * A class for defining the specific attribute's extra info\n * like type, stride, etc\n */",
"public",
"class",
"AttributeInfo",
"{",
"String",
"mName",
";",
"int",
"mNumComponents",
";",
"AttrComponentType",
"mComponentType",
";",
"int",
"mComponentSize",
";",
"boolean",
"mNormalized",
";",
"int",
"mStride",
";",
"int",
"mLocation",
";",
"public",
"AttributeInfo",
"(",
"String",
"name",
",",
"int",
"numComponents",
",",
"AttrComponentType",
"componentType",
",",
"int",
"componentSize",
",",
"boolean",
"normalized",
",",
"int",
"stride",
",",
"int",
"location",
")",
"{",
"mName",
"=",
"name",
";",
"mNumComponents",
"=",
"numComponents",
";",
"mComponentType",
"=",
"componentType",
";",
"mComponentSize",
"=",
"componentSize",
";",
"mNormalized",
"=",
"normalized",
";",
"mStride",
"=",
"stride",
";",
"mLocation",
"=",
"location",
";",
"if",
"(",
"location",
"<",
"0",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"",
"Invalid vertex attribute location",
"\"",
"+",
"name",
"+",
"\"",
"! Is the name spelled correctly?",
"\"",
")",
";",
"}",
"}",
"}",
"/**\n * A class for storing render states to be set at the beginning of render.\n */",
"private",
"class",
"RenderState",
"{",
"boolean",
"mEnableBlend",
"=",
"false",
";",
"BlendFactor",
"mBlendColorSFactor",
"=",
"BlendFactor",
".",
"ONE",
";",
"BlendFactor",
"mBlendColorDFactor",
"=",
"BlendFactor",
".",
"ZERO",
";",
"}",
"protected",
"ShaderProgram",
"mShader",
"=",
"null",
";",
"private",
"Map",
"<",
"String",
",",
"AttributeInfo",
">",
"mVertexAttributes",
"=",
"new",
"HashMap",
"<",
"String",
",",
"AttributeInfo",
">",
"(",
")",
";",
"private",
"Map",
"<",
"String",
",",
"Texture",
">",
"mTextures",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Texture",
">",
"(",
"1",
")",
";",
"private",
"RenderState",
"mRenderState",
"=",
"new",
"RenderState",
"(",
")",
";",
"public",
"Material",
"(",
"ShaderProgram",
"shader",
")",
"{",
"if",
"(",
"shader",
"!=",
"null",
"&&",
"shader",
".",
"isShaderCompiled",
"(",
")",
")",
"{",
"mShader",
"=",
"shader",
";",
"}",
"else",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"",
"ShaderProgram ",
"\"",
"+",
"shader",
"+",
"\"",
" is not valid! Failed to ",
"\"",
"+",
"\"",
"assign to new Material.",
"\"",
")",
";",
"}",
"}",
"public",
"AttributeInfo",
"addAttribute",
"(",
"String",
"name",
",",
"int",
"numComponents",
",",
"AttrComponentType",
"componentType",
",",
"int",
"componentSize",
",",
"boolean",
"normalized",
",",
"int",
"stride",
")",
"{",
"int",
"location",
"=",
"mShader",
".",
"getAttributeLocation",
"(",
"name",
")",
";",
"AttributeInfo",
"attr",
"=",
"new",
"AttributeInfo",
"(",
"name",
",",
"numComponents",
",",
"componentType",
",",
"componentSize",
",",
"normalized",
",",
"stride",
",",
"location",
")",
";",
"mVertexAttributes",
".",
"put",
"(",
"name",
",",
"attr",
")",
";",
"return",
"attr",
";",
"}",
"public",
"void",
"addTexture",
"(",
"String",
"textureUniformName",
",",
"Texture",
"texture",
")",
"{",
"mTextures",
".",
"put",
"(",
"textureUniformName",
",",
"texture",
")",
";",
"if",
"(",
"GLES20",
".",
"GL_TEXTURE0",
"+",
"mTextures",
".",
"size",
"(",
")",
">",
"GLES20",
".",
"GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"",
"Too many textures in material! Failed to add: ",
"\"",
"+",
"texture",
")",
";",
"}",
"}",
"public",
"void",
"beginRender",
"(",
")",
"{",
"mShader",
".",
"beginRender",
"(",
")",
";",
"if",
"(",
"mRenderState",
".",
"mEnableBlend",
")",
"{",
"GLES20",
".",
"glEnable",
"(",
"GLES20",
".",
"GL_BLEND",
")",
";",
"GLES20",
".",
"glBlendFunc",
"(",
"mRenderState",
".",
"mBlendColorSFactor",
".",
"getGlType",
"(",
")",
",",
"mRenderState",
".",
"mBlendColorDFactor",
".",
"getGlType",
"(",
")",
")",
";",
"}",
"for",
"(",
"AttributeInfo",
"attr",
":",
"mVertexAttributes",
".",
"values",
"(",
")",
")",
"{",
"GLES20",
".",
"glEnableVertexAttribArray",
"(",
"attr",
".",
"mLocation",
")",
";",
"}",
"int",
"textureIdx",
"=",
"0",
";",
"for",
"(",
"Entry",
"<",
"String",
",",
"Texture",
">",
"texture",
":",
"mTextures",
".",
"entrySet",
"(",
")",
")",
"{",
"GLES20",
".",
"glActiveTexture",
"(",
"GLES20",
".",
"GL_TEXTURE0",
"+",
"textureIdx",
")",
";",
"GLES20",
".",
"glBindTexture",
"(",
"GLES20",
".",
"GL_TEXTURE_2D",
",",
"texture",
".",
"getValue",
"(",
")",
".",
"getTextureId",
"(",
")",
")",
";",
"GLES20",
".",
"glUniform1i",
"(",
"getUniformLocation",
"(",
"texture",
".",
"getKey",
"(",
")",
")",
",",
"textureIdx",
")",
";",
"++",
"textureIdx",
";",
"}",
"}",
"public",
"void",
"endRender",
"(",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"mTextures",
".",
"size",
"(",
")",
";",
"++",
"i",
")",
"{",
"GLES20",
".",
"glActiveTexture",
"(",
"GLES20",
".",
"GL_TEXTURE0",
"+",
"i",
")",
";",
"GLES20",
".",
"glBindTexture",
"(",
"GLES20",
".",
"GL_TEXTURE_2D",
",",
"0",
")",
";",
"}",
"for",
"(",
"AttributeInfo",
"attr",
":",
"mVertexAttributes",
".",
"values",
"(",
")",
")",
"{",
"GLES20",
".",
"glDisableVertexAttribArray",
"(",
"attr",
".",
"mLocation",
")",
";",
"}",
"if",
"(",
"mRenderState",
".",
"mEnableBlend",
")",
"{",
"GLES20",
".",
"glDisable",
"(",
"GLES20",
".",
"GL_BLEND",
")",
";",
"}",
"mShader",
".",
"endRender",
"(",
")",
";",
"}",
"public",
"void",
"setVertexAttributeBuffer",
"(",
"AttributeInfo",
"attr",
",",
"Buffer",
"buffer",
",",
"int",
"offset",
")",
"{",
"buffer",
".",
"position",
"(",
"offset",
")",
";",
"GLES20",
".",
"glVertexAttribPointer",
"(",
"attr",
".",
"mLocation",
",",
"attr",
".",
"mNumComponents",
",",
"attr",
".",
"mComponentType",
".",
"getGlType",
"(",
")",
",",
"attr",
".",
"mNormalized",
",",
"attr",
".",
"mStride",
",",
"buffer",
")",
";",
"}",
"public",
"void",
"setVertexAttributeBuffer",
"(",
"String",
"name",
",",
"Buffer",
"buffer",
",",
"int",
"offset",
")",
"{",
"AttributeInfo",
"attr",
"=",
"mVertexAttributes",
".",
"get",
"(",
"name",
")",
";",
"buffer",
".",
"position",
"(",
"offset",
")",
";",
"GLES20",
".",
"glVertexAttribPointer",
"(",
"attr",
".",
"mLocation",
",",
"attr",
".",
"mNumComponents",
",",
"attr",
".",
"mComponentType",
".",
"getGlType",
"(",
")",
",",
"attr",
".",
"mNormalized",
",",
"attr",
".",
"mStride",
",",
"buffer",
")",
";",
"}",
"/**\n * Provide access to the ShaderProgram function\n */",
"public",
"int",
"getUniformLocation",
"(",
"String",
"name",
")",
"{",
"int",
"location",
"=",
"mShader",
".",
"getUniformLocation",
"(",
"name",
")",
";",
"if",
"(",
"location",
"<",
"0",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"",
"Invalid uniform location for ",
"\"",
"+",
"name",
"+",
"\"",
" Is the name spelled correctly?",
"\"",
")",
";",
"}",
"return",
"location",
";",
"}",
"public",
"void",
"setBlendFunc",
"(",
"BlendFactor",
"sFactor",
",",
"BlendFactor",
"dFactor",
")",
"{",
"if",
"(",
"sFactor",
"==",
"BlendFactor",
".",
"ONE",
"&&",
"dFactor",
"==",
"BlendFactor",
".",
"ZERO",
")",
"{",
"mRenderState",
".",
"mEnableBlend",
"=",
"false",
";",
"}",
"else",
"{",
"mRenderState",
".",
"mEnableBlend",
"=",
"true",
";",
"mRenderState",
".",
"mBlendColorSFactor",
"=",
"sFactor",
";",
"mRenderState",
".",
"mBlendColorDFactor",
"=",
"dFactor",
";",
"}",
"}",
"}"
] | A layer on top of ShaderProgram to store specific parameters to be reused. | [
"A",
"layer",
"on",
"top",
"of",
"ShaderProgram",
"to",
"store",
"specific",
"parameters",
"to",
"be",
"reused",
"."
] | [
"// These defaults are the OpenGL defaults",
"/// Member variables",
"/// Member methods",
"// Don't take the shader if it's not generated correctly",
"// Set render states",
"// enable all vertex attributes we have info on",
"// enable all textures",
"// Set the correct uniform",
"// Get next texture index",
"// disable all textures",
"// enable all vertex attributes",
"// Reset render states",
"// Optimize for (ONE, ZERO) -- that's the same as no blending."
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
844e89b27ce7cbc002e9eaf2f234345d05537e7e | ykulbashian/LiquidSurface | liquidview/src/main/java/com/google/fpl/liquidfunpaint/shader/Material.java | [
"Apache-2.0"
] | Java | AttributeInfo | /**
* A class for defining the specific attribute's extra info
* like type, stride, etc
*/ | A class for defining the specific attribute's extra info
like type, stride, etc | [
"A",
"class",
"for",
"defining",
"the",
"specific",
"attribute",
"'",
"s",
"extra",
"info",
"like",
"type",
"stride",
"etc"
] | public class AttributeInfo {
String mName;
int mNumComponents;
AttrComponentType mComponentType;
int mComponentSize;
boolean mNormalized;
int mStride;
int mLocation;
public AttributeInfo(
String name, int numComponents, AttrComponentType componentType,
int componentSize, boolean normalized, int stride, int location) {
mName = name;
mNumComponents = numComponents;
mComponentType = componentType;
mComponentSize = componentSize;
mNormalized = normalized;
mStride = stride;
mLocation = location;
if (location < 0) {
Log.e(TAG, "Invalid vertex attribute location" + name +
"! Is the name spelled correctly?");
}
}
} | [
"public",
"class",
"AttributeInfo",
"{",
"String",
"mName",
";",
"int",
"mNumComponents",
";",
"AttrComponentType",
"mComponentType",
";",
"int",
"mComponentSize",
";",
"boolean",
"mNormalized",
";",
"int",
"mStride",
";",
"int",
"mLocation",
";",
"public",
"AttributeInfo",
"(",
"String",
"name",
",",
"int",
"numComponents",
",",
"AttrComponentType",
"componentType",
",",
"int",
"componentSize",
",",
"boolean",
"normalized",
",",
"int",
"stride",
",",
"int",
"location",
")",
"{",
"mName",
"=",
"name",
";",
"mNumComponents",
"=",
"numComponents",
";",
"mComponentType",
"=",
"componentType",
";",
"mComponentSize",
"=",
"componentSize",
";",
"mNormalized",
"=",
"normalized",
";",
"mStride",
"=",
"stride",
";",
"mLocation",
"=",
"location",
";",
"if",
"(",
"location",
"<",
"0",
")",
"{",
"Log",
".",
"e",
"(",
"TAG",
",",
"\"",
"Invalid vertex attribute location",
"\"",
"+",
"name",
"+",
"\"",
"! Is the name spelled correctly?",
"\"",
")",
";",
"}",
"}",
"}"
] | A class for defining the specific attribute's extra info
like type, stride, etc | [
"A",
"class",
"for",
"defining",
"the",
"specific",
"attribute",
"'",
"s",
"extra",
"info",
"like",
"type",
"stride",
"etc"
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
844e89b27ce7cbc002e9eaf2f234345d05537e7e | ykulbashian/LiquidSurface | liquidview/src/main/java/com/google/fpl/liquidfunpaint/shader/Material.java | [
"Apache-2.0"
] | Java | RenderState | /**
* A class for storing render states to be set at the beginning of render.
*/ | A class for storing render states to be set at the beginning of render. | [
"A",
"class",
"for",
"storing",
"render",
"states",
"to",
"be",
"set",
"at",
"the",
"beginning",
"of",
"render",
"."
] | private class RenderState {
boolean mEnableBlend = false;
// These defaults are the OpenGL defaults
BlendFactor mBlendColorSFactor = BlendFactor.ONE;
BlendFactor mBlendColorDFactor = BlendFactor.ZERO;
} | [
"private",
"class",
"RenderState",
"{",
"boolean",
"mEnableBlend",
"=",
"false",
";",
"BlendFactor",
"mBlendColorSFactor",
"=",
"BlendFactor",
".",
"ONE",
";",
"BlendFactor",
"mBlendColorDFactor",
"=",
"BlendFactor",
".",
"ZERO",
";",
"}"
] | A class for storing render states to be set at the beginning of render. | [
"A",
"class",
"for",
"storing",
"render",
"states",
"to",
"be",
"set",
"at",
"the",
"beginning",
"of",
"render",
"."
] | [
"// These defaults are the OpenGL defaults"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
844ee24b0e39476401d129f354be7dd51c2a35ce | Tagar/dremio-oss | sabot/kernel/src/main/java/com/dremio/exec/store/avro/AvroTypeHelper.java | [
"Apache-2.0"
] | Java | AvroTypeHelper | /**
* Utility class for working with Avro data types.
*/ | Utility class for working with Avro data types. | [
"Utility",
"class",
"for",
"working",
"with",
"Avro",
"data",
"types",
"."
] | public final class AvroTypeHelper {
// XXX - Decide what to do about Avro's NULL type
/*
public static final MajorType MAJOR_TYPE_NULL_OPTIONAL = Types.optional(MinorType.NULL);
public static final MajorType MAJOR_TYPE_NULL_REQUIRED = Types.required(MinorType.NULL);
public static final MajorType MAJOR_TYPE_NULL_REPEATED = Types.repeated(MinorType.NULL);
*/
public static final MajorType MAJOR_TYPE_BOOL_OPTIONAL = Types.optional(MinorType.UINT1);
public static final MajorType MAJOR_TYPE_BOOL_REQUIRED = Types.required(MinorType.UINT1);
public static final MajorType MAJOR_TYPE_BOOL_REPEATED = Types.repeated(MinorType.UINT1);
public static final MajorType MAJOR_TYPE_INT_OPTIONAL = Types.optional(MinorType.INT);
public static final MajorType MAJOR_TYPE_INT_REQUIRED = Types.required(MinorType.INT);
public static final MajorType MAJOR_TYPE_INT_REPEATED = Types.repeated(MinorType.INT);
public static final MajorType MAJOR_TYPE_BIGINT_OPTIONAL = Types.optional(MinorType.BIGINT);
public static final MajorType MAJOR_TYPE_BIGINT_REQUIRED = Types.required(MinorType.BIGINT);
public static final MajorType MAJOR_TYPE_BIGINT_REPEATED = Types.repeated(MinorType.BIGINT);
public static final MajorType MAJOR_TYPE_FLOAT4_OPTIONAL = Types.optional(MinorType.FLOAT4);
public static final MajorType MAJOR_TYPE_FLOAT4_REQUIRED = Types.required(MinorType.FLOAT4);
public static final MajorType MAJOR_TYPE_FLOAT4_REPEATED = Types.repeated(MinorType.FLOAT4);
public static final MajorType MAJOR_TYPE_FLOAT8_OPTIONAL = Types.optional(MinorType.FLOAT8);
public static final MajorType MAJOR_TYPE_FLOAT8_REQUIRED = Types.required(MinorType.FLOAT8);
public static final MajorType MAJOR_TYPE_FLOAT8_REPEATED = Types.repeated(MinorType.FLOAT8);
public static final MajorType MAJOR_TYPE_VARBINARY_OPTIONAL = Types.optional(MinorType.VARBINARY);
public static final MajorType MAJOR_TYPE_VARBINARY_REQUIRED = Types.required(MinorType.VARBINARY);
public static final MajorType MAJOR_TYPE_VARBINARY_REPEATED = Types.repeated(MinorType.VARBINARY);
public static final MajorType MAJOR_TYPE_VARCHAR_OPTIONAL = Types.optional(MinorType.VARCHAR);
public static final MajorType MAJOR_TYPE_VARCHAR_REQUIRED = Types.required(MinorType.VARCHAR);
public static final MajorType MAJOR_TYPE_VARCHAR_REPEATED = Types.repeated(MinorType.VARCHAR);
private static final String UNSUPPORTED = "Unsupported type: %s [%s]";
private AvroTypeHelper() { }
/**
* Maintains a mapping between Avro types and Dremio types. Given an Avro data
* type, this method will return the corresponding field major type.
*
* @param field Avro field
* @return Major type or null if no corresponding type
*/
public static MajorType getFieldMajorType(final Field field, final DataMode mode) {
return getFieldMajorType(field.schema().getType(), mode);
}
/**
* Maintains a mapping between Avro types and Dremio types. Given an Avro data
* type, this method will return the corresponding Dremio field major type.
*
* @param type Avro type
* @param mode Data mode
* @return Major type or null if no corresponding type
*/
public static MajorType getFieldMajorType(final Type type, final DataMode mode) {
switch (type) {
case MAP:
case RECORD:
case ENUM:
case UNION:
throw new UnsupportedOperationException("Complex types are unimplemented");
case NULL:
/*
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_NULL_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_NULL_REQUIRED;
case REPEATED:
return MAJOR_TYPE_NULL_REPEATED;
}
break;
*/
throw new UnsupportedOperationException(String.format(UNSUPPORTED, type.getName(), mode.name()));
case ARRAY:
break;
case BOOLEAN:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_BOOL_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_BOOL_REQUIRED;
case REPEATED:
return MAJOR_TYPE_BOOL_REPEATED;
}
break;
case INT:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_INT_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_INT_REQUIRED;
case REPEATED:
return MAJOR_TYPE_INT_REPEATED;
}
break;
case LONG:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_BIGINT_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_BIGINT_REQUIRED;
case REPEATED:
return MAJOR_TYPE_BIGINT_REPEATED;
}
break;
case FLOAT:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_FLOAT4_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_FLOAT4_REQUIRED;
case REPEATED:
return MAJOR_TYPE_FLOAT4_REPEATED;
}
break;
case DOUBLE:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_FLOAT8_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_FLOAT8_REQUIRED;
case REPEATED:
return MAJOR_TYPE_FLOAT8_REPEATED;
}
break;
case BYTES:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_VARBINARY_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_VARBINARY_REQUIRED;
case REPEATED:
return MAJOR_TYPE_VARBINARY_REPEATED;
}
break;
case STRING:
switch (mode) {
case OPTIONAL:
return MAJOR_TYPE_VARCHAR_OPTIONAL;
case REQUIRED:
return MAJOR_TYPE_VARCHAR_REQUIRED;
case REPEATED:
return MAJOR_TYPE_VARCHAR_REPEATED;
}
break;
default:
throw new UnsupportedOperationException(String.format(UNSUPPORTED, type.getName(), mode.name()));
}
throw new UnsupportedOperationException(String.format(UNSUPPORTED, type.getName(), mode.name()));
}
} | [
"public",
"final",
"class",
"AvroTypeHelper",
"{",
"/*\n public static final MajorType MAJOR_TYPE_NULL_OPTIONAL = Types.optional(MinorType.NULL);\n public static final MajorType MAJOR_TYPE_NULL_REQUIRED = Types.required(MinorType.NULL);\n public static final MajorType MAJOR_TYPE_NULL_REPEATED = Types.repeated(MinorType.NULL);\n */",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BOOL_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"UINT1",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BOOL_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"UINT1",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BOOL_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"UINT1",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_INT_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"INT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_INT_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"INT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_INT_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"INT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BIGINT_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"BIGINT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BIGINT_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"BIGINT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_BIGINT_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"BIGINT",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT4_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"FLOAT4",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT4_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"FLOAT4",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT4_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"FLOAT4",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT8_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"FLOAT8",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT8_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"FLOAT8",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_FLOAT8_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"FLOAT8",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARBINARY_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"VARBINARY",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARBINARY_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"VARBINARY",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARBINARY_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"VARBINARY",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARCHAR_OPTIONAL",
"=",
"Types",
".",
"optional",
"(",
"MinorType",
".",
"VARCHAR",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARCHAR_REQUIRED",
"=",
"Types",
".",
"required",
"(",
"MinorType",
".",
"VARCHAR",
")",
";",
"public",
"static",
"final",
"MajorType",
"MAJOR_TYPE_VARCHAR_REPEATED",
"=",
"Types",
".",
"repeated",
"(",
"MinorType",
".",
"VARCHAR",
")",
";",
"private",
"static",
"final",
"String",
"UNSUPPORTED",
"=",
"\"",
"Unsupported type: %s [%s]",
"\"",
";",
"private",
"AvroTypeHelper",
"(",
")",
"{",
"}",
"/**\n * Maintains a mapping between Avro types and Dremio types. Given an Avro data\n * type, this method will return the corresponding field major type.\n *\n * @param field Avro field\n * @return Major type or null if no corresponding type\n */",
"public",
"static",
"MajorType",
"getFieldMajorType",
"(",
"final",
"Field",
"field",
",",
"final",
"DataMode",
"mode",
")",
"{",
"return",
"getFieldMajorType",
"(",
"field",
".",
"schema",
"(",
")",
".",
"getType",
"(",
")",
",",
"mode",
")",
";",
"}",
"/**\n * Maintains a mapping between Avro types and Dremio types. Given an Avro data\n * type, this method will return the corresponding Dremio field major type.\n *\n * @param type Avro type\n * @param mode Data mode\n * @return Major type or null if no corresponding type\n */",
"public",
"static",
"MajorType",
"getFieldMajorType",
"(",
"final",
"Type",
"type",
",",
"final",
"DataMode",
"mode",
")",
"{",
"switch",
"(",
"type",
")",
"{",
"case",
"MAP",
":",
"case",
"RECORD",
":",
"case",
"ENUM",
":",
"case",
"UNION",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"",
"Complex types are unimplemented",
"\"",
")",
";",
"case",
"NULL",
":",
"/*\n switch (mode) {\n case OPTIONAL:\n return MAJOR_TYPE_NULL_OPTIONAL;\n case REQUIRED:\n return MAJOR_TYPE_NULL_REQUIRED;\n case REPEATED:\n return MAJOR_TYPE_NULL_REPEATED;\n }\n break;\n */",
"throw",
"new",
"UnsupportedOperationException",
"(",
"String",
".",
"format",
"(",
"UNSUPPORTED",
",",
"type",
".",
"getName",
"(",
")",
",",
"mode",
".",
"name",
"(",
")",
")",
")",
";",
"case",
"ARRAY",
":",
"break",
";",
"case",
"BOOLEAN",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_BOOL_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_BOOL_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_BOOL_REPEATED",
";",
"}",
"break",
";",
"case",
"INT",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_INT_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_INT_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_INT_REPEATED",
";",
"}",
"break",
";",
"case",
"LONG",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_BIGINT_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_BIGINT_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_BIGINT_REPEATED",
";",
"}",
"break",
";",
"case",
"FLOAT",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_FLOAT4_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_FLOAT4_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_FLOAT4_REPEATED",
";",
"}",
"break",
";",
"case",
"DOUBLE",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_FLOAT8_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_FLOAT8_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_FLOAT8_REPEATED",
";",
"}",
"break",
";",
"case",
"BYTES",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_VARBINARY_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_VARBINARY_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_VARBINARY_REPEATED",
";",
"}",
"break",
";",
"case",
"STRING",
":",
"switch",
"(",
"mode",
")",
"{",
"case",
"OPTIONAL",
":",
"return",
"MAJOR_TYPE_VARCHAR_OPTIONAL",
";",
"case",
"REQUIRED",
":",
"return",
"MAJOR_TYPE_VARCHAR_REQUIRED",
";",
"case",
"REPEATED",
":",
"return",
"MAJOR_TYPE_VARCHAR_REPEATED",
";",
"}",
"break",
";",
"default",
":",
"throw",
"new",
"UnsupportedOperationException",
"(",
"String",
".",
"format",
"(",
"UNSUPPORTED",
",",
"type",
".",
"getName",
"(",
")",
",",
"mode",
".",
"name",
"(",
")",
")",
")",
";",
"}",
"throw",
"new",
"UnsupportedOperationException",
"(",
"String",
".",
"format",
"(",
"UNSUPPORTED",
",",
"type",
".",
"getName",
"(",
")",
",",
"mode",
".",
"name",
"(",
")",
")",
")",
";",
"}",
"}"
] | Utility class for working with Avro data types. | [
"Utility",
"class",
"for",
"working",
"with",
"Avro",
"data",
"types",
"."
] | [
"// XXX - Decide what to do about Avro's NULL type"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8452683386ff3f5395dff3cfc46c6fe32fa2ca68 | voostindie/sprox | src/main/java/nl/ulso/sprox/impl/ReflectionUtil.java | [
"MIT"
] | Java | ReflectionUtil | /**
* Provides utility methods for reflection.
*/ | Provides utility methods for reflection. | [
"Provides",
"utility",
"methods",
"for",
"reflection",
"."
] | final class ReflectionUtil {
private static final Map<Type, Class> PRIMITIVE_PARAMETER_TYPES = Map.of(
Boolean.class, Boolean.TYPE,
Byte.class, Byte.TYPE,
Character.class, Character.TYPE,
Double.class, Double.TYPE,
Float.class, Float.TYPE,
Integer.class, Integer.TYPE,
Long.class, Long.TYPE,
Short.class, Short.TYPE);
private ReflectionUtil() {
}
/**
* Resolves the {@link Class} that corresponds with a {@link Type}.
* <p>
* {@code Class} is an implementation of {@code Type} but, of course, not every {@code Type} is a {@code Class}.
* Case in point here are primitive types. These can appear as method parameters.
*
* @param objectType Type to resolve.
* @return Corresponding class.
*/
static Class resolveObjectClass(Type objectType) {
final Class type = PRIMITIVE_PARAMETER_TYPES.get(objectType);
if (type != null) {
return type;
}
if (isOptionalType(objectType)) {
return resolveObjectClass(extractTypeFromOptional(objectType));
}
try {
return (Class) objectType;
} catch (ClassCastException e) {
throw new IllegalStateException("Cannot resolve object class from type: " + objectType, e);
}
}
static boolean isOptionalType(Type objectType) {
if (objectType instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) objectType;
return parameterizedType.getRawType().equals(Optional.class);
}
return false;
}
static Type extractTypeFromOptional(Type optionalType) {
return ((ParameterizedType) optionalType).getActualTypeArguments()[0];
}
static boolean isListType(Type objectType) {
if (objectType instanceof ParameterizedType) {
final ParameterizedType parameterizedType = (ParameterizedType) objectType;
return parameterizedType.getRawType().equals(List.class);
}
return false;
}
static Type extractTypeFromList(Type listType) {
return ((ParameterizedType) listType).getActualTypeArguments()[0];
}
} | [
"final",
"class",
"ReflectionUtil",
"{",
"private",
"static",
"final",
"Map",
"<",
"Type",
",",
"Class",
">",
"PRIMITIVE_PARAMETER_TYPES",
"=",
"Map",
".",
"of",
"(",
"Boolean",
".",
"class",
",",
"Boolean",
".",
"TYPE",
",",
"Byte",
".",
"class",
",",
"Byte",
".",
"TYPE",
",",
"Character",
".",
"class",
",",
"Character",
".",
"TYPE",
",",
"Double",
".",
"class",
",",
"Double",
".",
"TYPE",
",",
"Float",
".",
"class",
",",
"Float",
".",
"TYPE",
",",
"Integer",
".",
"class",
",",
"Integer",
".",
"TYPE",
",",
"Long",
".",
"class",
",",
"Long",
".",
"TYPE",
",",
"Short",
".",
"class",
",",
"Short",
".",
"TYPE",
")",
";",
"private",
"ReflectionUtil",
"(",
")",
"{",
"}",
"/**\n * Resolves the {@link Class} that corresponds with a {@link Type}.\n * <p>\n * {@code Class} is an implementation of {@code Type} but, of course, not every {@code Type} is a {@code Class}.\n * Case in point here are primitive types. These can appear as method parameters.\n *\n * @param objectType Type to resolve.\n * @return Corresponding class.\n */",
"static",
"Class",
"resolveObjectClass",
"(",
"Type",
"objectType",
")",
"{",
"final",
"Class",
"type",
"=",
"PRIMITIVE_PARAMETER_TYPES",
".",
"get",
"(",
"objectType",
")",
";",
"if",
"(",
"type",
"!=",
"null",
")",
"{",
"return",
"type",
";",
"}",
"if",
"(",
"isOptionalType",
"(",
"objectType",
")",
")",
"{",
"return",
"resolveObjectClass",
"(",
"extractTypeFromOptional",
"(",
"objectType",
")",
")",
";",
"}",
"try",
"{",
"return",
"(",
"Class",
")",
"objectType",
";",
"}",
"catch",
"(",
"ClassCastException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"",
"Cannot resolve object class from type: ",
"\"",
"+",
"objectType",
",",
"e",
")",
";",
"}",
"}",
"static",
"boolean",
"isOptionalType",
"(",
"Type",
"objectType",
")",
"{",
"if",
"(",
"objectType",
"instanceof",
"ParameterizedType",
")",
"{",
"final",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"objectType",
";",
"return",
"parameterizedType",
".",
"getRawType",
"(",
")",
".",
"equals",
"(",
"Optional",
".",
"class",
")",
";",
"}",
"return",
"false",
";",
"}",
"static",
"Type",
"extractTypeFromOptional",
"(",
"Type",
"optionalType",
")",
"{",
"return",
"(",
"(",
"ParameterizedType",
")",
"optionalType",
")",
".",
"getActualTypeArguments",
"(",
")",
"[",
"0",
"]",
";",
"}",
"static",
"boolean",
"isListType",
"(",
"Type",
"objectType",
")",
"{",
"if",
"(",
"objectType",
"instanceof",
"ParameterizedType",
")",
"{",
"final",
"ParameterizedType",
"parameterizedType",
"=",
"(",
"ParameterizedType",
")",
"objectType",
";",
"return",
"parameterizedType",
".",
"getRawType",
"(",
")",
".",
"equals",
"(",
"List",
".",
"class",
")",
";",
"}",
"return",
"false",
";",
"}",
"static",
"Type",
"extractTypeFromList",
"(",
"Type",
"listType",
")",
"{",
"return",
"(",
"(",
"ParameterizedType",
")",
"listType",
")",
".",
"getActualTypeArguments",
"(",
")",
"[",
"0",
"]",
";",
"}",
"}"
] | Provides utility methods for reflection. | [
"Provides",
"utility",
"methods",
"for",
"reflection",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
84598679147632cc5571c44d739c374a3e970366 | sakamoto-neko/butterfly | butterflydao/src/main/java/com/buttongames/butterflydao/hibernate/dao/impl/ddr16/GoldenLeagueStatusDao.java | [
"Apache-2.0"
] | Java | GoldenLeagueStatusDao | /**
* DAO for interacting with <code>GoldenLeagueStatus</code> objects in the database.
* @author skogaby ([email protected])
*/ | DAO for interacting with GoldenLeagueStatus objects in the database. | [
"DAO",
"for",
"interacting",
"with",
"GoldenLeagueStatus",
"objects",
"in",
"the",
"database",
"."
] | @Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Repository
@Transactional
public class GoldenLeagueStatusDao extends AbstractHibernateDao<GoldenLeagueStatus> {
@Autowired
public GoldenLeagueStatusDao(final SessionFactory sessionFactory) {
super(sessionFactory);
setClazz(GoldenLeagueStatus.class);
}
/**
* Finds Golden League statuses by period.
* @param period The Golden League period of the record
* @return A list of matching records
*/
public List<GoldenLeagueStatus> findByPeriod(@GraphQLArgument(name = "period") final GoldenLeaguePeriod period) {
final Query<GoldenLeagueStatus> query = this.getCurrentSession().createQuery("from GoldenLeagueStatus where leaguePeriod = :leaguePeriod");
query.setParameter("leaguePeriod", period);
return query.getResultList();
}
/**
* Finds Golden League statuses by period and class.
* @param period The Golden League period of the record
* @param goldenLeagueClass The class to search for statuses for (1 = bronze, 2 = silver, 3 = gold)
* @return A matching re
*/
public List<GoldenLeagueStatus> findByPeriodAndClass(final GoldenLeaguePeriod period,
final int goldenLeagueClass) {
final Query<GoldenLeagueStatus> query = this.getCurrentSession().createQuery("from GoldenLeagueStatus where leaguePeriod = :leaguePeriod and goldenLeagueClass = :goldenLeagueClass");
query.setParameter("leaguePeriod", period);
query.setParameter("goldenLeagueClass", goldenLeagueClass);
return query.getResultList();
}
/**
* Finds a Golden League status by its user and period.
* @param user The user of the record
* @param period The Golden League period of the record
* @return A matching record, or null
*/
public GoldenLeagueStatus findByUserAndPeriod(final UserProfile user,
final GoldenLeaguePeriod period) {
final Query<GoldenLeagueStatus> query = this.getCurrentSession()
.createQuery("from GoldenLeagueStatus where user = :user and leaguePeriod = :leaguePeriod")
.setMaxResults(1);
query.setParameter("user", user);
query.setParameter("leaguePeriod", period);
try {
return query.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
} | [
"@",
"Scope",
"(",
"BeanDefinition",
".",
"SCOPE_PROTOTYPE",
")",
"@",
"Repository",
"@",
"Transactional",
"public",
"class",
"GoldenLeagueStatusDao",
"extends",
"AbstractHibernateDao",
"<",
"GoldenLeagueStatus",
">",
"{",
"@",
"Autowired",
"public",
"GoldenLeagueStatusDao",
"(",
"final",
"SessionFactory",
"sessionFactory",
")",
"{",
"super",
"(",
"sessionFactory",
")",
";",
"setClazz",
"(",
"GoldenLeagueStatus",
".",
"class",
")",
";",
"}",
"/**\n * Finds Golden League statuses by period.\n * @param period The Golden League period of the record\n * @return A list of matching records\n */",
"public",
"List",
"<",
"GoldenLeagueStatus",
">",
"findByPeriod",
"(",
"@",
"GraphQLArgument",
"(",
"name",
"=",
"\"",
"period",
"\"",
")",
"final",
"GoldenLeaguePeriod",
"period",
")",
"{",
"final",
"Query",
"<",
"GoldenLeagueStatus",
">",
"query",
"=",
"this",
".",
"getCurrentSession",
"(",
")",
".",
"createQuery",
"(",
"\"",
"from GoldenLeagueStatus where leaguePeriod = :leaguePeriod",
"\"",
")",
";",
"query",
".",
"setParameter",
"(",
"\"",
"leaguePeriod",
"\"",
",",
"period",
")",
";",
"return",
"query",
".",
"getResultList",
"(",
")",
";",
"}",
"/**\n * Finds Golden League statuses by period and class.\n * @param period The Golden League period of the record\n * @param goldenLeagueClass The class to search for statuses for (1 = bronze, 2 = silver, 3 = gold)\n * @return A matching re\n */",
"public",
"List",
"<",
"GoldenLeagueStatus",
">",
"findByPeriodAndClass",
"(",
"final",
"GoldenLeaguePeriod",
"period",
",",
"final",
"int",
"goldenLeagueClass",
")",
"{",
"final",
"Query",
"<",
"GoldenLeagueStatus",
">",
"query",
"=",
"this",
".",
"getCurrentSession",
"(",
")",
".",
"createQuery",
"(",
"\"",
"from GoldenLeagueStatus where leaguePeriod = :leaguePeriod and goldenLeagueClass = :goldenLeagueClass",
"\"",
")",
";",
"query",
".",
"setParameter",
"(",
"\"",
"leaguePeriod",
"\"",
",",
"period",
")",
";",
"query",
".",
"setParameter",
"(",
"\"",
"goldenLeagueClass",
"\"",
",",
"goldenLeagueClass",
")",
";",
"return",
"query",
".",
"getResultList",
"(",
")",
";",
"}",
"/**\n * Finds a Golden League status by its user and period.\n * @param user The user of the record\n * @param period The Golden League period of the record\n * @return A matching record, or null\n */",
"public",
"GoldenLeagueStatus",
"findByUserAndPeriod",
"(",
"final",
"UserProfile",
"user",
",",
"final",
"GoldenLeaguePeriod",
"period",
")",
"{",
"final",
"Query",
"<",
"GoldenLeagueStatus",
">",
"query",
"=",
"this",
".",
"getCurrentSession",
"(",
")",
".",
"createQuery",
"(",
"\"",
"from GoldenLeagueStatus where user = :user and leaguePeriod = :leaguePeriod",
"\"",
")",
".",
"setMaxResults",
"(",
"1",
")",
";",
"query",
".",
"setParameter",
"(",
"\"",
"user",
"\"",
",",
"user",
")",
";",
"query",
".",
"setParameter",
"(",
"\"",
"leaguePeriod",
"\"",
",",
"period",
")",
";",
"try",
"{",
"return",
"query",
".",
"getSingleResult",
"(",
")",
";",
"}",
"catch",
"(",
"NoResultException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"}",
"}"
] | DAO for interacting with <code>GoldenLeagueStatus</code> objects in the database. | [
"DAO",
"for",
"interacting",
"with",
"<code",
">",
"GoldenLeagueStatus<",
"/",
"code",
">",
"objects",
"in",
"the",
"database",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
845a67cf4f2cbf5acbaf09b06997bbc69184cb40 | sibvisions/vaadin-chartjs | src/main/java/com/byteowls/vaadin/chartjs/v3/options/scale/CategoryScale.java | [
"MIT"
] | Java | CategoryScale | /**
* The category scale will be familiar to those who have used v1.0.
* Labels are drawn in from the labels array included in the chart data.
*
* @author [email protected]
*/ | The category scale will be familiar to those who have used v1.0.
Labels are drawn in from the labels array included in the chart data.
| [
"The",
"category",
"scale",
"will",
"be",
"familiar",
"to",
"those",
"who",
"have",
"used",
"v1",
".",
"0",
".",
"Labels",
"are",
"drawn",
"in",
"from",
"the",
"labels",
"array",
"included",
"in",
"the",
"chart",
"data",
"."
] | public class CategoryScale extends BaseScale<CategoryScale> {
private static final long serialVersionUID = 5698788408274123785L;
private CategoryTicks<CategoryScale> categoryTicks;
public CategoryScale() {
type("category");
}
/**
* It defines options for the tick marks that are generated by the axis.
*/
@Override
public CategoryTicks<CategoryScale> ticks() {
if (this.categoryTicks == null) {
this.categoryTicks = new CategoryTicks<>(getThis());
}
return this.categoryTicks;
}
@Override
public CategoryScale getThis() {
return this;
}
@Override
public JsonObject buildJson() {
JsonObject map = super.buildJson();
JUtils.putNotNull(map, "ticks", categoryTicks);
return map;
}
} | [
"public",
"class",
"CategoryScale",
"extends",
"BaseScale",
"<",
"CategoryScale",
">",
"{",
"private",
"static",
"final",
"long",
"serialVersionUID",
"=",
"5698788408274123785L",
";",
"private",
"CategoryTicks",
"<",
"CategoryScale",
">",
"categoryTicks",
";",
"public",
"CategoryScale",
"(",
")",
"{",
"type",
"(",
"\"",
"category",
"\"",
")",
";",
"}",
"/**\n * It defines options for the tick marks that are generated by the axis.\n */",
"@",
"Override",
"public",
"CategoryTicks",
"<",
"CategoryScale",
">",
"ticks",
"(",
")",
"{",
"if",
"(",
"this",
".",
"categoryTicks",
"==",
"null",
")",
"{",
"this",
".",
"categoryTicks",
"=",
"new",
"CategoryTicks",
"<",
">",
"(",
"getThis",
"(",
")",
")",
";",
"}",
"return",
"this",
".",
"categoryTicks",
";",
"}",
"@",
"Override",
"public",
"CategoryScale",
"getThis",
"(",
")",
"{",
"return",
"this",
";",
"}",
"@",
"Override",
"public",
"JsonObject",
"buildJson",
"(",
")",
"{",
"JsonObject",
"map",
"=",
"super",
".",
"buildJson",
"(",
")",
";",
"JUtils",
".",
"putNotNull",
"(",
"map",
",",
"\"",
"ticks",
"\"",
",",
"categoryTicks",
")",
";",
"return",
"map",
";",
"}",
"}"
] | The category scale will be familiar to those who have used v1.0. | [
"The",
"category",
"scale",
"will",
"be",
"familiar",
"to",
"those",
"who",
"have",
"used",
"v1",
".",
"0",
"."
] | [] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
845c75c7a9d41f31791ae9b587826cb8b5ab8257 | omnisci/mapd-core | java/calcite/src/main/java/com/mapd/parser/extension/ddl/SqlAlterUser.java | [
"Apache-2.0"
] | Java | SqlAlterUser | /**
* Class that encapsulates all information associated with a ALTER USER DDL command.
*/ | Class that encapsulates all information associated with a ALTER USER DDL command. | [
"Class",
"that",
"encapsulates",
"all",
"information",
"associated",
"with",
"a",
"ALTER",
"USER",
"DDL",
"command",
"."
] | public class SqlAlterUser extends SqlCustomDdl {
private static final SqlOperator OPERATOR =
new SqlSpecialOperator("ALTER_USER", SqlKind.OTHER_DDL);
@Expose
private String name;
@Expose
HeavyDBOptionsMap options;
public SqlAlterUser(
final SqlParserPos pos, final String name, HeavyDBOptionsMap optionsMap) {
super(OPERATOR, pos);
this.name = name;
this.options = optionsMap;
}
} | [
"public",
"class",
"SqlAlterUser",
"extends",
"SqlCustomDdl",
"{",
"private",
"static",
"final",
"SqlOperator",
"OPERATOR",
"=",
"new",
"SqlSpecialOperator",
"(",
"\"",
"ALTER_USER",
"\"",
",",
"SqlKind",
".",
"OTHER_DDL",
")",
";",
"@",
"Expose",
"private",
"String",
"name",
";",
"@",
"Expose",
"HeavyDBOptionsMap",
"options",
";",
"public",
"SqlAlterUser",
"(",
"final",
"SqlParserPos",
"pos",
",",
"final",
"String",
"name",
",",
"HeavyDBOptionsMap",
"optionsMap",
")",
"{",
"super",
"(",
"OPERATOR",
",",
"pos",
")",
";",
"this",
".",
"name",
"=",
"name",
";",
"this",
".",
"options",
"=",
"optionsMap",
";",
"}",
"}"
] | Class that encapsulates all information associated with a ALTER USER DDL command. | [
"Class",
"that",
"encapsulates",
"all",
"information",
"associated",
"with",
"a",
"ALTER",
"USER",
"DDL",
"command",
"."
] | [] | [
{
"param": "SqlCustomDdl",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "SqlCustomDdl",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
845f5664e1b540d8c61a115a526ac28b40a0db7d | leginee/netbeans | cnd/cnd.toolchain.ui/src/org/netbeans/modules/cnd/api/toolchain/ui/BuildToolsAction.java | [
"Apache-2.0"
] | Java | BuildToolsAction | /**
* Post the ToolsPanel as a standalone dialog.
*
*/ | Post the ToolsPanel as a standalone dialog. | [
"Post",
"the",
"ToolsPanel",
"as",
"a",
"standalone",
"dialog",
"."
] | public class BuildToolsAction extends CallableSystemAction implements PropertyChangeListener {
private String title;
private String name;
private JButton jOK = null;
private ToolsPanel tp;
public BuildToolsAction() {
name = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsName"); // NOI18N
title = NbBundle.getMessage(BuildToolsAction.class, "LBL_BuildToolsTitle"); // NOI18N
}
@Override
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public void performAction() {
initBuildTools(new LocalToolsPanelModel(), new ArrayList<String>(), null);
}
@Override
public void propertyChange(PropertyChangeEvent ev) {
if (ev.getPropertyName().equals(ToolsPanel.PROP_VALID) &&
ev.getSource() instanceof ToolsPanel) {
jOK.setEnabled(((Boolean) ev.getNewValue()));
}
}
/**
* Initialize the build tools
*
* @returns true if the user pressed OK, false if Cancel
*/
public boolean initBuildTools(ToolsPanelModel model, ArrayList<String> errs, CompilerSet cs) {
if (downloadIfNeed(model, cs)){
return true;
}
tp = new ToolsPanel(model, "ResolveBuildTools"); // NOI18N
tp.addPropertyChangeListener(this);
jOK = new JButton(NbBundle.getMessage(BuildToolsAction.class, "BTN_OK")); // NOI18N
tp.setPreferredSize(new Dimension(640, 450));
tp.update(errs);
DialogDescriptor dd = new DialogDescriptor((Object) constructOuterPanel(tp), getTitle(), true,
new Object[] { jOK, DialogDescriptor.CANCEL_OPTION},
DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.findHelp(tp), null);
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
try {
dialog.setVisible(true);
} catch (Throwable th) {
if (!(th.getCause() instanceof InterruptedException)) {
throw new RuntimeException(th);
}
dd.setValue(DialogDescriptor.CLOSED_OPTION);
} finally {
dialog.dispose();
}
if (dd.getValue() == jOK) {
tp.applyChanges(true);
return true;
}
return false;
}
private boolean downloadIfNeed(ToolsPanelModel model, CompilerSet cs){
ExecutionEnvironment env = model.getSelectedDevelopmentHost();
if (env.isLocal()){
if (cs == null) {
cs = CompilerSetManager.get(ExecutionEnvironmentFactory.getLocal()).getDefaultCompilerSet();
}
if (cs != null) {
if (cs.isUrlPointer()){
// Can be downloaded
return DownloadUtils.showDownloadConfirmation(cs);
}
}
}
return false;
}
private JPanel constructOuterPanel(JPanel innerPanel) {
JPanel panel = new JPanel();
panel.setLayout(new java.awt.GridBagLayout());
java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
gridBagConstraints.weightx = 1.0;
gridBagConstraints.weighty = 1.0;
gridBagConstraints.insets = new java.awt.Insets(16, 16, 16, 16);
panel.add(innerPanel, gridBagConstraints);
return panel;
}
@Override
public void actionPerformed(ActionEvent ev) {
performAction();
}
@Override
public HelpCtx getHelpCtx() {
return null;
}
} | [
"public",
"class",
"BuildToolsAction",
"extends",
"CallableSystemAction",
"implements",
"PropertyChangeListener",
"{",
"private",
"String",
"title",
";",
"private",
"String",
"name",
";",
"private",
"JButton",
"jOK",
"=",
"null",
";",
"private",
"ToolsPanel",
"tp",
";",
"public",
"BuildToolsAction",
"(",
")",
"{",
"name",
"=",
"NbBundle",
".",
"getMessage",
"(",
"BuildToolsAction",
".",
"class",
",",
"\"",
"LBL_BuildToolsName",
"\"",
")",
";",
"title",
"=",
"NbBundle",
".",
"getMessage",
"(",
"BuildToolsAction",
".",
"class",
",",
"\"",
"LBL_BuildToolsTitle",
"\"",
")",
";",
"}",
"@",
"Override",
"public",
"String",
"getName",
"(",
")",
"{",
"return",
"name",
";",
"}",
"public",
"void",
"setName",
"(",
"String",
"name",
")",
"{",
"this",
".",
"name",
"=",
"name",
";",
"}",
"public",
"String",
"getTitle",
"(",
")",
"{",
"return",
"title",
";",
"}",
"public",
"void",
"setTitle",
"(",
"String",
"title",
")",
"{",
"this",
".",
"title",
"=",
"title",
";",
"}",
"@",
"Override",
"public",
"void",
"performAction",
"(",
")",
"{",
"initBuildTools",
"(",
"new",
"LocalToolsPanelModel",
"(",
")",
",",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
",",
"null",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"propertyChange",
"(",
"PropertyChangeEvent",
"ev",
")",
"{",
"if",
"(",
"ev",
".",
"getPropertyName",
"(",
")",
".",
"equals",
"(",
"ToolsPanel",
".",
"PROP_VALID",
")",
"&&",
"ev",
".",
"getSource",
"(",
")",
"instanceof",
"ToolsPanel",
")",
"{",
"jOK",
".",
"setEnabled",
"(",
"(",
"(",
"Boolean",
")",
"ev",
".",
"getNewValue",
"(",
")",
")",
")",
";",
"}",
"}",
"/**\n * Initialize the build tools\n *\n * @returns true if the user pressed OK, false if Cancel\n */",
"public",
"boolean",
"initBuildTools",
"(",
"ToolsPanelModel",
"model",
",",
"ArrayList",
"<",
"String",
">",
"errs",
",",
"CompilerSet",
"cs",
")",
"{",
"if",
"(",
"downloadIfNeed",
"(",
"model",
",",
"cs",
")",
")",
"{",
"return",
"true",
";",
"}",
"tp",
"=",
"new",
"ToolsPanel",
"(",
"model",
",",
"\"",
"ResolveBuildTools",
"\"",
")",
";",
"tp",
".",
"addPropertyChangeListener",
"(",
"this",
")",
";",
"jOK",
"=",
"new",
"JButton",
"(",
"NbBundle",
".",
"getMessage",
"(",
"BuildToolsAction",
".",
"class",
",",
"\"",
"BTN_OK",
"\"",
")",
")",
";",
"tp",
".",
"setPreferredSize",
"(",
"new",
"Dimension",
"(",
"640",
",",
"450",
")",
")",
";",
"tp",
".",
"update",
"(",
"errs",
")",
";",
"DialogDescriptor",
"dd",
"=",
"new",
"DialogDescriptor",
"(",
"(",
"Object",
")",
"constructOuterPanel",
"(",
"tp",
")",
",",
"getTitle",
"(",
")",
",",
"true",
",",
"new",
"Object",
"[",
"]",
"{",
"jOK",
",",
"DialogDescriptor",
".",
"CANCEL_OPTION",
"}",
",",
"DialogDescriptor",
".",
"OK_OPTION",
",",
"DialogDescriptor",
".",
"DEFAULT_ALIGN",
",",
"HelpCtx",
".",
"findHelp",
"(",
"tp",
")",
",",
"null",
")",
";",
"Dialog",
"dialog",
"=",
"DialogDisplayer",
".",
"getDefault",
"(",
")",
".",
"createDialog",
"(",
"dd",
")",
";",
"try",
"{",
"dialog",
".",
"setVisible",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"Throwable",
"th",
")",
"{",
"if",
"(",
"!",
"(",
"th",
".",
"getCause",
"(",
")",
"instanceof",
"InterruptedException",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"th",
")",
";",
"}",
"dd",
".",
"setValue",
"(",
"DialogDescriptor",
".",
"CLOSED_OPTION",
")",
";",
"}",
"finally",
"{",
"dialog",
".",
"dispose",
"(",
")",
";",
"}",
"if",
"(",
"dd",
".",
"getValue",
"(",
")",
"==",
"jOK",
")",
"{",
"tp",
".",
"applyChanges",
"(",
"true",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"private",
"boolean",
"downloadIfNeed",
"(",
"ToolsPanelModel",
"model",
",",
"CompilerSet",
"cs",
")",
"{",
"ExecutionEnvironment",
"env",
"=",
"model",
".",
"getSelectedDevelopmentHost",
"(",
")",
";",
"if",
"(",
"env",
".",
"isLocal",
"(",
")",
")",
"{",
"if",
"(",
"cs",
"==",
"null",
")",
"{",
"cs",
"=",
"CompilerSetManager",
".",
"get",
"(",
"ExecutionEnvironmentFactory",
".",
"getLocal",
"(",
")",
")",
".",
"getDefaultCompilerSet",
"(",
")",
";",
"}",
"if",
"(",
"cs",
"!=",
"null",
")",
"{",
"if",
"(",
"cs",
".",
"isUrlPointer",
"(",
")",
")",
"{",
"return",
"DownloadUtils",
".",
"showDownloadConfirmation",
"(",
"cs",
")",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}",
"private",
"JPanel",
"constructOuterPanel",
"(",
"JPanel",
"innerPanel",
")",
"{",
"JPanel",
"panel",
"=",
"new",
"JPanel",
"(",
")",
";",
"panel",
".",
"setLayout",
"(",
"new",
"java",
".",
"awt",
".",
"GridBagLayout",
"(",
")",
")",
";",
"java",
".",
"awt",
".",
"GridBagConstraints",
"gridBagConstraints",
"=",
"new",
"java",
".",
"awt",
".",
"GridBagConstraints",
"(",
")",
";",
"gridBagConstraints",
".",
"fill",
"=",
"java",
".",
"awt",
".",
"GridBagConstraints",
".",
"BOTH",
";",
"gridBagConstraints",
".",
"weightx",
"=",
"1.0",
";",
"gridBagConstraints",
".",
"weighty",
"=",
"1.0",
";",
"gridBagConstraints",
".",
"insets",
"=",
"new",
"java",
".",
"awt",
".",
"Insets",
"(",
"16",
",",
"16",
",",
"16",
",",
"16",
")",
";",
"panel",
".",
"add",
"(",
"innerPanel",
",",
"gridBagConstraints",
")",
";",
"return",
"panel",
";",
"}",
"@",
"Override",
"public",
"void",
"actionPerformed",
"(",
"ActionEvent",
"ev",
")",
"{",
"performAction",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"HelpCtx",
"getHelpCtx",
"(",
")",
"{",
"return",
"null",
";",
"}",
"}"
] | Post the ToolsPanel as a standalone dialog. | [
"Post",
"the",
"ToolsPanel",
"as",
"a",
"standalone",
"dialog",
"."
] | [
"// NOI18N",
"// NOI18N",
"// NOI18N",
"// NOI18N",
"// Can be downloaded"
] | [
{
"param": "CallableSystemAction",
"type": null
},
{
"param": "PropertyChangeListener",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "CallableSystemAction",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "PropertyChangeListener",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |