id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
135,600
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java
TemplateElasticsearchUpdater.createTemplate
public static void createTemplate(RestClient client, String template, boolean force) throws Exception { String json = TemplateSettingsReader.readTemplate(template); createTemplateWithJson(client, template, json, force); }
java
public static void createTemplate(RestClient client, String template, boolean force) throws Exception { String json = TemplateSettingsReader.readTemplate(template); createTemplateWithJson(client, template, json, force); }
[ "public", "static", "void", "createTemplate", "(", "RestClient", "client", ",", "String", "template", ",", "boolean", "force", ")", "throws", "Exception", "{", "String", "json", "=", "TemplateSettingsReader", ".", "readTemplate", "(", "template", ")", ";", "crea...
Create a template in Elasticsearch. Read read content from default classpath dir. @param client Elasticsearch client @param template Template name @param force set it to true if you want to force cleaning template before adding it @throws Exception if something goes wrong
[ "Create", "a", "template", "in", "Elasticsearch", ".", "Read", "read", "content", "from", "default", "classpath", "dir", "." ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java#L169-L172
135,601
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java
TemplateElasticsearchUpdater.createTemplateWithJson
public static void createTemplateWithJson(RestClient client, String template, String json, boolean force) throws Exception { if (isTemplateExist(client, template)) { if (force) { logger.debug("Template [{}] already exists. Force is set. Removing it.", template); removeTemplate(client, template); } else { logger.debug("Template [{}] already exists.", template); } } if (!isTemplateExist(client, template)) { logger.debug("Template [{}] doesn't exist. Creating it.", template); createTemplateWithJsonInElasticsearch(client, template, json); } }
java
public static void createTemplateWithJson(RestClient client, String template, String json, boolean force) throws Exception { if (isTemplateExist(client, template)) { if (force) { logger.debug("Template [{}] already exists. Force is set. Removing it.", template); removeTemplate(client, template); } else { logger.debug("Template [{}] already exists.", template); } } if (!isTemplateExist(client, template)) { logger.debug("Template [{}] doesn't exist. Creating it.", template); createTemplateWithJsonInElasticsearch(client, template, json); } }
[ "public", "static", "void", "createTemplateWithJson", "(", "RestClient", "client", ",", "String", "template", ",", "String", "json", ",", "boolean", "force", ")", "throws", "Exception", "{", "if", "(", "isTemplateExist", "(", "client", ",", "template", ")", ")...
Create a new template in Elasticsearch @param client Elasticsearch client @param template Template name @param json JSon content for the template @param force set it to true if you want to force cleaning template before adding it @throws Exception if something goes wrong
[ "Create", "a", "new", "template", "in", "Elasticsearch" ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateElasticsearchUpdater.java#L182-L196
135,602
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/SettingsReader.java
SettingsReader.readFileFromClasspath
public static String readFileFromClasspath(String file) { logger.trace("Reading file [{}]...", file); String content = null; try (InputStream asStream = SettingsReader.class.getClassLoader().getResourceAsStream(file)) { if (asStream == null) { logger.trace("Can not find [{}] in class loader.", file); return null; } content = IOUtils.toString(asStream, "UTF-8"); } catch (IOException e) { logger.warn("Can not read [{}].", file); } return content; }
java
public static String readFileFromClasspath(String file) { logger.trace("Reading file [{}]...", file); String content = null; try (InputStream asStream = SettingsReader.class.getClassLoader().getResourceAsStream(file)) { if (asStream == null) { logger.trace("Can not find [{}] in class loader.", file); return null; } content = IOUtils.toString(asStream, "UTF-8"); } catch (IOException e) { logger.warn("Can not read [{}].", file); } return content; }
[ "public", "static", "String", "readFileFromClasspath", "(", "String", "file", ")", "{", "logger", ".", "trace", "(", "\"Reading file [{}]...\"", ",", "file", ")", ";", "String", "content", "=", "null", ";", "try", "(", "InputStream", "asStream", "=", "Settings...
Read a file content from the classpath @param file filename @return The file content
[ "Read", "a", "file", "content", "from", "the", "classpath" ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/SettingsReader.java#L38-L53
135,603
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java
ResourceList.getResources
public static String[] getResources(final String root) throws URISyntaxException, IOException { logger.trace("Reading classpath resources from {}", root); URL dirURL = ResourceList.class.getClassLoader().getResource(root); if (dirURL != null && dirURL.getProtocol().equals("file")) { /* A file path: easy enough */ logger.trace("found a file resource: {}", dirURL); String[] resources = new File(dirURL.toURI()).list(); Arrays.sort(resources); return resources; } if (dirURL == null) { /* * In case of a jar file, we can't actually find a directory. * Have to assume the same jar as clazz. */ String me = ResourceList.class.getName().replace(".", "/")+".class"; dirURL = ResourceList.class.getClassLoader().getResource(me); } if (dirURL == null) { throw new RuntimeException("can not get resource file " + root); } if (dirURL.getProtocol().equals("jar")) { /* A JAR path */ logger.trace("found a jar file resource: {}", dirURL); String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file String prefix = dirURL.getPath().substring(5 + jarPath.length()) // remove any ! that a class loader (e.g. from spring boot) could have added .replaceAll("!", "") // remove leading slash that is not part of the JarEntry::getName .substring(1); Set<String> result = new HashSet<>(); //avoid duplicates in case it is a subdirectory try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))) { Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar while(entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.startsWith(prefix)) { //filter according to the path String entry = name.substring(prefix.length()); int checkSubdir = entry.indexOf("/"); if (checkSubdir >= 0) { // if it is a subdirectory, we just return the directory name entry = entry.substring(0, checkSubdir); } result.add(entry); } } } String[] resources = result.toArray(new String[result.size()]); Arrays.sort(resources); return resources; } // Resource does not exist. We can return an empty list logger.trace("did not find any resource. returning empty array"); return NO_RESOURCE; }
java
public static String[] getResources(final String root) throws URISyntaxException, IOException { logger.trace("Reading classpath resources from {}", root); URL dirURL = ResourceList.class.getClassLoader().getResource(root); if (dirURL != null && dirURL.getProtocol().equals("file")) { /* A file path: easy enough */ logger.trace("found a file resource: {}", dirURL); String[] resources = new File(dirURL.toURI()).list(); Arrays.sort(resources); return resources; } if (dirURL == null) { /* * In case of a jar file, we can't actually find a directory. * Have to assume the same jar as clazz. */ String me = ResourceList.class.getName().replace(".", "/")+".class"; dirURL = ResourceList.class.getClassLoader().getResource(me); } if (dirURL == null) { throw new RuntimeException("can not get resource file " + root); } if (dirURL.getProtocol().equals("jar")) { /* A JAR path */ logger.trace("found a jar file resource: {}", dirURL); String jarPath = dirURL.getPath().substring(5, dirURL.getPath().indexOf("!")); //strip out only the JAR file String prefix = dirURL.getPath().substring(5 + jarPath.length()) // remove any ! that a class loader (e.g. from spring boot) could have added .replaceAll("!", "") // remove leading slash that is not part of the JarEntry::getName .substring(1); Set<String> result = new HashSet<>(); //avoid duplicates in case it is a subdirectory try (JarFile jar = new JarFile(URLDecoder.decode(jarPath, "UTF-8"))) { Enumeration<JarEntry> entries = jar.entries(); //gives ALL entries in jar while(entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.startsWith(prefix)) { //filter according to the path String entry = name.substring(prefix.length()); int checkSubdir = entry.indexOf("/"); if (checkSubdir >= 0) { // if it is a subdirectory, we just return the directory name entry = entry.substring(0, checkSubdir); } result.add(entry); } } } String[] resources = result.toArray(new String[result.size()]); Arrays.sort(resources); return resources; } // Resource does not exist. We can return an empty list logger.trace("did not find any resource. returning empty array"); return NO_RESOURCE; }
[ "public", "static", "String", "[", "]", "getResources", "(", "final", "String", "root", ")", "throws", "URISyntaxException", ",", "IOException", "{", "logger", ".", "trace", "(", "\"Reading classpath resources from {}\"", ",", "root", ")", ";", "URL", "dirURL", ...
List directory contents for a resource folder. Not recursive. This is basically a brute-force implementation. Works for regular files and also JARs. @param root Should end with "/", but not start with one. @return Just the name of each member item, not the full paths. @throws URISyntaxException When a file:// resource can not be converted to URL @throws IOException When a URL can not be decoded
[ "List", "directory", "contents", "for", "a", "resource", "folder", ".", "Not", "recursive", ".", "This", "is", "basically", "a", "brute", "-", "force", "implementation", ".", "Works", "for", "regular", "files", "and", "also", "JARs", "." ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/ResourceList.java#L57-L114
135,604
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/template/TemplateFinder.java
TemplateFinder.findTemplates
public static List<String> findTemplates(String root) throws IOException, URISyntaxException { if (root == null) { return findTemplates(); } logger.debug("Looking for templates in classpath under [{}].", root); final List<String> templateNames = new ArrayList<>(); String[] resources = ResourceList.getResources(root + "/" + Defaults.TemplateDir + "/"); // "es/_template/" for (String resource : resources) { if (!resource.isEmpty()) { String withoutIndex = resource.substring(resource.indexOf("/")+1); String template = withoutIndex.substring(0, withoutIndex.indexOf(Defaults.JsonFileExtension)); logger.trace(" - found [{}].", template); templateNames.add(template); } } return templateNames; }
java
public static List<String> findTemplates(String root) throws IOException, URISyntaxException { if (root == null) { return findTemplates(); } logger.debug("Looking for templates in classpath under [{}].", root); final List<String> templateNames = new ArrayList<>(); String[] resources = ResourceList.getResources(root + "/" + Defaults.TemplateDir + "/"); // "es/_template/" for (String resource : resources) { if (!resource.isEmpty()) { String withoutIndex = resource.substring(resource.indexOf("/")+1); String template = withoutIndex.substring(0, withoutIndex.indexOf(Defaults.JsonFileExtension)); logger.trace(" - found [{}].", template); templateNames.add(template); } } return templateNames; }
[ "public", "static", "List", "<", "String", ">", "findTemplates", "(", "String", "root", ")", "throws", "IOException", ",", "URISyntaxException", "{", "if", "(", "root", "==", "null", ")", "{", "return", "findTemplates", "(", ")", ";", "}", "logger", ".", ...
Find all templates @param root dir within the classpath @return a list of templates @throws IOException if connection with elasticsearch is failing @throws URISyntaxException this should not happen
[ "Find", "all", "templates" ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/template/TemplateFinder.java#L52-L71
135,605
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java
IndexElasticsearchUpdater.createIndex
@Deprecated public static void createIndex(Client client, String root, String index, boolean force) throws Exception { String settings = IndexSettingsReader.readSettings(root, index); createIndexWithSettings(client, index, settings, force); }
java
@Deprecated public static void createIndex(Client client, String root, String index, boolean force) throws Exception { String settings = IndexSettingsReader.readSettings(root, index); createIndexWithSettings(client, index, settings, force); }
[ "@", "Deprecated", "public", "static", "void", "createIndex", "(", "Client", "client", ",", "String", "root", ",", "String", "index", ",", "boolean", "force", ")", "throws", "Exception", "{", "String", "settings", "=", "IndexSettingsReader", ".", "readSettings",...
Create a new index in Elasticsearch. Read also _settings.json if exists. @param client Elasticsearch client @param root dir within the classpath @param index Index name @param force Remove index if exists (Warning: remove all data) @throws Exception if the elasticsearch API call is failing
[ "Create", "a", "new", "index", "in", "Elasticsearch", ".", "Read", "also", "_settings", ".", "json", "if", "exists", "." ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L49-L53
135,606
dadoonet/elasticsearch-beyonder
src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java
IndexElasticsearchUpdater.createIndex
public static void createIndex(RestClient client, String index, boolean force) throws Exception { String settings = IndexSettingsReader.readSettings(index); createIndexWithSettings(client, index, settings, force); }
java
public static void createIndex(RestClient client, String index, boolean force) throws Exception { String settings = IndexSettingsReader.readSettings(index); createIndexWithSettings(client, index, settings, force); }
[ "public", "static", "void", "createIndex", "(", "RestClient", "client", ",", "String", "index", ",", "boolean", "force", ")", "throws", "Exception", "{", "String", "settings", "=", "IndexSettingsReader", ".", "readSettings", "(", "index", ")", ";", "createIndexW...
Create a new index in Elasticsearch. Read also _settings.json if exists in default classpath dir. @param client Elasticsearch client @param index Index name @param force Remove index if exists (Warning: remove all data) @throws Exception if the elasticsearch API call is failing
[ "Create", "a", "new", "index", "in", "Elasticsearch", ".", "Read", "also", "_settings", ".", "json", "if", "exists", "in", "default", "classpath", "dir", "." ]
275bf63432b97169a90a266e983143cca9ad7629
https://github.com/dadoonet/elasticsearch-beyonder/blob/275bf63432b97169a90a266e983143cca9ad7629/src/main/java/fr/pilato/elasticsearch/tools/index/IndexElasticsearchUpdater.java#L222-L225
135,607
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/FloatingLabelWidgetBase.java
FloatingLabelWidgetBase.inflateWidgetLayout
private void inflateWidgetLayout(Context context, int layoutId) { inflate(context, layoutId, this); floatingLabel = (TextView) findViewById(R.id.flw_floating_label); if (floatingLabel == null) { throw new RuntimeException("Your layout must have a TextView whose ID is @id/flw_floating_label"); } View iw = findViewById(R.id.flw_input_widget); if (iw == null) { throw new RuntimeException("Your layout must have an input widget whose ID is @id/flw_input_widget"); } try { inputWidget = (InputWidgetT) iw; } catch (ClassCastException e) { throw new RuntimeException("The input widget is not of the expected type"); } }
java
private void inflateWidgetLayout(Context context, int layoutId) { inflate(context, layoutId, this); floatingLabel = (TextView) findViewById(R.id.flw_floating_label); if (floatingLabel == null) { throw new RuntimeException("Your layout must have a TextView whose ID is @id/flw_floating_label"); } View iw = findViewById(R.id.flw_input_widget); if (iw == null) { throw new RuntimeException("Your layout must have an input widget whose ID is @id/flw_input_widget"); } try { inputWidget = (InputWidgetT) iw; } catch (ClassCastException e) { throw new RuntimeException("The input widget is not of the expected type"); } }
[ "private", "void", "inflateWidgetLayout", "(", "Context", "context", ",", "int", "layoutId", ")", "{", "inflate", "(", "context", ",", "layoutId", ",", "this", ")", ";", "floatingLabel", "=", "(", "TextView", ")", "findViewById", "(", "R", ".", "id", ".", ...
Inflate the widget layout and make sure we have everything in there @param context The context @param layoutId The id of the layout to inflate
[ "Inflate", "the", "widget", "layout", "and", "make", "sure", "we", "have", "everything", "in", "there" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/FloatingLabelWidgetBase.java#L605-L622
135,608
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java
ElementBuilder.css
public B css(String... classes) { if (classes != null) { List<String> failSafeClasses = new ArrayList<>(); for (String c : classes) { if (c != null) { if (c.contains(" ")) { failSafeClasses.addAll(asList(c.split(" "))); } else { failSafeClasses.add(c); } } } for (String failSafeClass : failSafeClasses) { get().classList.add(failSafeClass); } } return that(); }
java
public B css(String... classes) { if (classes != null) { List<String> failSafeClasses = new ArrayList<>(); for (String c : classes) { if (c != null) { if (c.contains(" ")) { failSafeClasses.addAll(asList(c.split(" "))); } else { failSafeClasses.add(c); } } } for (String failSafeClass : failSafeClasses) { get().classList.add(failSafeClass); } } return that(); }
[ "public", "B", "css", "(", "String", "...", "classes", ")", "{", "if", "(", "classes", "!=", "null", ")", "{", "List", "<", "String", ">", "failSafeClasses", "=", "new", "ArrayList", "<>", "(", ")", ";", "for", "(", "String", "c", ":", "classes", "...
Adds the specified CSS classes to the class list of the element.
[ "Adds", "the", "specified", "CSS", "classes", "to", "the", "class", "list", "of", "the", "element", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java#L90-L107
135,609
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java
ElementBuilder.attr
public B attr(String name, String value) { get().setAttribute(name, value); return that(); }
java
public B attr(String name, String value) { get().setAttribute(name, value); return that(); }
[ "public", "B", "attr", "(", "String", "name", ",", "String", "value", ")", "{", "get", "(", ")", ".", "setAttribute", "(", "name", ",", "value", ")", ";", "return", "that", "(", ")", ";", "}" ]
Sets the specified attribute of the element.
[ "Sets", "the", "specified", "attribute", "of", "the", "element", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java#L122-L125
135,610
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java
ElementBuilder.on
public <V extends Event> B on(EventType<V, ?> type, EventCallbackFn<V> callback) { bind(get(), type, callback); return that(); }
java
public <V extends Event> B on(EventType<V, ?> type, EventCallbackFn<V> callback) { bind(get(), type, callback); return that(); }
[ "public", "<", "V", "extends", "Event", ">", "B", "on", "(", "EventType", "<", "V", ",", "?", ">", "type", ",", "EventCallbackFn", "<", "V", ">", "callback", ")", "{", "bind", "(", "get", "(", ")", ",", "type", ",", "callback", ")", ";", "return"...
Adds the given callback to the element.
[ "Adds", "the", "given", "callback", "to", "the", "element", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/builder/ElementBuilder.java#L158-L161
135,611
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/edittext/FloatingLabelEditText.java
FloatingLabelEditText.setInputWidgetText
public void setInputWidgetText(CharSequence text, TextView.BufferType type) { getInputWidget().setText(text, type); }
java
public void setInputWidgetText(CharSequence text, TextView.BufferType type) { getInputWidget().setText(text, type); }
[ "public", "void", "setInputWidgetText", "(", "CharSequence", "text", ",", "TextView", ".", "BufferType", "type", ")", "{", "getInputWidget", "(", ")", ".", "setText", "(", "text", ",", "type", ")", ";", "}" ]
Delegate method for the input widget
[ "Delegate", "method", "for", "the", "input", "widget" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/edittext/FloatingLabelEditText.java#L115-L117
135,612
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/edittext/FloatingLabelEditText.java
FloatingLabelEditText.onTextChanged
protected void onTextChanged(String s) { if (!isFloatOnFocusEnabled()) { if (s.length() == 0) { anchorLabel(); } else { floatLabel(); } } if (editTextListener != null) editTextListener.onTextChanged(this, s); }
java
protected void onTextChanged(String s) { if (!isFloatOnFocusEnabled()) { if (s.length() == 0) { anchorLabel(); } else { floatLabel(); } } if (editTextListener != null) editTextListener.onTextChanged(this, s); }
[ "protected", "void", "onTextChanged", "(", "String", "s", ")", "{", "if", "(", "!", "isFloatOnFocusEnabled", "(", ")", ")", "{", "if", "(", "s", ".", "length", "(", ")", "==", "0", ")", "{", "anchorLabel", "(", ")", ";", "}", "else", "{", "floatLab...
Called when the text within the input widget is updated @param s The new text
[ "Called", "when", "the", "text", "within", "the", "input", "widget", "is", "updated" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/edittext/FloatingLabelEditText.java#L213-L222
135,613
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java
BitmapUtils.applyColor
public static Bitmap applyColor(Bitmap bitmap, int accentColor) { int r = Color.red(accentColor); int g = Color.green(accentColor); int b = Color.blue(accentColor); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); for (int i=0; i<pixels.length; i++) { int color = pixels[i]; int alpha = Color.alpha(color); pixels[i] = Color.argb(alpha, r, g, b); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
java
public static Bitmap applyColor(Bitmap bitmap, int accentColor) { int r = Color.red(accentColor); int g = Color.green(accentColor); int b = Color.blue(accentColor); int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); for (int i=0; i<pixels.length; i++) { int color = pixels[i]; int alpha = Color.alpha(color); pixels[i] = Color.argb(alpha, r, g, b); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
[ "public", "static", "Bitmap", "applyColor", "(", "Bitmap", "bitmap", ",", "int", "accentColor", ")", "{", "int", "r", "=", "Color", ".", "red", "(", "accentColor", ")", ";", "int", "g", "=", "Color", ".", "green", "(", "accentColor", ")", ";", "int", ...
Creates a copy of the bitmap by replacing the color of every pixel by accentColor while keeping the alpha value. @param bitmap The original bitmap. @param accentColor The color to apply to every pixel. @return A copy of the given bitmap with the accent color applied.
[ "Creates", "a", "copy", "of", "the", "bitmap", "by", "replacing", "the", "color", "of", "every", "pixel", "by", "accentColor", "while", "keeping", "the", "alpha", "value", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java#L53-L69
135,614
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java
BitmapUtils.changeTintColor
public static Bitmap changeTintColor(Bitmap bitmap, int originalColor, int destinationColor) { // original tint color int[] o = new int[] { Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor) }; // destination tint color int[] d = new int[] { Color.red(destinationColor), Color.green(destinationColor), Color.blue(destinationColor) }; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); int maxIndex = getMaxIndex(o); int mintIndex = getMinIndex(o); for (int i=0; i<pixels.length; i++) { int color = pixels[i]; // pixel color int[] p = new int[] { Color.red(color), Color.green(color), Color.blue(color) }; int alpha = Color.alpha(color); float[] transformation = calculateTransformation(o[maxIndex], o[mintIndex], p[maxIndex], p[mintIndex]); pixels[i] = applyTransformation(d, alpha, transformation); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
java
public static Bitmap changeTintColor(Bitmap bitmap, int originalColor, int destinationColor) { // original tint color int[] o = new int[] { Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor) }; // destination tint color int[] d = new int[] { Color.red(destinationColor), Color.green(destinationColor), Color.blue(destinationColor) }; int width = bitmap.getWidth(); int height = bitmap.getHeight(); int[] pixels = new int[width * height]; bitmap.getPixels(pixels, 0, width, 0, 0, width, height); int maxIndex = getMaxIndex(o); int mintIndex = getMinIndex(o); for (int i=0; i<pixels.length; i++) { int color = pixels[i]; // pixel color int[] p = new int[] { Color.red(color), Color.green(color), Color.blue(color) }; int alpha = Color.alpha(color); float[] transformation = calculateTransformation(o[maxIndex], o[mintIndex], p[maxIndex], p[mintIndex]); pixels[i] = applyTransformation(d, alpha, transformation); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
[ "public", "static", "Bitmap", "changeTintColor", "(", "Bitmap", "bitmap", ",", "int", "originalColor", ",", "int", "destinationColor", ")", "{", "// original tint color", "int", "[", "]", "o", "=", "new", "int", "[", "]", "{", "Color", ".", "red", "(", "or...
Creates a copy of the bitmap by calculating the transformation based on the original color and applying it to the the destination color. @param bitmap The original bitmap. @param originalColor Tint color in the original bitmap. @param destinationColor Tint color to be applied. @return A copy of the given bitmap with the tint color changed.
[ "Creates", "a", "copy", "of", "the", "bitmap", "by", "calculating", "the", "transformation", "based", "on", "the", "original", "color", "and", "applying", "it", "to", "the", "the", "destination", "color", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java#L79-L112
135,615
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java
BitmapUtils.processTintTransformationMap
public static Bitmap processTintTransformationMap(Bitmap transformationMap, int tintColor) { // tint color int[] t = new int[] { Color.red(tintColor), Color.green(tintColor), Color.blue(tintColor) }; int width = transformationMap.getWidth(); int height = transformationMap.getHeight(); int[] pixels = new int[width * height]; transformationMap.getPixels(pixels, 0, width, 0, 0, width, height); float[] transformation = new float[2]; for (int i=0; i<pixels.length; i++) { int color = pixels[i]; int alpha = Color.alpha(color); transformation[0] = Color.red(color) / 255f; transformation[1] = Color.green(color) / 255f; pixels[i] = applyTransformation(t, alpha, transformation); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
java
public static Bitmap processTintTransformationMap(Bitmap transformationMap, int tintColor) { // tint color int[] t = new int[] { Color.red(tintColor), Color.green(tintColor), Color.blue(tintColor) }; int width = transformationMap.getWidth(); int height = transformationMap.getHeight(); int[] pixels = new int[width * height]; transformationMap.getPixels(pixels, 0, width, 0, 0, width, height); float[] transformation = new float[2]; for (int i=0; i<pixels.length; i++) { int color = pixels[i]; int alpha = Color.alpha(color); transformation[0] = Color.red(color) / 255f; transformation[1] = Color.green(color) / 255f; pixels[i] = applyTransformation(t, alpha, transformation); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
[ "public", "static", "Bitmap", "processTintTransformationMap", "(", "Bitmap", "transformationMap", ",", "int", "tintColor", ")", "{", "// tint color", "int", "[", "]", "t", "=", "new", "int", "[", "]", "{", "Color", ".", "red", "(", "tintColor", ")", ",", "...
Apply the given tint color to the transformation map. @param transformationMap A bitmap representing the transformation map. @param tintColor Tint color to be applied. @return A bitmap with the with the tint color set.
[ "Apply", "the", "given", "tint", "color", "to", "the", "transformation", "map", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java#L160-L182
135,616
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java
BitmapUtils.writeToFile
public static void writeToFile(Bitmap bitmap, String dir, String filename) throws FileNotFoundException, IOException { File sdCard = Environment.getExternalStorageDirectory(); File dirFile = new File (sdCard.getAbsolutePath() + "/" + dir); dirFile.mkdirs(); File f = new File(dirFile, filename); FileOutputStream fos = new FileOutputStream(f, false); bitmap.compress(CompressFormat.PNG, 100 /*ignored for PNG*/, fos); fos.flush(); fos.close(); }
java
public static void writeToFile(Bitmap bitmap, String dir, String filename) throws FileNotFoundException, IOException { File sdCard = Environment.getExternalStorageDirectory(); File dirFile = new File (sdCard.getAbsolutePath() + "/" + dir); dirFile.mkdirs(); File f = new File(dirFile, filename); FileOutputStream fos = new FileOutputStream(f, false); bitmap.compress(CompressFormat.PNG, 100 /*ignored for PNG*/, fos); fos.flush(); fos.close(); }
[ "public", "static", "void", "writeToFile", "(", "Bitmap", "bitmap", ",", "String", "dir", ",", "String", "filename", ")", "throws", "FileNotFoundException", ",", "IOException", "{", "File", "sdCard", "=", "Environment", ".", "getExternalStorageDirectory", "(", ")"...
Write the given bitmap to a file in the external storage. Requires "android.permission.WRITE_EXTERNAL_STORAGE" permission.
[ "Write", "the", "given", "bitmap", "to", "a", "file", "in", "the", "external", "storage", ".", "Requires", "android", ".", "permission", ".", "WRITE_EXTERNAL_STORAGE", "permission", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/BitmapUtils.java#L232-L241
135,617
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java
NativeResources.getIdentifier
public static int getIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_ID, NATIVE_PACKAGE); }
java
public static int getIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_ID, NATIVE_PACKAGE); }
[ "public", "static", "int", "getIdentifier", "(", "String", "name", ")", "{", "Resources", "res", "=", "Resources", ".", "getSystem", "(", ")", ";", "return", "res", ".", "getIdentifier", "(", "name", ",", "TYPE_ID", ",", "NATIVE_PACKAGE", ")", ";", "}" ]
Get a native identifier by name as in 'R.id.name'.
[ "Get", "a", "native", "identifier", "by", "name", "as", "in", "R", ".", "id", ".", "name", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java#L18-L21
135,618
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java
NativeResources.getStringIdentifier
public static int getStringIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_STRING, NATIVE_PACKAGE); }
java
public static int getStringIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_STRING, NATIVE_PACKAGE); }
[ "public", "static", "int", "getStringIdentifier", "(", "String", "name", ")", "{", "Resources", "res", "=", "Resources", ".", "getSystem", "(", ")", ";", "return", "res", ".", "getIdentifier", "(", "name", ",", "TYPE_STRING", ",", "NATIVE_PACKAGE", ")", ";",...
Get a native string id by name as in 'R.string.name'.
[ "Get", "a", "native", "string", "id", "by", "name", "as", "in", "R", ".", "string", ".", "name", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java#L24-L27
135,619
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java
NativeResources.getDrawableIdentifier
public static int getDrawableIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_DRAWABLE, NATIVE_PACKAGE); }
java
public static int getDrawableIdentifier(String name) { Resources res = Resources.getSystem(); return res.getIdentifier(name, TYPE_DRAWABLE, NATIVE_PACKAGE); }
[ "public", "static", "int", "getDrawableIdentifier", "(", "String", "name", ")", "{", "Resources", "res", "=", "Resources", ".", "getSystem", "(", ")", ";", "return", "res", ".", "getIdentifier", "(", "name", ",", "TYPE_DRAWABLE", ",", "NATIVE_PACKAGE", ")", ...
Get a native drawable id by name as in 'R.drawable.name'.
[ "Get", "a", "native", "drawable", "id", "by", "name", "as", "in", "R", ".", "drawable", ".", "name", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/util/NativeResources.java#L37-L40
135,620
hal/elemento
samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java
TodoItemElement.create
static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) { return new Templated_TodoItemElement(application, repository); }
java
static TodoItemElement create(Provider<ApplicationElement> application, TodoItemRepository repository) { return new Templated_TodoItemElement(application, repository); }
[ "static", "TodoItemElement", "create", "(", "Provider", "<", "ApplicationElement", ">", "application", ",", "TodoItemRepository", "repository", ")", "{", "return", "new", "Templated_TodoItemElement", "(", "application", ",", "repository", ")", ";", "}" ]
Don't use ApplicationElement directly as this will lead to a dependency cycle in the generated GIN code!
[ "Don", "t", "use", "ApplicationElement", "directly", "as", "this", "will", "lead", "to", "a", "dependency", "cycle", "in", "the", "generated", "GIN", "code!" ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/samples/dagger/src/main/java/org/jboss/gwt/elemento/sample/dagger/client/TodoItemElement.java#L39-L41
135,621
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentResources.java
AccentResources.addTintResourceId
public void addTintResourceId(int resId) { if (mCustomTintDrawableIds == null) mCustomTintDrawableIds = new ArrayList<Integer>(); mCustomTintDrawableIds.add(resId); }
java
public void addTintResourceId(int resId) { if (mCustomTintDrawableIds == null) mCustomTintDrawableIds = new ArrayList<Integer>(); mCustomTintDrawableIds.add(resId); }
[ "public", "void", "addTintResourceId", "(", "int", "resId", ")", "{", "if", "(", "mCustomTintDrawableIds", "==", "null", ")", "mCustomTintDrawableIds", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "mCustomTintDrawableIds", ".", "add", "(", "res...
Add a drawable resource to which to apply the "tint" technique.
[ "Add", "a", "drawable", "resource", "to", "which", "to", "apply", "the", "tint", "technique", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentResources.java#L349-L353
135,622
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentResources.java
AccentResources.addTintTransformationResourceId
public void addTintTransformationResourceId(int resId) { if (mCustomTransformationDrawableIds == null) mCustomTransformationDrawableIds = new ArrayList<Integer>(); mCustomTransformationDrawableIds.add(resId); }
java
public void addTintTransformationResourceId(int resId) { if (mCustomTransformationDrawableIds == null) mCustomTransformationDrawableIds = new ArrayList<Integer>(); mCustomTransformationDrawableIds.add(resId); }
[ "public", "void", "addTintTransformationResourceId", "(", "int", "resId", ")", "{", "if", "(", "mCustomTransformationDrawableIds", "==", "null", ")", "mCustomTransformationDrawableIds", "=", "new", "ArrayList", "<", "Integer", ">", "(", ")", ";", "mCustomTransformatio...
Add a drawable resource to which to apply the "tint transformation" technique.
[ "Add", "a", "drawable", "resource", "to", "which", "to", "apply", "the", "tint", "transformation", "technique", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentResources.java#L356-L360
135,623
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentResources.java
AccentResources.getTintendResourceStream
private InputStream getTintendResourceStream(int id, TypedValue value, int color) { Bitmap bitmap = getBitmapFromResource(id, value); bitmap = BitmapUtils.applyColor(bitmap, color); return getStreamFromBitmap(bitmap); }
java
private InputStream getTintendResourceStream(int id, TypedValue value, int color) { Bitmap bitmap = getBitmapFromResource(id, value); bitmap = BitmapUtils.applyColor(bitmap, color); return getStreamFromBitmap(bitmap); }
[ "private", "InputStream", "getTintendResourceStream", "(", "int", "id", ",", "TypedValue", "value", ",", "int", "color", ")", "{", "Bitmap", "bitmap", "=", "getBitmapFromResource", "(", "id", ",", "value", ")", ";", "bitmap", "=", "BitmapUtils", ".", "applyCol...
Get a reference to a resource that is equivalent to the one requested, but with the accent color applied to it.
[ "Get", "a", "reference", "to", "a", "resource", "that", "is", "equivalent", "to", "the", "one", "requested", "but", "with", "the", "accent", "color", "applied", "to", "it", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentResources.java#L366-L370
135,624
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentResources.java
AccentResources.getTintTransformationResourceStream
private InputStream getTintTransformationResourceStream(int id, TypedValue value, int color) { Bitmap bitmap = getBitmapFromResource(id, value); bitmap = BitmapUtils.processTintTransformationMap(bitmap, color); return getStreamFromBitmap(bitmap); }
java
private InputStream getTintTransformationResourceStream(int id, TypedValue value, int color) { Bitmap bitmap = getBitmapFromResource(id, value); bitmap = BitmapUtils.processTintTransformationMap(bitmap, color); return getStreamFromBitmap(bitmap); }
[ "private", "InputStream", "getTintTransformationResourceStream", "(", "int", "id", ",", "TypedValue", "value", ",", "int", "color", ")", "{", "Bitmap", "bitmap", "=", "getBitmapFromResource", "(", "id", ",", "value", ")", ";", "bitmap", "=", "BitmapUtils", ".", ...
Get a reference to a resource that is equivalent to the one requested, but changing the tint from the original red to the given color.
[ "Get", "a", "reference", "to", "a", "resource", "that", "is", "equivalent", "to", "the", "one", "requested", "but", "changing", "the", "tint", "from", "the", "original", "red", "to", "the", "given", "color", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentResources.java#L376-L380
135,625
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/itempicker/FloatingLabelItemPicker.java
FloatingLabelItemPicker.getSelectedItems
public Collection<ItemT> getSelectedItems() { if (availableItems == null || selectedIndices == null || selectedIndices.length == 0) { return new ArrayList<ItemT>(0); } ArrayList<ItemT> items = new ArrayList<ItemT>(selectedIndices.length); for (int index : selectedIndices) { items.add(availableItems.get(index)); } return items; }
java
public Collection<ItemT> getSelectedItems() { if (availableItems == null || selectedIndices == null || selectedIndices.length == 0) { return new ArrayList<ItemT>(0); } ArrayList<ItemT> items = new ArrayList<ItemT>(selectedIndices.length); for (int index : selectedIndices) { items.add(availableItems.get(index)); } return items; }
[ "public", "Collection", "<", "ItemT", ">", "getSelectedItems", "(", ")", "{", "if", "(", "availableItems", "==", "null", "||", "selectedIndices", "==", "null", "||", "selectedIndices", ".", "length", "==", "0", ")", "{", "return", "new", "ArrayList", "<", ...
Get the items currently selected @return
[ "Get", "the", "items", "currently", "selected" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/itempicker/FloatingLabelItemPicker.java#L179-L189
135,626
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/itempicker/AbstractPickerDialogFragment.java
AbstractPickerDialogFragment.buildCommonArgsBundle
protected static Bundle buildCommonArgsBundle(int pickerId, String title, String positiveButtonText, String negativeButtonText, boolean enableMultipleSelection, int[] selectedItemIndices) { Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putString(ARG_TITLE, title); args.putString(ARG_POSITIVE_BUTTON_TEXT, positiveButtonText); args.putString(ARG_NEGATIVE_BUTTON_TEXT, negativeButtonText); args.putBoolean(ARG_ENABLE_MULTIPLE_SELECTION, enableMultipleSelection); args.putIntArray(ARG_SELECTED_ITEMS_INDICES, selectedItemIndices); return args; }
java
protected static Bundle buildCommonArgsBundle(int pickerId, String title, String positiveButtonText, String negativeButtonText, boolean enableMultipleSelection, int[] selectedItemIndices) { Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putString(ARG_TITLE, title); args.putString(ARG_POSITIVE_BUTTON_TEXT, positiveButtonText); args.putString(ARG_NEGATIVE_BUTTON_TEXT, negativeButtonText); args.putBoolean(ARG_ENABLE_MULTIPLE_SELECTION, enableMultipleSelection); args.putIntArray(ARG_SELECTED_ITEMS_INDICES, selectedItemIndices); return args; }
[ "protected", "static", "Bundle", "buildCommonArgsBundle", "(", "int", "pickerId", ",", "String", "title", ",", "String", "positiveButtonText", ",", "String", "negativeButtonText", ",", "boolean", "enableMultipleSelection", ",", "int", "[", "]", "selectedItemIndices", ...
Utility method for implementations to create the base argument bundle @param pickerId The id of the item picker @param title The title for the dialog @param positiveButtonText The text of the positive button @param negativeButtonText The text of the negative button @param enableMultipleSelection Whether or not to allow selecting multiple items @param selectedItemIndices The positions of the items already selected @return The arguments bundle
[ "Utility", "method", "for", "implementations", "to", "create", "the", "base", "argument", "bundle" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/itempicker/AbstractPickerDialogFragment.java#L56-L65
135,627
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/drawable/ToggleForegroundDrawable.java
ToggleForegroundDrawable.draw
@Override public void draw(Canvas canvas) { float width = canvas.getWidth(); float margin = (width / 3) + mState.mMarginSide; float posY = canvas.getHeight() - mState.mMarginBottom; canvas.drawLine(margin, posY, width - margin, posY, mPaint); }
java
@Override public void draw(Canvas canvas) { float width = canvas.getWidth(); float margin = (width / 3) + mState.mMarginSide; float posY = canvas.getHeight() - mState.mMarginBottom; canvas.drawLine(margin, posY, width - margin, posY, mPaint); }
[ "@", "Override", "public", "void", "draw", "(", "Canvas", "canvas", ")", "{", "float", "width", "=", "canvas", ".", "getWidth", "(", ")", ";", "float", "margin", "=", "(", "width", "/", "3", ")", "+", "mState", ".", "mMarginSide", ";", "float", "posY...
It is based on the canvas width and height instead of the bounds in order not to consider the margins of the button it is drawn in.
[ "It", "is", "based", "on", "the", "canvas", "width", "and", "height", "instead", "of", "the", "bounds", "in", "order", "not", "to", "consider", "the", "margins", "of", "the", "button", "it", "is", "drawn", "in", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/drawable/ToggleForegroundDrawable.java#L82-L88
135,628
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/BodyObserver.java
BodyObserver.addAttachObserver
static void addAttachObserver(HTMLElement element, ObserverCallback callback) { if (!ready) { startObserving(); } attachObservers.add(createObserver(element, callback, ATTACH_UID_KEY)); }
java
static void addAttachObserver(HTMLElement element, ObserverCallback callback) { if (!ready) { startObserving(); } attachObservers.add(createObserver(element, callback, ATTACH_UID_KEY)); }
[ "static", "void", "addAttachObserver", "(", "HTMLElement", "element", ",", "ObserverCallback", "callback", ")", "{", "if", "(", "!", "ready", ")", "{", "startObserving", "(", ")", ";", "}", "attachObservers", ".", "add", "(", "createObserver", "(", "element", ...
Check if the observer is already started, if not it will start it, then register and callback for when the element is attached to the dom.
[ "Check", "if", "the", "observer", "is", "already", "started", "if", "not", "it", "will", "start", "it", "then", "register", "and", "callback", "for", "when", "the", "element", "is", "attached", "to", "the", "dom", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/BodyObserver.java#L100-L105
135,629
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/BodyObserver.java
BodyObserver.addDetachObserver
static void addDetachObserver(HTMLElement element, ObserverCallback callback) { if (!ready) { startObserving(); } detachObservers.add(createObserver(element, callback, DETACH_UID_KEY)); }
java
static void addDetachObserver(HTMLElement element, ObserverCallback callback) { if (!ready) { startObserving(); } detachObservers.add(createObserver(element, callback, DETACH_UID_KEY)); }
[ "static", "void", "addDetachObserver", "(", "HTMLElement", "element", ",", "ObserverCallback", "callback", ")", "{", "if", "(", "!", "ready", ")", "{", "startObserving", "(", ")", ";", "}", "detachObservers", ".", "add", "(", "createObserver", "(", "element", ...
Check if the observer is already started, if not it will start it, then register and callback for when the element is removed from the dom.
[ "Check", "if", "the", "observer", "is", "already", "started", "if", "not", "it", "will", "start", "it", "then", "register", "and", "callback", "for", "when", "the", "element", "is", "removed", "from", "the", "dom", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/BodyObserver.java#L111-L116
135,630
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/DatePickerFragment.java
DatePickerFragment.newInstance
public static <DateInstantT extends DateInstant> DatePickerFragment newInstance(int pickerId, DateInstantT selectedInstant) { DatePickerFragment f = new DatePickerFragment(); Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant); f.setArguments(args); return f; }
java
public static <DateInstantT extends DateInstant> DatePickerFragment newInstance(int pickerId, DateInstantT selectedInstant) { DatePickerFragment f = new DatePickerFragment(); Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant); f.setArguments(args); return f; }
[ "public", "static", "<", "DateInstantT", "extends", "DateInstant", ">", "DatePickerFragment", "newInstance", "(", "int", "pickerId", ",", "DateInstantT", "selectedInstant", ")", "{", "DatePickerFragment", "f", "=", "new", "DatePickerFragment", "(", ")", ";", "Bundle...
Create a new date picker @param pickerId The id of the item picker @param selectedInstant The positions of the items already selected @return The arguments bundle
[ "Create", "a", "new", "date", "picker" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/DatePickerFragment.java#L30-L39
135,631
hal/elemento
template-processor/src/main/java/org/jboss/gwt/elemento/processor/TemplatedProcessor.java
TemplatedProcessor.abortWithError
private void abortWithError(Element element, String msg, Object... args) throws AbortProcessingException { error(element, msg, args); throw new AbortProcessingException(); }
java
private void abortWithError(Element element, String msg, Object... args) throws AbortProcessingException { error(element, msg, args); throw new AbortProcessingException(); }
[ "private", "void", "abortWithError", "(", "Element", "element", ",", "String", "msg", ",", "Object", "...", "args", ")", "throws", "AbortProcessingException", "{", "error", "(", "element", ",", "msg", ",", "args", ")", ";", "throw", "new", "AbortProcessingExce...
Issue a compilation error and abandon the processing of this template. This does not prevent the processing of other templates.
[ "Issue", "a", "compilation", "error", "and", "abandon", "the", "processing", "of", "this", "template", ".", "This", "does", "not", "prevent", "the", "processing", "of", "other", "templates", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/template-processor/src/main/java/org/jboss/gwt/elemento/processor/TemplatedProcessor.java#L711-L714
135,632
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentHelper.java
AccentHelper.getPalette
public static AccentPalette getPalette(Context context) { Resources resources = context.getResources(); if (!(resources instanceof AccentResources)) return null; return ((AccentResources)resources).getPalette(); }
java
public static AccentPalette getPalette(Context context) { Resources resources = context.getResources(); if (!(resources instanceof AccentResources)) return null; return ((AccentResources)resources).getPalette(); }
[ "public", "static", "AccentPalette", "getPalette", "(", "Context", "context", ")", "{", "Resources", "resources", "=", "context", ".", "getResources", "(", ")", ";", "if", "(", "!", "(", "resources", "instanceof", "AccentResources", ")", ")", "return", "null",...
Get the AccentPalette instance from the the context. @return It might return null if HoloAccent has not been correctly configured.
[ "Get", "the", "AccentPalette", "instance", "from", "the", "the", "context", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentHelper.java#L72-L77
135,633
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/AccentHelper.java
AccentHelper.prepareDialog
public void prepareDialog(Context c, Window window) { if (mDividerPainter == null) mDividerPainter = initPainter(c, mOverrideColor); mDividerPainter.paint(window); }
java
public void prepareDialog(Context c, Window window) { if (mDividerPainter == null) mDividerPainter = initPainter(c, mOverrideColor); mDividerPainter.paint(window); }
[ "public", "void", "prepareDialog", "(", "Context", "c", ",", "Window", "window", ")", "{", "if", "(", "mDividerPainter", "==", "null", ")", "mDividerPainter", "=", "initPainter", "(", "c", ",", "mOverrideColor", ")", ";", "mDividerPainter", ".", "paint", "("...
Paint the dialog's divider if required to correctly customize it.
[ "Paint", "the", "dialog", "s", "divider", "if", "required", "to", "correctly", "customize", "it", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/AccentHelper.java#L142-L146
135,634
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.emptyElement
public static <E extends HTMLElement> EmptyContentBuilder<E> emptyElement(String tag, Class<E> type) { return emptyElement(() -> createElement(tag, type)); }
java
public static <E extends HTMLElement> EmptyContentBuilder<E> emptyElement(String tag, Class<E> type) { return emptyElement(() -> createElement(tag, type)); }
[ "public", "static", "<", "E", "extends", "HTMLElement", ">", "EmptyContentBuilder", "<", "E", ">", "emptyElement", "(", "String", "tag", ",", "Class", "<", "E", ">", "type", ")", "{", "return", "emptyElement", "(", "(", ")", "->", "createElement", "(", "...
Returns a builder for the specified empty tag.
[ "Returns", "a", "builder", "for", "the", "specified", "empty", "tag", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L534-L536
135,635
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.textElement
public static <E extends HTMLElement> TextContentBuilder<E> textElement(String tag, Class<E> type) { return new TextContentBuilder<>(createElement(tag, type)); }
java
public static <E extends HTMLElement> TextContentBuilder<E> textElement(String tag, Class<E> type) { return new TextContentBuilder<>(createElement(tag, type)); }
[ "public", "static", "<", "E", "extends", "HTMLElement", ">", "TextContentBuilder", "<", "E", ">", "textElement", "(", "String", "tag", ",", "Class", "<", "E", ">", "type", ")", "{", "return", "new", "TextContentBuilder", "<>", "(", "createElement", "(", "t...
Returns a builder for the specified text tag.
[ "Returns", "a", "builder", "for", "the", "specified", "text", "tag", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L543-L545
135,636
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.htmlElement
public static <E extends HTMLElement> HtmlContentBuilder<E> htmlElement(String tag, Class<E> type) { return new HtmlContentBuilder<>(createElement(tag, type)); }
java
public static <E extends HTMLElement> HtmlContentBuilder<E> htmlElement(String tag, Class<E> type) { return new HtmlContentBuilder<>(createElement(tag, type)); }
[ "public", "static", "<", "E", "extends", "HTMLElement", ">", "HtmlContentBuilder", "<", "E", ">", "htmlElement", "(", "String", "tag", ",", "Class", "<", "E", ">", "type", ")", "{", "return", "new", "HtmlContentBuilder", "<>", "(", "createElement", "(", "t...
Returns a builder for the specified html tag.
[ "Returns", "a", "builder", "for", "the", "specified", "html", "tag", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L548-L550
135,637
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.stream
public static <E> Stream<E> stream(JsArrayLike<E> nodes) { if (nodes == null) { return Stream.empty(); } else { return StreamSupport.stream(spliteratorUnknownSize(iterator(nodes), 0), false); } }
java
public static <E> Stream<E> stream(JsArrayLike<E> nodes) { if (nodes == null) { return Stream.empty(); } else { return StreamSupport.stream(spliteratorUnknownSize(iterator(nodes), 0), false); } }
[ "public", "static", "<", "E", ">", "Stream", "<", "E", ">", "stream", "(", "JsArrayLike", "<", "E", ">", "nodes", ")", "{", "if", "(", "nodes", "==", "null", ")", "{", "return", "Stream", ".", "empty", "(", ")", ";", "}", "else", "{", "return", ...
Returns a stream for the elements in the given array-like.
[ "Returns", "a", "stream", "for", "the", "elements", "in", "the", "given", "array", "-", "like", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L600-L606
135,638
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.stream
public static Stream<Node> stream(Node parent) { if (parent == null) { return Stream.empty(); } else { return StreamSupport.stream(spliteratorUnknownSize(iterator(parent), 0), false); } }
java
public static Stream<Node> stream(Node parent) { if (parent == null) { return Stream.empty(); } else { return StreamSupport.stream(spliteratorUnknownSize(iterator(parent), 0), false); } }
[ "public", "static", "Stream", "<", "Node", ">", "stream", "(", "Node", "parent", ")", "{", "if", "(", "parent", "==", "null", ")", "{", "return", "Stream", ".", "empty", "(", ")", ";", "}", "else", "{", "return", "StreamSupport", ".", "stream", "(", ...
Returns a stream for the child nodes of the given parent node.
[ "Returns", "a", "stream", "for", "the", "child", "nodes", "of", "the", "given", "parent", "node", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L609-L615
135,639
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.lazyAppend
public static void lazyAppend(Element parent, Element child) { if (!parent.contains(child)) { parent.appendChild(child); } }
java
public static void lazyAppend(Element parent, Element child) { if (!parent.contains(child)) { parent.appendChild(child); } }
[ "public", "static", "void", "lazyAppend", "(", "Element", "parent", ",", "Element", "child", ")", "{", "if", "(", "!", "parent", ".", "contains", "(", "child", ")", ")", "{", "parent", ".", "appendChild", "(", "child", ")", ";", "}", "}" ]
Appends the specified element to the parent element if not already present. If parent already contains child, this method does nothing.
[ "Appends", "the", "specified", "element", "to", "the", "parent", "element", "if", "not", "already", "present", ".", "If", "parent", "already", "contains", "child", "this", "method", "does", "nothing", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L648-L652
135,640
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.insertAfter
public static void insertAfter(Element newElement, Element after) { after.parentNode.insertBefore(newElement, after.nextSibling); }
java
public static void insertAfter(Element newElement, Element after) { after.parentNode.insertBefore(newElement, after.nextSibling); }
[ "public", "static", "void", "insertAfter", "(", "Element", "newElement", ",", "Element", "after", ")", "{", "after", ".", "parentNode", ".", "insertBefore", "(", "newElement", ",", "after", ".", "nextSibling", ")", ";", "}" ]
Inserts the specified element into the parent of the after element.
[ "Inserts", "the", "specified", "element", "into", "the", "parent", "of", "the", "after", "element", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L655-L657
135,641
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.lazyInsertAfter
public static void lazyInsertAfter(Element newElement, Element after) { if (!after.parentNode.contains(newElement)) { after.parentNode.insertBefore(newElement, after.nextSibling); } }
java
public static void lazyInsertAfter(Element newElement, Element after) { if (!after.parentNode.contains(newElement)) { after.parentNode.insertBefore(newElement, after.nextSibling); } }
[ "public", "static", "void", "lazyInsertAfter", "(", "Element", "newElement", ",", "Element", "after", ")", "{", "if", "(", "!", "after", ".", "parentNode", ".", "contains", "(", "newElement", ")", ")", "{", "after", ".", "parentNode", ".", "insertBefore", ...
Inserts the specified element into the parent of the after element if not already present. If parent already contains child, this method does nothing.
[ "Inserts", "the", "specified", "element", "into", "the", "parent", "of", "the", "after", "element", "if", "not", "already", "present", ".", "If", "parent", "already", "contains", "child", "this", "method", "does", "nothing", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L663-L667
135,642
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.insertBefore
public static void insertBefore(Element newElement, Element before) { before.parentNode.insertBefore(newElement, before); }
java
public static void insertBefore(Element newElement, Element before) { before.parentNode.insertBefore(newElement, before); }
[ "public", "static", "void", "insertBefore", "(", "Element", "newElement", ",", "Element", "before", ")", "{", "before", ".", "parentNode", ".", "insertBefore", "(", "newElement", ",", "before", ")", ";", "}" ]
Inserts the specified element into the parent of the before element.
[ "Inserts", "the", "specified", "element", "into", "the", "parent", "of", "the", "before", "element", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L680-L682
135,643
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.lazyInsertBefore
public static void lazyInsertBefore(Element newElement, Element before) { if (!before.parentNode.contains(newElement)) { before.parentNode.insertBefore(newElement, before); } }
java
public static void lazyInsertBefore(Element newElement, Element before) { if (!before.parentNode.contains(newElement)) { before.parentNode.insertBefore(newElement, before); } }
[ "public", "static", "void", "lazyInsertBefore", "(", "Element", "newElement", ",", "Element", "before", ")", "{", "if", "(", "!", "before", ".", "parentNode", ".", "contains", "(", "newElement", ")", ")", "{", "before", ".", "parentNode", ".", "insertBefore"...
Inserts the specified element into the parent of the before element if not already present. If parent already contains child, this method does nothing.
[ "Inserts", "the", "specified", "element", "into", "the", "parent", "of", "the", "before", "element", "if", "not", "already", "present", ".", "If", "parent", "already", "contains", "child", "this", "method", "does", "nothing", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L688-L692
135,644
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.failSafeRemoveFromParent
public static boolean failSafeRemoveFromParent(Element element) { return failSafeRemove(element != null ? element.parentNode : null, element); }
java
public static boolean failSafeRemoveFromParent(Element element) { return failSafeRemove(element != null ? element.parentNode : null, element); }
[ "public", "static", "boolean", "failSafeRemoveFromParent", "(", "Element", "element", ")", "{", "return", "failSafeRemove", "(", "element", "!=", "null", "?", "element", ".", "parentNode", ":", "null", ",", "element", ")", ";", "}" ]
Removes the element from its parent if the element is not null and has a parent. @return {@code true} if the the element has been removed from its parent, {@code false} otherwise.
[ "Removes", "the", "element", "from", "its", "parent", "if", "the", "element", "is", "not", "null", "and", "has", "a", "parent", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L718-L720
135,645
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.failSafeRemove
public static boolean failSafeRemove(Node parent, Element child) { //noinspection SimplifiableIfStatement if (parent != null && child != null && parent.contains(child)) { return parent.removeChild(child) != null; } return false; }
java
public static boolean failSafeRemove(Node parent, Element child) { //noinspection SimplifiableIfStatement if (parent != null && child != null && parent.contains(child)) { return parent.removeChild(child) != null; } return false; }
[ "public", "static", "boolean", "failSafeRemove", "(", "Node", "parent", ",", "Element", "child", ")", "{", "//noinspection SimplifiableIfStatement", "if", "(", "parent", "!=", "null", "&&", "child", "!=", "null", "&&", "parent", ".", "contains", "(", "child", ...
Removes the child from parent if both parent and child are not null and parent contains child. @return {@code true} if the the element has been removed from its parent, {@code false} otherwise.
[ "Removes", "the", "child", "from", "parent", "if", "both", "parent", "and", "child", "are", "not", "null", "and", "parent", "contains", "child", "." ]
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L727-L733
135,646
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.onAttach
public static void onAttach(HTMLElement element, ObserverCallback callback) { if (element != null) { BodyObserver.addAttachObserver(element, callback); } }
java
public static void onAttach(HTMLElement element, ObserverCallback callback) { if (element != null) { BodyObserver.addAttachObserver(element, callback); } }
[ "public", "static", "void", "onAttach", "(", "HTMLElement", "element", ",", "ObserverCallback", "callback", ")", "{", "if", "(", "element", "!=", "null", ")", "{", "BodyObserver", ".", "addAttachObserver", "(", "element", ",", "callback", ")", ";", "}", "}" ...
Registers a callback when an element is appended to the document body. Note that the callback will be called only once, if the element is appended more than once a new callback should be registered. @param element the HTML element which is going to be added to the body @param callback {@link ObserverCallback}
[ "Registers", "a", "callback", "when", "an", "element", "is", "appended", "to", "the", "document", "body", ".", "Note", "that", "the", "callback", "will", "be", "called", "only", "once", "if", "the", "element", "is", "appended", "more", "than", "once", "a",...
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L742-L746
135,647
hal/elemento
core/src/main/java/org/jboss/gwt/elemento/core/Elements.java
Elements.onDetach
public static void onDetach(HTMLElement element, ObserverCallback callback) { if (element != null) { BodyObserver.addDetachObserver(element, callback); } }
java
public static void onDetach(HTMLElement element, ObserverCallback callback) { if (element != null) { BodyObserver.addDetachObserver(element, callback); } }
[ "public", "static", "void", "onDetach", "(", "HTMLElement", "element", ",", "ObserverCallback", "callback", ")", "{", "if", "(", "element", "!=", "null", ")", "{", "BodyObserver", ".", "addDetachObserver", "(", "element", ",", "callback", ")", ";", "}", "}" ...
Registers a callback when an element is removed from the document body. Note that the callback will be called only once, if the element is removed and re-appended a new callback should be registered. @param element the HTML element which is going to be removed from the body @param callback {@link ObserverCallback}
[ "Registers", "a", "callback", "when", "an", "element", "is", "removed", "from", "the", "document", "body", ".", "Note", "that", "the", "callback", "will", "be", "called", "only", "once", "if", "the", "element", "is", "removed", "and", "re", "-", "appended"...
26da2d5a1fe2ec55b779737dbaeda25a942eee61
https://github.com/hal/elemento/blob/26da2d5a1fe2ec55b779737dbaeda25a942eee61/core/src/main/java/org/jboss/gwt/elemento/core/Elements.java#L755-L759
135,648
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/widget/AccentSwitch.java
AccentSwitch.setSwitchTextAppearance
public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = context.obtainStyledAttributes(resid, R.styleable.TextAppearanceAccentSwitch); ColorStateList colors; int ts; colors = appearance .getColorStateList(R.styleable.TextAppearanceAccentSwitch_android_textColor); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's // textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize( R.styleable.TextAppearanceAccentSwitch_android_textSize, 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } int typefaceIndex, styleIndex; typefaceIndex = appearance.getInt( R.styleable.TextAppearanceAccentSwitch_android_typeface, -1); styleIndex = appearance.getInt( R.styleable.TextAppearanceAccentSwitch_android_textStyle, -1); setSwitchTypefaceByIndex(typefaceIndex, styleIndex); boolean allCaps = appearance.getBoolean( R.styleable.TextAppearanceAccentSwitch_android_textAllCaps, false); if (allCaps) { mSwitchTransformationMethod = new AllCapsTransformationMethod( getContext()); mSwitchTransformationMethod.setLengthChangesAllowed(true); } else { mSwitchTransformationMethod = null; } appearance.recycle(); }
java
public void setSwitchTextAppearance(Context context, int resid) { TypedArray appearance = context.obtainStyledAttributes(resid, R.styleable.TextAppearanceAccentSwitch); ColorStateList colors; int ts; colors = appearance .getColorStateList(R.styleable.TextAppearanceAccentSwitch_android_textColor); if (colors != null) { mTextColors = colors; } else { // If no color set in TextAppearance, default to the view's // textColor mTextColors = getTextColors(); } ts = appearance.getDimensionPixelSize( R.styleable.TextAppearanceAccentSwitch_android_textSize, 0); if (ts != 0) { if (ts != mTextPaint.getTextSize()) { mTextPaint.setTextSize(ts); requestLayout(); } } int typefaceIndex, styleIndex; typefaceIndex = appearance.getInt( R.styleable.TextAppearanceAccentSwitch_android_typeface, -1); styleIndex = appearance.getInt( R.styleable.TextAppearanceAccentSwitch_android_textStyle, -1); setSwitchTypefaceByIndex(typefaceIndex, styleIndex); boolean allCaps = appearance.getBoolean( R.styleable.TextAppearanceAccentSwitch_android_textAllCaps, false); if (allCaps) { mSwitchTransformationMethod = new AllCapsTransformationMethod( getContext()); mSwitchTransformationMethod.setLengthChangesAllowed(true); } else { mSwitchTransformationMethod = null; } appearance.recycle(); }
[ "public", "void", "setSwitchTextAppearance", "(", "Context", "context", ",", "int", "resid", ")", "{", "TypedArray", "appearance", "=", "context", ".", "obtainStyledAttributes", "(", "resid", ",", "R", ".", "styleable", ".", "TextAppearanceAccentSwitch", ")", ";",...
Sets the switch text color, size, style, hint color, and highlight color from the specified TextAppearance resource. @attr ref android.R.styleable#Switch_switchTextAppearance
[ "Sets", "the", "switch", "text", "color", "size", "style", "hint", "color", "and", "highlight", "color", "from", "the", "specified", "TextAppearance", "resource", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/widget/AccentSwitch.java#L255-L301
135,649
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/widget/AccentSwitch.java
AccentSwitch.stopDrag
private void stopDrag(MotionEvent ev) { mTouchMode = TOUCH_MODE_IDLE; // Up and not canceled, also checks the switch has not been disabled // during the drag boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); cancelSuperTouch(ev); if (commitChange) { boolean newState; mVelocityTracker.computeCurrentVelocity(1000); float xvel = mVelocityTracker.getXVelocity(); if (Math.abs(xvel) > mMinFlingVelocity) { // newState = isLayoutRtl() ? (xvel < 0) : (xvel > 0); newState = xvel > 0; } else { newState = getTargetCheckedState(); } animateThumbToCheckedState(newState); } else { animateThumbToCheckedState(isChecked()); } }
java
private void stopDrag(MotionEvent ev) { mTouchMode = TOUCH_MODE_IDLE; // Up and not canceled, also checks the switch has not been disabled // during the drag boolean commitChange = ev.getAction() == MotionEvent.ACTION_UP && isEnabled(); cancelSuperTouch(ev); if (commitChange) { boolean newState; mVelocityTracker.computeCurrentVelocity(1000); float xvel = mVelocityTracker.getXVelocity(); if (Math.abs(xvel) > mMinFlingVelocity) { // newState = isLayoutRtl() ? (xvel < 0) : (xvel > 0); newState = xvel > 0; } else { newState = getTargetCheckedState(); } animateThumbToCheckedState(newState); } else { animateThumbToCheckedState(isChecked()); } }
[ "private", "void", "stopDrag", "(", "MotionEvent", "ev", ")", "{", "mTouchMode", "=", "TOUCH_MODE_IDLE", ";", "// Up and not canceled, also checks the switch has not been disabled", "// during the drag", "boolean", "commitChange", "=", "ev", ".", "getAction", "(", ")", "=...
Called from onTouchEvent to end a drag operation. @param ev Event that triggered the end of drag mode - ACTION_UP or ACTION_CANCEL
[ "Called", "from", "onTouchEvent", "to", "end", "a", "drag", "operation", "." ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/widget/AccentSwitch.java#L694-L717
135,650
marvinlabs/android-floatinglabel-widgets
library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/TimePickerFragment.java
TimePickerFragment.newInstance
public static <TimeInstantT extends TimeInstant> TimePickerFragment newInstance(int pickerId, TimeInstantT selectedInstant) { TimePickerFragment f = new TimePickerFragment(); Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant); f.setArguments(args); return f; }
java
public static <TimeInstantT extends TimeInstant> TimePickerFragment newInstance(int pickerId, TimeInstantT selectedInstant) { TimePickerFragment f = new TimePickerFragment(); Bundle args = new Bundle(); args.putInt(ARG_PICKER_ID, pickerId); args.putParcelable(ARG_SELECTED_INSTANT, selectedInstant); f.setArguments(args); return f; }
[ "public", "static", "<", "TimeInstantT", "extends", "TimeInstant", ">", "TimePickerFragment", "newInstance", "(", "int", "pickerId", ",", "TimeInstantT", "selectedInstant", ")", "{", "TimePickerFragment", "f", "=", "new", "TimePickerFragment", "(", ")", ";", "Bundle...
Create a new time picker @param pickerId The id of the item picker @param selectedInstant The positions of the items already selected @return The arguments bundle
[ "Create", "a", "new", "time", "picker" ]
bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f
https://github.com/marvinlabs/android-floatinglabel-widgets/blob/bb89889f1e75ed9b228b77d3ba895ceeeb41fe4f/library/src/main/java/com/marvinlabs/widget/floatinglabel/instantpicker/TimePickerFragment.java#L33-L42
135,651
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/widget/AccentSearchView.java
AccentSearchView.setBackground
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private void setBackground(View view, Drawable drawable) { if (Build.VERSION.SDK_INT >= SET_DRAWABLE_MIN_SDK) view.setBackground(drawable); else view.setBackgroundDrawable(drawable); }
java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private void setBackground(View view, Drawable drawable) { if (Build.VERSION.SDK_INT >= SET_DRAWABLE_MIN_SDK) view.setBackground(drawable); else view.setBackgroundDrawable(drawable); }
[ "@", "SuppressWarnings", "(", "\"deprecation\"", ")", "@", "SuppressLint", "(", "\"NewApi\"", ")", "private", "void", "setBackground", "(", "View", "view", ",", "Drawable", "drawable", ")", "{", "if", "(", "Build", ".", "VERSION", ".", "SDK_INT", ">=", "SET_...
Call the appropriate method to set the background to the View
[ "Call", "the", "appropriate", "method", "to", "set", "the", "background", "to", "the", "View" ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/widget/AccentSearchView.java#L51-L58
135,652
negusoft/holoaccent
HoloAccent/src/com/negusoft/holoaccent/preference/SwitchPreference.java
SwitchPreference.sendAccessibilityEvent
void sendAccessibilityEvent(View view) { // Since the view is still not attached we create, populate, // and send the event directly since we do not know when it // will be attached and posting commands is not as clean. AccessibilityManager accessibilityManager = (AccessibilityManager)getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager == null) return; if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(); event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED); view.onInitializeAccessibilityEvent(event); view.dispatchPopulateAccessibilityEvent(event); accessibilityManager.sendAccessibilityEvent(event); } mSendClickAccessibilityEvent = false; }
java
void sendAccessibilityEvent(View view) { // Since the view is still not attached we create, populate, // and send the event directly since we do not know when it // will be attached and posting commands is not as clean. AccessibilityManager accessibilityManager = (AccessibilityManager)getContext().getSystemService(Context.ACCESSIBILITY_SERVICE); if (accessibilityManager == null) return; if (mSendClickAccessibilityEvent && accessibilityManager.isEnabled()) { AccessibilityEvent event = AccessibilityEvent.obtain(); event.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED); view.onInitializeAccessibilityEvent(event); view.dispatchPopulateAccessibilityEvent(event); accessibilityManager.sendAccessibilityEvent(event); } mSendClickAccessibilityEvent = false; }
[ "void", "sendAccessibilityEvent", "(", "View", "view", ")", "{", "// Since the view is still not attached we create, populate,", "// and send the event directly since we do not know when it", "// will be attached and posting commands is not as clean.", "AccessibilityManager", "accessibilityMan...
As defined in TwoStatePreference source
[ "As", "defined", "in", "TwoStatePreference", "source" ]
7121a02dde94834e770cb81174d0bdc596323324
https://github.com/negusoft/holoaccent/blob/7121a02dde94834e770cb81174d0bdc596323324/HoloAccent/src/com/negusoft/holoaccent/preference/SwitchPreference.java#L104-L120
135,653
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.unescape
public static String unescape(String string, char escape) { CharArrayWriter out = new CharArrayWriter(string.length()); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (c == escape) { try { out.write(Integer.parseInt(string.substring(i + 1, i + 3), 16)); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } i += 2; } else { out.write(c); } } return new String(out.toCharArray()); }
java
public static String unescape(String string, char escape) { CharArrayWriter out = new CharArrayWriter(string.length()); for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (c == escape) { try { out.write(Integer.parseInt(string.substring(i + 1, i + 3), 16)); } catch (NumberFormatException e) { throw new IllegalArgumentException(e); } i += 2; } else { out.write(c); } } return new String(out.toCharArray()); }
[ "public", "static", "String", "unescape", "(", "String", "string", ",", "char", "escape", ")", "{", "CharArrayWriter", "out", "=", "new", "CharArrayWriter", "(", "string", ".", "length", "(", ")", ")", ";", "for", "(", "int", "i", "=", "0", ";", "i", ...
Unescapes string using escape symbol. @param string string @param escape escape symbol @return unescaped string
[ "Unescapes", "string", "using", "escape", "symbol", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L41-L65
135,654
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.escape
public static String escape(String string, char escape, boolean isPath) { try { BitSet validChars = isPath ? URISaveEx : URISave; byte[] bytes = string.getBytes("utf-8"); StringBuffer out = new StringBuffer(bytes.length); for (int i = 0; i < bytes.length; i++) { int c = bytes[i] & 0xff; if (validChars.get(c) && c != escape) { out.append((char)c); } else { out.append(escape); out.append(hexTable[(c >> 4) & 0x0f]); out.append(hexTable[(c) & 0x0f]); } } return out.toString(); } catch (Exception exc) { throw new InternalError(exc.toString()); } }
java
public static String escape(String string, char escape, boolean isPath) { try { BitSet validChars = isPath ? URISaveEx : URISave; byte[] bytes = string.getBytes("utf-8"); StringBuffer out = new StringBuffer(bytes.length); for (int i = 0; i < bytes.length; i++) { int c = bytes[i] & 0xff; if (validChars.get(c) && c != escape) { out.append((char)c); } else { out.append(escape); out.append(hexTable[(c >> 4) & 0x0f]); out.append(hexTable[(c) & 0x0f]); } } return out.toString(); } catch (Exception exc) { throw new InternalError(exc.toString()); } }
[ "public", "static", "String", "escape", "(", "String", "string", ",", "char", "escape", ",", "boolean", "isPath", ")", "{", "try", "{", "BitSet", "validChars", "=", "isPath", "?", "URISaveEx", ":", "URISave", ";", "byte", "[", "]", "bytes", "=", "string"...
Escapes string using escape symbol. @param string string @param escape escape symbol @param isPath if the string is path @return escaped string
[ "Escapes", "string", "using", "escape", "symbol", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L119-L146
135,655
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.relativizePath
public static String relativizePath(String path, boolean withIndex) { if (path.startsWith("/")) path = path.substring(1); if (!withIndex && path.endsWith("]")) { int index = path.lastIndexOf('['); return index == -1 ? path : path.substring(0, index); } return path; }
java
public static String relativizePath(String path, boolean withIndex) { if (path.startsWith("/")) path = path.substring(1); if (!withIndex && path.endsWith("]")) { int index = path.lastIndexOf('['); return index == -1 ? path : path.substring(0, index); } return path; }
[ "public", "static", "String", "relativizePath", "(", "String", "path", ",", "boolean", "withIndex", ")", "{", "if", "(", "path", ".", "startsWith", "(", "\"/\"", ")", ")", "path", "=", "path", ".", "substring", "(", "1", ")", ";", "if", "(", "!", "wi...
Creates relative path from string. @param path path @param withIndex indicates whether we should keep the index or not @return relative path
[ "Creates", "relative", "path", "from", "string", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L166-L177
135,656
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.removeIndexFromPath
public static String removeIndexFromPath(String path) { if (path.endsWith("]")) { int index = path.lastIndexOf('['); if (index != -1) { return path.substring(0, index); } } return path; }
java
public static String removeIndexFromPath(String path) { if (path.endsWith("]")) { int index = path.lastIndexOf('['); if (index != -1) { return path.substring(0, index); } } return path; }
[ "public", "static", "String", "removeIndexFromPath", "(", "String", "path", ")", "{", "if", "(", "path", ".", "endsWith", "(", "\"]\"", ")", ")", "{", "int", "index", "=", "path", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", "!=",...
Removes the index from the path if it has an index defined
[ "Removes", "the", "index", "from", "the", "path", "if", "it", "has", "an", "index", "defined" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L182-L193
135,657
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.pathOnly
public static String pathOnly(String path) { String curPath = path; curPath = curPath.substring(curPath.indexOf("/")); curPath = curPath.substring(0, curPath.lastIndexOf("/")); if ("".equals(curPath)) { curPath = "/"; } return curPath; }
java
public static String pathOnly(String path) { String curPath = path; curPath = curPath.substring(curPath.indexOf("/")); curPath = curPath.substring(0, curPath.lastIndexOf("/")); if ("".equals(curPath)) { curPath = "/"; } return curPath; }
[ "public", "static", "String", "pathOnly", "(", "String", "path", ")", "{", "String", "curPath", "=", "path", ";", "curPath", "=", "curPath", ".", "substring", "(", "curPath", ".", "indexOf", "(", "\"/\"", ")", ")", ";", "curPath", "=", "curPath", ".", ...
Cuts the path from string. @param path full path @return relative path.
[ "Cuts", "the", "path", "from", "string", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L201-L211
135,658
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.nameOnly
public static String nameOnly(String path) { int index = path.lastIndexOf('/'); String name = index == -1 ? path : path.substring(index + 1); if (name.endsWith("]")) { index = name.lastIndexOf('['); return index == -1 ? name : name.substring(0, index); } return name; }
java
public static String nameOnly(String path) { int index = path.lastIndexOf('/'); String name = index == -1 ? path : path.substring(index + 1); if (name.endsWith("]")) { index = name.lastIndexOf('['); return index == -1 ? name : name.substring(0, index); } return name; }
[ "public", "static", "String", "nameOnly", "(", "String", "path", ")", "{", "int", "index", "=", "path", ".", "lastIndexOf", "(", "'", "'", ")", ";", "String", "name", "=", "index", "==", "-", "1", "?", "path", ":", "path", ".", "substring", "(", "i...
Cuts the current name from the path. @param path path @return current name
[ "Cuts", "the", "current", "name", "from", "the", "path", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L239-L249
135,659
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java
TextUtil.getExtension
public static String getExtension(String filename) { int index = filename.lastIndexOf('.'); if (index >= 0) { return filename.substring(index + 1); } return ""; }
java
public static String getExtension(String filename) { int index = filename.lastIndexOf('.'); if (index >= 0) { return filename.substring(index + 1); } return ""; }
[ "public", "static", "String", "getExtension", "(", "String", "filename", ")", "{", "int", "index", "=", "filename", ".", "lastIndexOf", "(", "'", "'", ")", ";", "if", "(", "index", ">=", "0", ")", "{", "return", "filename", ".", "substring", "(", "inde...
Extracts the extension of the file. @param filename file name @return extension or emtpy string if file has no extension
[ "Extracts", "the", "extension", "of", "the", "file", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/util/TextUtil.java#L268-L278
135,660
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
ItemDataMergeVisitor.isPredecessor
protected boolean isPredecessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager(); PropertyData predecessorsProperty = (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_PREDECESSORS, 0), ItemType.PROPERTY); if (predecessorsProperty != null) { for (ValueData pv : predecessorsProperty.getValues()) { String pidentifier = ValueDataUtil.getString(pv); if (pidentifier.equals(corrVersion.getIdentifier())) { return true; // got it } // search in predecessors of the predecessor NodeData predecessor = (NodeData)mergeDataManager.getItemData(pidentifier); if (predecessor != null) { if (isPredecessor(predecessor, corrVersion)) { return true; } } else { throw new RepositoryException("Merge. Predecessor is not found by uuid " + pidentifier + ". Version " + mergeSession.getLocationFactory().createJCRPath(mergeVersion.getQPath()).getAsString(false)); } } // else it's a root version } return false; }
java
protected boolean isPredecessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager(); PropertyData predecessorsProperty = (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_PREDECESSORS, 0), ItemType.PROPERTY); if (predecessorsProperty != null) { for (ValueData pv : predecessorsProperty.getValues()) { String pidentifier = ValueDataUtil.getString(pv); if (pidentifier.equals(corrVersion.getIdentifier())) { return true; // got it } // search in predecessors of the predecessor NodeData predecessor = (NodeData)mergeDataManager.getItemData(pidentifier); if (predecessor != null) { if (isPredecessor(predecessor, corrVersion)) { return true; } } else { throw new RepositoryException("Merge. Predecessor is not found by uuid " + pidentifier + ". Version " + mergeSession.getLocationFactory().createJCRPath(mergeVersion.getQPath()).getAsString(false)); } } // else it's a root version } return false; }
[ "protected", "boolean", "isPredecessor", "(", "NodeData", "mergeVersion", ",", "NodeData", "corrVersion", ")", "throws", "RepositoryException", "{", "SessionDataManager", "mergeDataManager", "=", "mergeSession", ".", "getTransientNodesManager", "(", ")", ";", "PropertyDat...
Is a predecessor of the merge version
[ "Is", "a", "predecessor", "of", "the", "merge", "version" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java#L478-L516
135,661
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java
ItemDataMergeVisitor.isSuccessor
protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager(); PropertyData successorsProperty = (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0), ItemType.PROPERTY); if (successorsProperty != null) { for (ValueData sv : successorsProperty.getValues()) { String sidentifier = ValueDataUtil.getString(sv); if (sidentifier.equals(corrVersion.getIdentifier())) { return true; // got it } // search in successors of the successor NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier); if (successor != null) { if (isSuccessor(successor, corrVersion)) { return true; } } else { throw new RepositoryException("Merge. Ssuccessor is not found by uuid " + sidentifier + ". Version " + mergeSession.getLocationFactory().createJCRPath(mergeVersion.getQPath()).getAsString(false)); } } // else it's a end of version graph node } return false; }
java
protected boolean isSuccessor(NodeData mergeVersion, NodeData corrVersion) throws RepositoryException { SessionDataManager mergeDataManager = mergeSession.getTransientNodesManager(); PropertyData successorsProperty = (PropertyData)mergeDataManager.getItemData(mergeVersion, new QPathEntry(Constants.JCR_SUCCESSORS, 0), ItemType.PROPERTY); if (successorsProperty != null) { for (ValueData sv : successorsProperty.getValues()) { String sidentifier = ValueDataUtil.getString(sv); if (sidentifier.equals(corrVersion.getIdentifier())) { return true; // got it } // search in successors of the successor NodeData successor = (NodeData)mergeDataManager.getItemData(sidentifier); if (successor != null) { if (isSuccessor(successor, corrVersion)) { return true; } } else { throw new RepositoryException("Merge. Ssuccessor is not found by uuid " + sidentifier + ". Version " + mergeSession.getLocationFactory().createJCRPath(mergeVersion.getQPath()).getAsString(false)); } } // else it's a end of version graph node } return false; }
[ "protected", "boolean", "isSuccessor", "(", "NodeData", "mergeVersion", ",", "NodeData", "corrVersion", ")", "throws", "RepositoryException", "{", "SessionDataManager", "mergeDataManager", "=", "mergeSession", ".", "getTransientNodesManager", "(", ")", ";", "PropertyData"...
Is a successor of the merge version
[ "Is", "a", "successor", "of", "the", "merge", "version" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/version/ItemDataMergeVisitor.java#L521-L559
135,662
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedNodeDataReader.java
PersistedNodeDataReader.read
public PersistedNodeData read(ObjectReader in) throws UnknownClassIdException, IOException { // read id int key; if ((key = in.readInt()) != SerializationConstants.PERSISTED_NODE_DATA) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } QPath qpath; try { String sQPath = in.readString(); qpath = QPath.parse(sQPath); } catch (final IllegalPathException e) { throw new IOException("Deserialization error. " + e) { /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } String identifier = in.readString(); String parentIdentifier = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { parentIdentifier = in.readString(); } int persistedVersion = in.readInt(); // -------------- int orderNum = in.readInt(); // primary type InternalQName primaryTypeName; try { primaryTypeName = InternalQName.parse(in.readString()); } catch (final IllegalNameException e) { throw new IOException(e.getMessage()) { private static final long serialVersionUID = 3489809179234435267L; /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } // mixins InternalQName[] mixinTypeNames = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { int count = in.readInt(); mixinTypeNames = new InternalQName[count]; for (int i = 0; i < count; i++) { try { mixinTypeNames[i] = InternalQName.parse(in.readString()); } catch (final IllegalNameException e) { throw new IOException(e.getMessage()) { private static final long serialVersionUID = 3489809179234435268L; // eclipse // gen /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } } } // acl AccessControlList acl = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { ACLReader rdr = new ACLReader(); acl = rdr.read(in); } return new PersistedNodeData(identifier, qpath, parentIdentifier, persistedVersion, orderNum, primaryTypeName, mixinTypeNames, acl); }
java
public PersistedNodeData read(ObjectReader in) throws UnknownClassIdException, IOException { // read id int key; if ((key = in.readInt()) != SerializationConstants.PERSISTED_NODE_DATA) { throw new UnknownClassIdException("There is unexpected class [" + key + "]"); } QPath qpath; try { String sQPath = in.readString(); qpath = QPath.parse(sQPath); } catch (final IllegalPathException e) { throw new IOException("Deserialization error. " + e) { /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } String identifier = in.readString(); String parentIdentifier = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { parentIdentifier = in.readString(); } int persistedVersion = in.readInt(); // -------------- int orderNum = in.readInt(); // primary type InternalQName primaryTypeName; try { primaryTypeName = InternalQName.parse(in.readString()); } catch (final IllegalNameException e) { throw new IOException(e.getMessage()) { private static final long serialVersionUID = 3489809179234435267L; /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } // mixins InternalQName[] mixinTypeNames = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { int count = in.readInt(); mixinTypeNames = new InternalQName[count]; for (int i = 0; i < count; i++) { try { mixinTypeNames[i] = InternalQName.parse(in.readString()); } catch (final IllegalNameException e) { throw new IOException(e.getMessage()) { private static final long serialVersionUID = 3489809179234435268L; // eclipse // gen /** * {@inheritDoc} */ @Override public Throwable getCause() { return e; } }; } } } // acl AccessControlList acl = null; if (in.readByte() == SerializationConstants.NOT_NULL_DATA) { ACLReader rdr = new ACLReader(); acl = rdr.read(in); } return new PersistedNodeData(identifier, qpath, parentIdentifier, persistedVersion, orderNum, primaryTypeName, mixinTypeNames, acl); }
[ "public", "PersistedNodeData", "read", "(", "ObjectReader", "in", ")", "throws", "UnknownClassIdException", ",", "IOException", "{", "// read id", "int", "key", ";", "if", "(", "(", "key", "=", "in", ".", "readInt", "(", ")", ")", "!=", "SerializationConstants...
Read and set PersistedNodeData data. @param in ObjectReader. @return PersistedNodeData object. @throws UnknownClassIdException If read Class ID is not expected or do not exist. @throws IOException If an I/O error has occurred.
[ "Read", "and", "set", "PersistedNodeData", "data", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/dataflow/serialization/PersistedNodeDataReader.java#L51-L161
135,663
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.prepareRenamingApproachScripts
protected void prepareRenamingApproachScripts() throws DBCleanException { cleaningScripts.addAll(getTablesRenamingScripts()); cleaningScripts.addAll(getDBInitializationScripts()); cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getConstraintsRemovingScripts()); cleaningScripts.addAll(getIndexesDroppingScripts()); committingScripts.addAll(getOldTablesDroppingScripts()); committingScripts.addAll(getIndexesAddingScripts()); committingScripts.addAll(getConstraintsAddingScripts()); committingScripts.addAll(getFKAddingScripts()); rollbackingScripts.addAll(getTablesDroppingScripts()); rollbackingScripts.addAll(getOldTablesRenamingScripts()); }
java
protected void prepareRenamingApproachScripts() throws DBCleanException { cleaningScripts.addAll(getTablesRenamingScripts()); cleaningScripts.addAll(getDBInitializationScripts()); cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getConstraintsRemovingScripts()); cleaningScripts.addAll(getIndexesDroppingScripts()); committingScripts.addAll(getOldTablesDroppingScripts()); committingScripts.addAll(getIndexesAddingScripts()); committingScripts.addAll(getConstraintsAddingScripts()); committingScripts.addAll(getFKAddingScripts()); rollbackingScripts.addAll(getTablesDroppingScripts()); rollbackingScripts.addAll(getOldTablesRenamingScripts()); }
[ "protected", "void", "prepareRenamingApproachScripts", "(", ")", "throws", "DBCleanException", "{", "cleaningScripts", ".", "addAll", "(", "getTablesRenamingScripts", "(", ")", ")", ";", "cleaningScripts", ".", "addAll", "(", "getDBInitializationScripts", "(", ")", ")...
Prepares scripts for renaming approach database cleaning. @throws DBCleanException
[ "Prepares", "scripts", "for", "renaming", "approach", "database", "cleaning", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L150-L165
135,664
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.prepareDroppingTablesApproachScripts
protected void prepareDroppingTablesApproachScripts() throws DBCleanException { cleaningScripts.addAll(getTablesDroppingScripts()); cleaningScripts.addAll(getDBInitializationScripts()); cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getIndexesDroppingScripts()); committingScripts.addAll(getIndexesAddingScripts()); committingScripts.addAll(getFKAddingScripts()); }
java
protected void prepareDroppingTablesApproachScripts() throws DBCleanException { cleaningScripts.addAll(getTablesDroppingScripts()); cleaningScripts.addAll(getDBInitializationScripts()); cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getIndexesDroppingScripts()); committingScripts.addAll(getIndexesAddingScripts()); committingScripts.addAll(getFKAddingScripts()); }
[ "protected", "void", "prepareDroppingTablesApproachScripts", "(", ")", "throws", "DBCleanException", "{", "cleaningScripts", ".", "addAll", "(", "getTablesDroppingScripts", "(", ")", ")", ";", "cleaningScripts", ".", "addAll", "(", "getDBInitializationScripts", "(", ")"...
Prepares scripts for dropping tables approach database cleaning. @throws DBCleanException
[ "Prepares", "scripts", "for", "dropping", "tables", "approach", "database", "cleaning", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L172-L181
135,665
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.prepareSimpleCleaningApproachScripts
protected void prepareSimpleCleaningApproachScripts() { cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getSingleDbWorkspaceCleaningScripts()); committingScripts.addAll(getFKAddingScripts()); rollbackingScripts.addAll(getFKAddingScripts()); }
java
protected void prepareSimpleCleaningApproachScripts() { cleaningScripts.addAll(getFKRemovingScripts()); cleaningScripts.addAll(getSingleDbWorkspaceCleaningScripts()); committingScripts.addAll(getFKAddingScripts()); rollbackingScripts.addAll(getFKAddingScripts()); }
[ "protected", "void", "prepareSimpleCleaningApproachScripts", "(", ")", "{", "cleaningScripts", ".", "addAll", "(", "getFKRemovingScripts", "(", ")", ")", ";", "cleaningScripts", ".", "addAll", "(", "getSingleDbWorkspaceCleaningScripts", "(", ")", ")", ";", "committing...
Prepares scripts for simple cleaning database.
[ "Prepares", "scripts", "for", "simple", "cleaning", "database", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L186-L194
135,666
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.getFKRemovingScripts
protected Collection<String> getFKRemovingScripts() { List<String> scripts = new ArrayList<String>(); String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT"; scripts.add("ALTER TABLE " + itemTableName + " " + constraintDroppingSyntax() + " " + constraintName); return scripts; }
java
protected Collection<String> getFKRemovingScripts() { List<String> scripts = new ArrayList<String>(); String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT"; scripts.add("ALTER TABLE " + itemTableName + " " + constraintDroppingSyntax() + " " + constraintName); return scripts; }
[ "protected", "Collection", "<", "String", ">", "getFKRemovingScripts", "(", ")", "{", "List", "<", "String", ">", "scripts", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "constraintName", "=", "\"JCR_FK_\"", "+", "itemTableSuffix", "...
Returns SQL scripts for removing FK on JCR_ITEM table.
[ "Returns", "SQL", "scripts", "for", "removing", "FK", "on", "JCR_ITEM", "table", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L249-L257
135,667
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.getFKAddingScripts
protected Collection<String> getFKAddingScripts() { List<String> scripts = new ArrayList<String>(); String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)"; scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName); return scripts; }
java
protected Collection<String> getFKAddingScripts() { List<String> scripts = new ArrayList<String>(); String constraintName = "JCR_FK_" + itemTableSuffix + "_PARENT FOREIGN KEY(PARENT_ID) REFERENCES " + itemTableName + "(ID)"; scripts.add("ALTER TABLE " + itemTableName + " ADD CONSTRAINT " + constraintName); return scripts; }
[ "protected", "Collection", "<", "String", ">", "getFKAddingScripts", "(", ")", "{", "List", "<", "String", ">", "scripts", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "String", "constraintName", "=", "\"JCR_FK_\"", "+", "itemTableSuffix", "+"...
Returns SQL scripts for adding FK on JCR_ITEM table.
[ "Returns", "SQL", "scripts", "for", "adding", "FK", "on", "JCR_ITEM", "table", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L262-L271
135,668
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.getOldTablesDroppingScripts
protected Collection<String> getOldTablesDroppingScripts() { List<String> scripts = new ArrayList<String>(); scripts.add("DROP TABLE " + valueTableName + "_OLD"); scripts.add("DROP TABLE " + refTableName + "_OLD"); scripts.add("DROP TABLE " + itemTableName + "_OLD"); return scripts; }
java
protected Collection<String> getOldTablesDroppingScripts() { List<String> scripts = new ArrayList<String>(); scripts.add("DROP TABLE " + valueTableName + "_OLD"); scripts.add("DROP TABLE " + refTableName + "_OLD"); scripts.add("DROP TABLE " + itemTableName + "_OLD"); return scripts; }
[ "protected", "Collection", "<", "String", ">", "getOldTablesDroppingScripts", "(", ")", "{", "List", "<", "String", ">", "scripts", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "scripts", ".", "add", "(", "\"DROP TABLE \"", "+", "valueTableNam...
Returns SQL scripts for dropping existed old JCR tables.
[ "Returns", "SQL", "scripts", "for", "dropping", "existed", "old", "JCR", "tables", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L276-L285
135,669
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java
DBCleaningScripts.getDBInitializationScripts
protected Collection<String> getDBInitializationScripts() throws DBCleanException { String dbScripts; try { dbScripts = DBInitializerHelper.prepareScripts(wsEntry, dialect); } catch (IOException e) { throw new DBCleanException(e); } catch (RepositoryConfigurationException e) { throw new DBCleanException(e); } List<String> scripts = new ArrayList<String>(); for (String query : JDBCUtils.splitWithSQLDelimiter(dbScripts)) { if (query.contains(itemTableName + "_SEQ") || query.contains(itemTableName + "_NEXT_VAL")) { continue; } scripts.add(JDBCUtils.cleanWhitespaces(query)); } scripts.add(DBInitializerHelper.getRootNodeInitializeScript(itemTableName, multiDb)); return scripts; }
java
protected Collection<String> getDBInitializationScripts() throws DBCleanException { String dbScripts; try { dbScripts = DBInitializerHelper.prepareScripts(wsEntry, dialect); } catch (IOException e) { throw new DBCleanException(e); } catch (RepositoryConfigurationException e) { throw new DBCleanException(e); } List<String> scripts = new ArrayList<String>(); for (String query : JDBCUtils.splitWithSQLDelimiter(dbScripts)) { if (query.contains(itemTableName + "_SEQ") || query.contains(itemTableName + "_NEXT_VAL")) { continue; } scripts.add(JDBCUtils.cleanWhitespaces(query)); } scripts.add(DBInitializerHelper.getRootNodeInitializeScript(itemTableName, multiDb)); return scripts; }
[ "protected", "Collection", "<", "String", ">", "getDBInitializationScripts", "(", ")", "throws", "DBCleanException", "{", "String", "dbScripts", ";", "try", "{", "dbScripts", "=", "DBInitializerHelper", ".", "prepareScripts", "(", "wsEntry", ",", "dialect", ")", "...
Returns SQL scripts for database initalization. @throws DBCleanException
[ "Returns", "SQL", "scripts", "for", "database", "initalization", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/clean/rdbms/scripts/DBCleaningScripts.java#L322-L351
135,670
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
WorkspaceContainerFacade.getComponentInstancesOfType
public <T> List<T> getComponentInstancesOfType(Class<T> componentType) { return container.getComponentInstancesOfType(componentType); }
java
public <T> List<T> getComponentInstancesOfType(Class<T> componentType) { return container.getComponentInstancesOfType(componentType); }
[ "public", "<", "T", ">", "List", "<", "T", ">", "getComponentInstancesOfType", "(", "Class", "<", "T", ">", "componentType", ")", "{", "return", "container", ".", "getComponentInstancesOfType", "(", "componentType", ")", ";", "}" ]
Returns list of components of specific type. @param componentType component type @return List of Object
[ "Returns", "list", "of", "components", "of", "specific", "type", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java#L93-L96
135,671
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
WorkspaceContainerFacade.getState
public int getState() { boolean hasSuspendedComponents = false; boolean hasResumedComponents = false; List<Suspendable> suspendableComponents = getComponentInstancesOfType(Suspendable.class); for (Suspendable component : suspendableComponents) { if (component.isSuspended()) { hasSuspendedComponents = true; } else { hasResumedComponents = true; } } if (hasSuspendedComponents && !hasResumedComponents) { return ManageableRepository.SUSPENDED; } else if (!hasSuspendedComponents) { return ManageableRepository.ONLINE; } else { return ManageableRepository.UNDEFINED; } }
java
public int getState() { boolean hasSuspendedComponents = false; boolean hasResumedComponents = false; List<Suspendable> suspendableComponents = getComponentInstancesOfType(Suspendable.class); for (Suspendable component : suspendableComponents) { if (component.isSuspended()) { hasSuspendedComponents = true; } else { hasResumedComponents = true; } } if (hasSuspendedComponents && !hasResumedComponents) { return ManageableRepository.SUSPENDED; } else if (!hasSuspendedComponents) { return ManageableRepository.ONLINE; } else { return ManageableRepository.UNDEFINED; } }
[ "public", "int", "getState", "(", ")", "{", "boolean", "hasSuspendedComponents", "=", "false", ";", "boolean", "hasResumedComponents", "=", "false", ";", "List", "<", "Suspendable", ">", "suspendableComponents", "=", "getComponentInstancesOfType", "(", "Suspendable", ...
Returns current workspace state.
[ "Returns", "current", "workspace", "state", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java#L127-L156
135,672
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
WorkspaceContainerFacade.setState
public void setState(final int state) throws RepositoryException { // Need privileges to manage repository. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION); } try { SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>() { public Void run() throws RepositoryException { switch (state) { case ManageableRepository.ONLINE : resume(); break; case ManageableRepository.OFFLINE : suspend(); break; case ManageableRepository.SUSPENDED : suspend(); break; default : return null; } return null; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof RepositoryException) { throw new RepositoryException(cause); } else { throw new RuntimeException(cause); } } }
java
public void setState(final int state) throws RepositoryException { // Need privileges to manage repository. SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkPermission(JCRRuntimePermissions.MANAGE_REPOSITORY_PERMISSION); } try { SecurityHelper.doPrivilegedExceptionAction(new PrivilegedExceptionAction<Void>() { public Void run() throws RepositoryException { switch (state) { case ManageableRepository.ONLINE : resume(); break; case ManageableRepository.OFFLINE : suspend(); break; case ManageableRepository.SUSPENDED : suspend(); break; default : return null; } return null; } }); } catch (PrivilegedActionException e) { Throwable cause = e.getCause(); if (cause instanceof RepositoryException) { throw new RepositoryException(cause); } else { throw new RuntimeException(cause); } } }
[ "public", "void", "setState", "(", "final", "int", "state", ")", "throws", "RepositoryException", "{", "// Need privileges to manage repository.", "SecurityManager", "security", "=", "System", ".", "getSecurityManager", "(", ")", ";", "if", "(", "security", "!=", "n...
Set new workspace state. @param state @throws RepositoryException
[ "Set", "new", "workspace", "state", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java#L164-L209
135,673
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
WorkspaceContainerFacade.suspend
private void suspend() throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer(); if (workspaceResumer != null) { workspaceResumer.onSuspend(); } List<Suspendable> components = getComponentInstancesOfType(Suspendable.class); Comparator<Suspendable> c = new Comparator<Suspendable>() { public int compare(Suspendable s1, Suspendable s2) { return s2.getPriority() - s1.getPriority(); }; }; Collections.sort(components, c); for (Suspendable component : components) { try { if (!component.isSuspended()) { component.suspend(); } } catch (SuspendException e) { throw new RepositoryException("Can't suspend component", e); } } }
java
private void suspend() throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer(); if (workspaceResumer != null) { workspaceResumer.onSuspend(); } List<Suspendable> components = getComponentInstancesOfType(Suspendable.class); Comparator<Suspendable> c = new Comparator<Suspendable>() { public int compare(Suspendable s1, Suspendable s2) { return s2.getPriority() - s1.getPriority(); }; }; Collections.sort(components, c); for (Suspendable component : components) { try { if (!component.isSuspended()) { component.suspend(); } } catch (SuspendException e) { throw new RepositoryException("Can't suspend component", e); } } }
[ "private", "void", "suspend", "(", ")", "throws", "RepositoryException", "{", "WorkspaceResumer", "workspaceResumer", "=", "getWorkspaceResumer", "(", ")", ";", "if", "(", "workspaceResumer", "!=", "null", ")", "{", "workspaceResumer", ".", "onSuspend", "(", ")", ...
Suspend all components in workspace. @throws RepositoryException
[ "Suspend", "all", "components", "in", "workspace", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java#L216-L249
135,674
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java
WorkspaceContainerFacade.resume
private void resume() throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer(); if (workspaceResumer != null) { workspaceResumer.onResume(); } // components should be resumed in reverse order List<Suspendable> components = getComponentInstancesOfType(Suspendable.class); Comparator<Suspendable> c = new Comparator<Suspendable>() { public int compare(Suspendable s1, Suspendable s2) { return s1.getPriority() - s2.getPriority(); }; }; Collections.sort(components, c); for (Suspendable component : components) { try { if (component.isSuspended()) { component.resume(); } } catch (ResumeException e) { throw new RepositoryException("Can't set component online", e); } } }
java
private void resume() throws RepositoryException { WorkspaceResumer workspaceResumer = getWorkspaceResumer(); if (workspaceResumer != null) { workspaceResumer.onResume(); } // components should be resumed in reverse order List<Suspendable> components = getComponentInstancesOfType(Suspendable.class); Comparator<Suspendable> c = new Comparator<Suspendable>() { public int compare(Suspendable s1, Suspendable s2) { return s1.getPriority() - s2.getPriority(); }; }; Collections.sort(components, c); for (Suspendable component : components) { try { if (component.isSuspended()) { component.resume(); } } catch (ResumeException e) { throw new RepositoryException("Can't set component online", e); } } }
[ "private", "void", "resume", "(", ")", "throws", "RepositoryException", "{", "WorkspaceResumer", "workspaceResumer", "=", "getWorkspaceResumer", "(", ")", ";", "if", "(", "workspaceResumer", "!=", "null", ")", "{", "workspaceResumer", ".", "onResume", "(", ")", ...
Set all components online. @throws RepositoryException
[ "Set", "all", "components", "online", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/core/WorkspaceContainerFacade.java#L256-L289
135,675
exoplatform/jcr
exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java
PropFindCommand.propertyNames
private Set<QName> propertyNames(HierarchicalProperty body) { HashSet<QName> names = new HashSet<QName>(); HierarchicalProperty propBody = body.getChild(PropertyConstants.DAV_ALLPROP_INCLUDE); if (propBody != null) { names.add(PropertyConstants.DAV_ALLPROP_INCLUDE); } else { propBody = body.getChild(0); } List<HierarchicalProperty> properties = propBody.getChildren(); Iterator<HierarchicalProperty> propIter = properties.iterator(); while (propIter.hasNext()) { HierarchicalProperty property = propIter.next(); names.add(property.getName()); } return names; }
java
private Set<QName> propertyNames(HierarchicalProperty body) { HashSet<QName> names = new HashSet<QName>(); HierarchicalProperty propBody = body.getChild(PropertyConstants.DAV_ALLPROP_INCLUDE); if (propBody != null) { names.add(PropertyConstants.DAV_ALLPROP_INCLUDE); } else { propBody = body.getChild(0); } List<HierarchicalProperty> properties = propBody.getChildren(); Iterator<HierarchicalProperty> propIter = properties.iterator(); while (propIter.hasNext()) { HierarchicalProperty property = propIter.next(); names.add(property.getName()); } return names; }
[ "private", "Set", "<", "QName", ">", "propertyNames", "(", "HierarchicalProperty", "body", ")", "{", "HashSet", "<", "QName", ">", "names", "=", "new", "HashSet", "<", "QName", ">", "(", ")", ";", "HierarchicalProperty", "propBody", "=", "body", ".", "getC...
Returns the set of properties names. @param body request body. @return the set of properties names.
[ "Returns", "the", "set", "of", "properties", "names", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.webdav/src/main/java/org/exoplatform/services/jcr/webdav/command/PropFindCommand.java#L187-L211
135,676
exoplatform/jcr
exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/AbstractFCKConnector.java
AbstractFCKConnector.getCurrentFolderPath
protected String getCurrentFolderPath(GenericWebAppContext context) { // To limit browsing set Servlet init param "digitalAssetsPath" with desired JCR path String rootFolderStr = (String)context.get("org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsPath"); if (rootFolderStr == null) rootFolderStr = "/"; // set current folder String currentFolderStr = (String)context.get("CurrentFolder"); if (currentFolderStr == null) currentFolderStr = ""; else if (currentFolderStr.length() < rootFolderStr.length()) currentFolderStr = rootFolderStr; return currentFolderStr; }
java
protected String getCurrentFolderPath(GenericWebAppContext context) { // To limit browsing set Servlet init param "digitalAssetsPath" with desired JCR path String rootFolderStr = (String)context.get("org.exoplatform.frameworks.jcr.command.web.fckeditor.digitalAssetsPath"); if (rootFolderStr == null) rootFolderStr = "/"; // set current folder String currentFolderStr = (String)context.get("CurrentFolder"); if (currentFolderStr == null) currentFolderStr = ""; else if (currentFolderStr.length() < rootFolderStr.length()) currentFolderStr = rootFolderStr; return currentFolderStr; }
[ "protected", "String", "getCurrentFolderPath", "(", "GenericWebAppContext", "context", ")", "{", "// To limit browsing set Servlet init param \"digitalAssetsPath\" with desired JCR path", "String", "rootFolderStr", "=", "(", "String", ")", "context", ".", "get", "(", "\"org.exo...
Return FCKeditor current folder path. @param context @return String path
[ "Return", "FCKeditor", "current", "folder", "path", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/AbstractFCKConnector.java#L42-L59
135,677
exoplatform/jcr
exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/AbstractFCKConnector.java
AbstractFCKConnector.makeRESTPath
protected String makeRESTPath(String repoName, String workspace, String resource) { final StringBuilder sb = new StringBuilder(512); ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent(); if (container instanceof PortalContainer) { PortalContainer pContainer = (PortalContainer)container; sb.append('/').append(pContainer.getRestContextName()).append('/'); } else { sb.append('/').append(PortalContainer.DEFAULT_REST_CONTEXT_NAME).append('/'); } return sb.append("jcr/").append(repoName).append('/').append(workspace).append(resource).toString(); }
java
protected String makeRESTPath(String repoName, String workspace, String resource) { final StringBuilder sb = new StringBuilder(512); ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent(); if (container instanceof PortalContainer) { PortalContainer pContainer = (PortalContainer)container; sb.append('/').append(pContainer.getRestContextName()).append('/'); } else { sb.append('/').append(PortalContainer.DEFAULT_REST_CONTEXT_NAME).append('/'); } return sb.append("jcr/").append(repoName).append('/').append(workspace).append(resource).toString(); }
[ "protected", "String", "makeRESTPath", "(", "String", "repoName", ",", "String", "workspace", ",", "String", "resource", ")", "{", "final", "StringBuilder", "sb", "=", "new", "StringBuilder", "(", "512", ")", ";", "ExoContainer", "container", "=", "ExoContainerC...
Compile REST path of the given resource. @param workspace @param resource , we assume that path starts with '/' @return
[ "Compile", "REST", "path", "of", "the", "given", "resource", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.framework.command/src/main/java/org/exoplatform/frameworks/jcr/command/web/fckeditor/AbstractFCKConnector.java#L69-L83
135,678
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/CacheableSessionLockManager.java
CacheableSessionLockManager.getLockToken
protected String getLockToken(String tokenHash) { for (String token : tokens.keySet()) { if (tokens.get(token).equals(tokenHash)) { return token; } } return null; }
java
protected String getLockToken(String tokenHash) { for (String token : tokens.keySet()) { if (tokens.get(token).equals(tokenHash)) { return token; } } return null; }
[ "protected", "String", "getLockToken", "(", "String", "tokenHash", ")", "{", "for", "(", "String", "token", ":", "tokens", ".", "keySet", "(", ")", ")", "{", "if", "(", "tokens", ".", "get", "(", "token", ")", ".", "equals", "(", "tokenHash", ")", ")...
Returns real token, if session has it. @param tokenHash - token hash string @return lock token string
[ "Returns", "real", "token", "if", "session", "has", "it", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/CacheableSessionLockManager.java#L309-L319
135,679
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/CacheableSessionLockManager.java
CacheableSessionLockManager.getPendingLock
public LockData getPendingLock(String nodeId) { if (pendingLocks.contains(nodeId)) { return lockedNodes.get(nodeId); } else { return null; } }
java
public LockData getPendingLock(String nodeId) { if (pendingLocks.contains(nodeId)) { return lockedNodes.get(nodeId); } else { return null; } }
[ "public", "LockData", "getPendingLock", "(", "String", "nodeId", ")", "{", "if", "(", "pendingLocks", ".", "contains", "(", "nodeId", ")", ")", "{", "return", "lockedNodes", ".", "get", "(", "nodeId", ")", ";", "}", "else", "{", "return", "null", ";", ...
Return pending lock. @param nodeId - ID of locked node @return pending lock or null
[ "Return", "pending", "lock", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/core/lock/cacheable/CacheableSessionLockManager.java#L327-L337
135,680
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.getNodeIndex
public int getNodeIndex(NodeData parentData, InternalQName name, String skipIdentifier) throws PathNotFoundException, IllegalPathException, RepositoryException { if (name instanceof QPathEntry) { name = new InternalQName(name.getNamespace(), name.getName()); } int newIndex = 1; NodeDefinitionData nodedef = nodeTypeDataManager.getChildNodeDefinition(name, parentData.getPrimaryTypeName(), parentData .getMixinTypeNames()); List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, skipIdentifier); List<ItemState> transientDeletedChilds; if (nodedef.isAllowsSameNameSiblings()) { transientDeletedChilds = getItemStatesList(parentData, name, ItemState.DELETED, null); } else { transientDeletedChilds = getItemStatesList(parentData, new QPathEntry(name, 0), ItemState.DELETED, null); ItemData sameNameNode = null; try { sameNameNode = dataConsumer.getItemData(parentData, new QPathEntry(name, 0), ItemType.NODE, false); } catch (PathNotFoundException e) { // Ok no same name node; return newIndex; } if (((sameNameNode != null) || (transientAddChilds.size() > 0))) { if ((sameNameNode != null) && (transientDeletedChilds.size() < 1)) { throw new ItemExistsException("The node already exists in " + sameNameNode.getQPath().getAsString() + " and same name sibling is not allowed "); } else if (transientAddChilds.size() > 0) { throw new ItemExistsException("The node already exists in add state " + " and same name sibling is not allowed "); } } } newIndex += transientAddChilds.size(); List<NodeData> existedChilds = dataConsumer.getChildNodesData(parentData); // Calculate SNS index for dest root main: for (int n = 0, l = existedChilds.size(); n < l; n++) { NodeData child = existedChilds.get(n); if (child.getQPath().getName().equals(name)) { // skip deleted items if (!transientDeletedChilds.isEmpty()) { for (int i = 0, length = transientDeletedChilds.size(); i < length; i++) { ItemState state = transientDeletedChilds.get(i); if (state.getData().equals(child)) { transientDeletedChilds.remove(i); continue main; } } } newIndex++; // next sibling index } } // searching return newIndex; }
java
public int getNodeIndex(NodeData parentData, InternalQName name, String skipIdentifier) throws PathNotFoundException, IllegalPathException, RepositoryException { if (name instanceof QPathEntry) { name = new InternalQName(name.getNamespace(), name.getName()); } int newIndex = 1; NodeDefinitionData nodedef = nodeTypeDataManager.getChildNodeDefinition(name, parentData.getPrimaryTypeName(), parentData .getMixinTypeNames()); List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, skipIdentifier); List<ItemState> transientDeletedChilds; if (nodedef.isAllowsSameNameSiblings()) { transientDeletedChilds = getItemStatesList(parentData, name, ItemState.DELETED, null); } else { transientDeletedChilds = getItemStatesList(parentData, new QPathEntry(name, 0), ItemState.DELETED, null); ItemData sameNameNode = null; try { sameNameNode = dataConsumer.getItemData(parentData, new QPathEntry(name, 0), ItemType.NODE, false); } catch (PathNotFoundException e) { // Ok no same name node; return newIndex; } if (((sameNameNode != null) || (transientAddChilds.size() > 0))) { if ((sameNameNode != null) && (transientDeletedChilds.size() < 1)) { throw new ItemExistsException("The node already exists in " + sameNameNode.getQPath().getAsString() + " and same name sibling is not allowed "); } else if (transientAddChilds.size() > 0) { throw new ItemExistsException("The node already exists in add state " + " and same name sibling is not allowed "); } } } newIndex += transientAddChilds.size(); List<NodeData> existedChilds = dataConsumer.getChildNodesData(parentData); // Calculate SNS index for dest root main: for (int n = 0, l = existedChilds.size(); n < l; n++) { NodeData child = existedChilds.get(n); if (child.getQPath().getName().equals(name)) { // skip deleted items if (!transientDeletedChilds.isEmpty()) { for (int i = 0, length = transientDeletedChilds.size(); i < length; i++) { ItemState state = transientDeletedChilds.get(i); if (state.getData().equals(child)) { transientDeletedChilds.remove(i); continue main; } } } newIndex++; // next sibling index } } // searching return newIndex; }
[ "public", "int", "getNodeIndex", "(", "NodeData", "parentData", ",", "InternalQName", "name", ",", "String", "skipIdentifier", ")", "throws", "PathNotFoundException", ",", "IllegalPathException", ",", "RepositoryException", "{", "if", "(", "name", "instanceof", "QPath...
Return new node index. @param parentData @param name @param skipIdentifier @return @throws PathNotFoundException @throws IllegalPathException @throws RepositoryException
[ "Return", "new", "node", "index", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L218-L297
135,681
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.setAncestorToSave
public void setAncestorToSave(QPath newAncestorToSave) { if (!ancestorToSave.equals(newAncestorToSave)) { isNeedReloadAncestorToSave = true; } this.ancestorToSave = newAncestorToSave; }
java
public void setAncestorToSave(QPath newAncestorToSave) { if (!ancestorToSave.equals(newAncestorToSave)) { isNeedReloadAncestorToSave = true; } this.ancestorToSave = newAncestorToSave; }
[ "public", "void", "setAncestorToSave", "(", "QPath", "newAncestorToSave", ")", "{", "if", "(", "!", "ancestorToSave", ".", "equals", "(", "newAncestorToSave", ")", ")", "{", "isNeedReloadAncestorToSave", "=", "true", ";", "}", "this", ".", "ancestorToSave", "=",...
Set new ancestorToSave. @param newAncestorToSave
[ "Set", "new", "ancestorToSave", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L338-L345
135,682
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.createVersionHistory
protected void createVersionHistory(ImportNodeData nodeData) throws RepositoryException { // Generate new VersionHistoryIdentifier and BaseVersionIdentifier // if uuid changed after UC boolean newVersionHistory = nodeData.isNewIdentifer() || !nodeData.isContainsVersionhistory(); if (newVersionHistory) { nodeData.setVersionHistoryIdentifier(IdGenerator.generate()); nodeData.setBaseVersionIdentifier(IdGenerator.generate()); } PlainChangesLogImpl changes = new PlainChangesLogImpl(); // using VH helper as for one new VH, all changes in changes log new VersionHistoryDataHelper(nodeData, changes, dataConsumer, nodeTypeDataManager, nodeData.getVersionHistoryIdentifier(), nodeData.getBaseVersionIdentifier()); if (!newVersionHistory) { for (ItemState state : changes.getAllStates()) { if (!state.getData().getQPath().isDescendantOf(Constants.JCR_SYSTEM_PATH)) { changesLog.add(state); } } } else { changesLog.addAll(changes.getAllStates()); } }
java
protected void createVersionHistory(ImportNodeData nodeData) throws RepositoryException { // Generate new VersionHistoryIdentifier and BaseVersionIdentifier // if uuid changed after UC boolean newVersionHistory = nodeData.isNewIdentifer() || !nodeData.isContainsVersionhistory(); if (newVersionHistory) { nodeData.setVersionHistoryIdentifier(IdGenerator.generate()); nodeData.setBaseVersionIdentifier(IdGenerator.generate()); } PlainChangesLogImpl changes = new PlainChangesLogImpl(); // using VH helper as for one new VH, all changes in changes log new VersionHistoryDataHelper(nodeData, changes, dataConsumer, nodeTypeDataManager, nodeData.getVersionHistoryIdentifier(), nodeData.getBaseVersionIdentifier()); if (!newVersionHistory) { for (ItemState state : changes.getAllStates()) { if (!state.getData().getQPath().isDescendantOf(Constants.JCR_SYSTEM_PATH)) { changesLog.add(state); } } } else { changesLog.addAll(changes.getAllStates()); } }
[ "protected", "void", "createVersionHistory", "(", "ImportNodeData", "nodeData", ")", "throws", "RepositoryException", "{", "// Generate new VersionHistoryIdentifier and BaseVersionIdentifier", "// if uuid changed after UC", "boolean", "newVersionHistory", "=", "nodeData", ".", "isN...
Create new version history. @param nodeData @throws RepositoryException
[ "Create", "new", "version", "history", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L353-L383
135,683
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.checkReferenceable
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException { // if node is in version storage - do not assign new id from jcr:uuid // property if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth() && currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3] .equals(Constants.JCR_FROZENNODE) && currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)) { return; } String identifier = validateUuidCollision(olUuid); if (identifier != null) { reloadChangesInfoAfterUC(currentNodeInfo, identifier); } else { currentNodeInfo.setIsNewIdentifer(true); } if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) { NodeData parentNode = getParent(); currentNodeInfo.setParentIdentifer(parentNode.getIdentifier()); if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary()) { // remove the temporary parent tree.pop(); } } }
java
protected void checkReferenceable(ImportNodeData currentNodeInfo, String olUuid) throws RepositoryException { // if node is in version storage - do not assign new id from jcr:uuid // property if (Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3 <= currentNodeInfo.getQPath().getDepth() && currentNodeInfo.getQPath().getEntries()[Constants.JCR_VERSION_STORAGE_PATH.getDepth() + 3] .equals(Constants.JCR_FROZENNODE) && currentNodeInfo.getQPath().isDescendantOf(Constants.JCR_VERSION_STORAGE_PATH)) { return; } String identifier = validateUuidCollision(olUuid); if (identifier != null) { reloadChangesInfoAfterUC(currentNodeInfo, identifier); } else { currentNodeInfo.setIsNewIdentifer(true); } if (uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING) { NodeData parentNode = getParent(); currentNodeInfo.setParentIdentifer(parentNode.getIdentifier()); if (parentNode instanceof ImportNodeData && ((ImportNodeData)parentNode).isTemporary()) { // remove the temporary parent tree.pop(); } } }
[ "protected", "void", "checkReferenceable", "(", "ImportNodeData", "currentNodeInfo", ",", "String", "olUuid", ")", "throws", "RepositoryException", "{", "// if node is in version storage - do not assign new id from jcr:uuid", "// property", "if", "(", "Constants", ".", "JCR_VER...
Check uuid collision. If collision happen reload path information. @param currentNodeInfo @param olUuid @throws RepositoryException
[ "Check", "uuid", "collision", ".", "If", "collision", "happen", "reload", "path", "information", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L400-L432
135,684
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.getItemStatesList
private List<ItemState> getItemStatesList(NodeData parentData, InternalQName name, int state, String skipIdentifier) { List<ItemState> states = new ArrayList<ItemState>(); for (ItemState itemState : changesLog.getAllStates()) { ItemData stateData = itemState.getData(); if (isParent(stateData, parentData) && stateData.getQPath().getName().equals(name)) { if ((state != 0) && (state != itemState.getState()) || stateData.getIdentifier().equals(skipIdentifier)) { continue; } states.add(itemState); } } return states; }
java
private List<ItemState> getItemStatesList(NodeData parentData, InternalQName name, int state, String skipIdentifier) { List<ItemState> states = new ArrayList<ItemState>(); for (ItemState itemState : changesLog.getAllStates()) { ItemData stateData = itemState.getData(); if (isParent(stateData, parentData) && stateData.getQPath().getName().equals(name)) { if ((state != 0) && (state != itemState.getState()) || stateData.getIdentifier().equals(skipIdentifier)) { continue; } states.add(itemState); } } return states; }
[ "private", "List", "<", "ItemState", ">", "getItemStatesList", "(", "NodeData", "parentData", ",", "InternalQName", "name", ",", "int", "state", ",", "String", "skipIdentifier", ")", "{", "List", "<", "ItemState", ">", "states", "=", "new", "ArrayList", "<", ...
Return list of changes for item. @param parentData - parent item @param name - item name @param state - state @param skipIdentifier - skipped identifier. @return
[ "Return", "list", "of", "changes", "for", "item", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L623-L640
135,685
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.getLastItemState
protected ItemState getLastItemState(String identifer) { List<ItemState> allStates = changesLog.getAllStates(); for (int i = allStates.size() - 1; i >= 0; i--) { ItemState state = allStates.get(i); if (state.getData().getIdentifier().equals(identifer)) return state; } return null; }
java
protected ItemState getLastItemState(String identifer) { List<ItemState> allStates = changesLog.getAllStates(); for (int i = allStates.size() - 1; i >= 0; i--) { ItemState state = allStates.get(i); if (state.getData().getIdentifier().equals(identifer)) return state; } return null; }
[ "protected", "ItemState", "getLastItemState", "(", "String", "identifer", ")", "{", "List", "<", "ItemState", ">", "allStates", "=", "changesLog", ".", "getAllStates", "(", ")", ";", "for", "(", "int", "i", "=", "allStates", ".", "size", "(", ")", "-", "...
Return last item state in changes log. If no state exist return null. @param identifer @return
[ "Return", "last", "item", "state", "in", "changes", "log", ".", "If", "no", "state", "exist", "return", "null", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L648-L658
135,686
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.removeExisted
private void removeExisted(NodeData sameUuidItem) throws RepositoryException, ConstraintViolationException, PathNotFoundException { if (!nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, sameUuidItem.getPrimaryTypeName(), sameUuidItem .getMixinTypeNames())) { throw new RepositoryException("An incoming referenceable node has the same " + " UUID as a identifier of non mix:referenceable" + " node already existing in the workspace!"); } // If an incoming referenceable node has the same UUID as a node // already existing in the workspace then the already existing // node (and its subtree) is removed from wherever it may be in // the workspace before the incoming node is added. Note that this // can result in nodes disappearing from locations in the // workspace that are remote from the location to which the // incoming subtree is being written. // parentNodeData = (NodeData) sameUuidItem.getParent().getData(); QPath sameUuidPath = sameUuidItem.getQPath(); if (ancestorToSave.isDescendantOf(sameUuidPath) || ancestorToSave.equals(sameUuidPath)) { throw new ConstraintViolationException("The imported document contains a element" + " with jcr:uuid attribute the same as the parent of the import target."); } setAncestorToSave(QPath.getCommonAncestorPath(ancestorToSave, sameUuidPath)); ItemDataRemoveVisitor visitor = new ItemDataRemoveVisitor(dataConsumer, getAncestorToSave(), nodeTypeDataManager, accessManager, userState); sameUuidItem.accept(visitor); changesLog.addAll(visitor.getRemovedStates()); // Refresh the indexes if needed boolean reloadSNS = uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING; if (reloadSNS) { NodeData parentData = (NodeData)dataConsumer.getItemData(sameUuidItem.getParentIdentifier()); ItemState lastState = getLastItemState(sameUuidItem.getParentIdentifier()); if (sameUuidItem != null && (lastState == null || !lastState.isDeleted())) { InternalQName name = new InternalQName(sameUuidItem.getQPath().getName().getNamespace(), sameUuidItem.getQPath().getName() .getName()); List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, null); if (transientAddChilds.isEmpty()) return; List<ItemState> statesToReLoad = new LinkedList<ItemState>(); for (int i = 0, length = transientAddChilds.size(); i < length; i++) { ItemState state = transientAddChilds.get(i); if (sameUuidItem.getQPath().getIndex() < state.getData().getQPath().getIndex() && state.getData() instanceof ImportNodeData) { statesToReLoad.add(state); } } if (statesToReLoad.isEmpty()) return; for (ItemState state : statesToReLoad) { ImportNodeData node = (ImportNodeData)state.getData(); reloadChangesInfoAfterUC(parentData, node, node.getIdentifier()); } } } }
java
private void removeExisted(NodeData sameUuidItem) throws RepositoryException, ConstraintViolationException, PathNotFoundException { if (!nodeTypeDataManager.isNodeType(Constants.MIX_REFERENCEABLE, sameUuidItem.getPrimaryTypeName(), sameUuidItem .getMixinTypeNames())) { throw new RepositoryException("An incoming referenceable node has the same " + " UUID as a identifier of non mix:referenceable" + " node already existing in the workspace!"); } // If an incoming referenceable node has the same UUID as a node // already existing in the workspace then the already existing // node (and its subtree) is removed from wherever it may be in // the workspace before the incoming node is added. Note that this // can result in nodes disappearing from locations in the // workspace that are remote from the location to which the // incoming subtree is being written. // parentNodeData = (NodeData) sameUuidItem.getParent().getData(); QPath sameUuidPath = sameUuidItem.getQPath(); if (ancestorToSave.isDescendantOf(sameUuidPath) || ancestorToSave.equals(sameUuidPath)) { throw new ConstraintViolationException("The imported document contains a element" + " with jcr:uuid attribute the same as the parent of the import target."); } setAncestorToSave(QPath.getCommonAncestorPath(ancestorToSave, sameUuidPath)); ItemDataRemoveVisitor visitor = new ItemDataRemoveVisitor(dataConsumer, getAncestorToSave(), nodeTypeDataManager, accessManager, userState); sameUuidItem.accept(visitor); changesLog.addAll(visitor.getRemovedStates()); // Refresh the indexes if needed boolean reloadSNS = uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING || uuidBehavior == ImportUUIDBehavior.IMPORT_UUID_COLLISION_REPLACE_EXISTING; if (reloadSNS) { NodeData parentData = (NodeData)dataConsumer.getItemData(sameUuidItem.getParentIdentifier()); ItemState lastState = getLastItemState(sameUuidItem.getParentIdentifier()); if (sameUuidItem != null && (lastState == null || !lastState.isDeleted())) { InternalQName name = new InternalQName(sameUuidItem.getQPath().getName().getNamespace(), sameUuidItem.getQPath().getName() .getName()); List<ItemState> transientAddChilds = getItemStatesList(parentData, name, ItemState.ADDED, null); if (transientAddChilds.isEmpty()) return; List<ItemState> statesToReLoad = new LinkedList<ItemState>(); for (int i = 0, length = transientAddChilds.size(); i < length; i++) { ItemState state = transientAddChilds.get(i); if (sameUuidItem.getQPath().getIndex() < state.getData().getQPath().getIndex() && state.getData() instanceof ImportNodeData) { statesToReLoad.add(state); } } if (statesToReLoad.isEmpty()) return; for (ItemState state : statesToReLoad) { ImportNodeData node = (ImportNodeData)state.getData(); reloadChangesInfoAfterUC(parentData, node, node.getIdentifier()); } } } }
[ "private", "void", "removeExisted", "(", "NodeData", "sameUuidItem", ")", "throws", "RepositoryException", ",", "ConstraintViolationException", ",", "PathNotFoundException", "{", "if", "(", "!", "nodeTypeDataManager", ".", "isNodeType", "(", "Constants", ".", "MIX_REFER...
Remove existed item. @param sameUuidItem @throws RepositoryException @throws ConstraintViolationException @throws PathNotFoundException
[ "Remove", "existed", "item", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L686-L757
135,687
exoplatform/jcr
exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java
BaseXmlImporter.removeVersionHistory
private void removeVersionHistory(NodeData mixVersionableNode) throws RepositoryException, ConstraintViolationException, VersionException { try { PropertyData vhpd = (PropertyData)dataConsumer.getItemData(mixVersionableNode, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1), ItemType.PROPERTY); String vhID = ValueDataUtil.getString(vhpd.getValues().get(0)); VersionHistoryRemover historyRemover = new VersionHistoryRemover(vhID, dataConsumer, nodeTypeDataManager, repository, currentWorkspaceName, null, ancestorToSave, changesLog, accessManager, userState); historyRemover.remove(); } catch (IllegalStateException e) { throw new RepositoryException(e); } }
java
private void removeVersionHistory(NodeData mixVersionableNode) throws RepositoryException, ConstraintViolationException, VersionException { try { PropertyData vhpd = (PropertyData)dataConsumer.getItemData(mixVersionableNode, new QPathEntry(Constants.JCR_VERSIONHISTORY, 1), ItemType.PROPERTY); String vhID = ValueDataUtil.getString(vhpd.getValues().get(0)); VersionHistoryRemover historyRemover = new VersionHistoryRemover(vhID, dataConsumer, nodeTypeDataManager, repository, currentWorkspaceName, null, ancestorToSave, changesLog, accessManager, userState); historyRemover.remove(); } catch (IllegalStateException e) { throw new RepositoryException(e); } }
[ "private", "void", "removeVersionHistory", "(", "NodeData", "mixVersionableNode", ")", "throws", "RepositoryException", ",", "ConstraintViolationException", ",", "VersionException", "{", "try", "{", "PropertyData", "vhpd", "=", "(", "PropertyData", ")", "dataConsumer", ...
Remove version history of versionable node. @param mixVersionableNode - node @throws RepositoryException @throws ConstraintViolationException @throws VersionException
[ "Remove", "version", "history", "of", "versionable", "node", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.core/src/main/java/org/exoplatform/services/jcr/impl/xml/importing/BaseXmlImporter.java#L767-L786
135,688
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/AbstractBackupJob.java
AbstractBackupJob.notifyListeners
protected void notifyListeners() { synchronized (listeners) { Thread notifier = new NotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this); notifier.start(); } }
java
protected void notifyListeners() { synchronized (listeners) { Thread notifier = new NotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this); notifier.start(); } }
[ "protected", "void", "notifyListeners", "(", ")", "{", "synchronized", "(", "listeners", ")", "{", "Thread", "notifier", "=", "new", "NotifyThread", "(", "listeners", ".", "toArray", "(", "new", "BackupJobListener", "[", "listeners", ".", "size", "(", ")", "...
Notify all listeners about the job state changed
[ "Notify", "all", "listeners", "about", "the", "job", "state", "changed" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/AbstractBackupJob.java#L163-L170
135,689
exoplatform/jcr
exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/AbstractBackupJob.java
AbstractBackupJob.notifyError
protected void notifyError(String message, Throwable error) { synchronized (listeners) { Thread notifier = new ErrorNotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this, message, error); notifier.start(); } }
java
protected void notifyError(String message, Throwable error) { synchronized (listeners) { Thread notifier = new ErrorNotifyThread(listeners.toArray(new BackupJobListener[listeners.size()]), this, message, error); notifier.start(); } }
[ "protected", "void", "notifyError", "(", "String", "message", ",", "Throwable", "error", ")", "{", "synchronized", "(", "listeners", ")", "{", "Thread", "notifier", "=", "new", "ErrorNotifyThread", "(", "listeners", ".", "toArray", "(", "new", "BackupJobListener...
Notify all listeners about an error @param error - Throwable instance
[ "Notify", "all", "listeners", "about", "an", "error" ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.component.ext/src/main/java/org/exoplatform/services/jcr/ext/backup/impl/AbstractBackupJob.java#L178-L186
135,690
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.readProfile
private UserProfile readProfile(Session session, String userName) throws Exception { Node profileNode; try { profileNode = utils.getProfileNode(session, userName); } catch (PathNotFoundException e) { return null; } return readProfile(userName, profileNode); }
java
private UserProfile readProfile(Session session, String userName) throws Exception { Node profileNode; try { profileNode = utils.getProfileNode(session, userName); } catch (PathNotFoundException e) { return null; } return readProfile(userName, profileNode); }
[ "private", "UserProfile", "readProfile", "(", "Session", "session", ",", "String", "userName", ")", "throws", "Exception", "{", "Node", "profileNode", ";", "try", "{", "profileNode", "=", "utils", ".", "getProfileNode", "(", "session", ",", "userName", ")", ";...
Reads user profile from storage based on user name.
[ "Reads", "user", "profile", "from", "storage", "based", "on", "user", "name", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L118-L131
135,691
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.removeUserProfile
private UserProfile removeUserProfile(Session session, String userName, boolean broadcast) throws Exception { Node profileNode; try { profileNode = utils.getProfileNode(session, userName); } catch (PathNotFoundException e) { return null; } UserProfile profile = readProfile(userName, profileNode); if (broadcast) { preDelete(profile, broadcast); } profileNode.remove(); session.save(); removeFromCache(profile); if (broadcast) { postDelete(profile); } return profile; }
java
private UserProfile removeUserProfile(Session session, String userName, boolean broadcast) throws Exception { Node profileNode; try { profileNode = utils.getProfileNode(session, userName); } catch (PathNotFoundException e) { return null; } UserProfile profile = readProfile(userName, profileNode); if (broadcast) { preDelete(profile, broadcast); } profileNode.remove(); session.save(); removeFromCache(profile); if (broadcast) { postDelete(profile); } return profile; }
[ "private", "UserProfile", "removeUserProfile", "(", "Session", "session", ",", "String", "userName", ",", "boolean", "broadcast", ")", "throws", "Exception", "{", "Node", "profileNode", ";", "try", "{", "profileNode", "=", "utils", ".", "getProfileNode", "(", "s...
Remove user profile from storage.
[ "Remove", "user", "profile", "from", "storage", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L194-L224
135,692
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.migrateProfile
void migrateProfile(Node oldUserNode) throws Exception { UserProfile userProfile = new UserProfileImpl(oldUserNode.getName()); Node attrNode = null; try { attrNode = oldUserNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE + "/" + MigrationTool.JOS_ATTRIBUTES); } catch (PathNotFoundException e) { return; } PropertyIterator props = attrNode.getProperties(); while (props.hasNext()) { Property prop = props.nextProperty(); // ignore system properties if (!(prop.getName()).startsWith("jcr:") && !(prop.getName()).startsWith("exo:") && !(prop.getName()).startsWith("jos:")) { userProfile.setAttribute(prop.getName(), prop.getString()); } } if (findUserProfileByName(userProfile.getUserName()) != null) { removeUserProfile(userProfile.getUserName(), false); } saveUserProfile(userProfile, false); }
java
void migrateProfile(Node oldUserNode) throws Exception { UserProfile userProfile = new UserProfileImpl(oldUserNode.getName()); Node attrNode = null; try { attrNode = oldUserNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE + "/" + MigrationTool.JOS_ATTRIBUTES); } catch (PathNotFoundException e) { return; } PropertyIterator props = attrNode.getProperties(); while (props.hasNext()) { Property prop = props.nextProperty(); // ignore system properties if (!(prop.getName()).startsWith("jcr:") && !(prop.getName()).startsWith("exo:") && !(prop.getName()).startsWith("jos:")) { userProfile.setAttribute(prop.getName(), prop.getString()); } } if (findUserProfileByName(userProfile.getUserName()) != null) { removeUserProfile(userProfile.getUserName(), false); } saveUserProfile(userProfile, false); }
[ "void", "migrateProfile", "(", "Node", "oldUserNode", ")", "throws", "Exception", "{", "UserProfile", "userProfile", "=", "new", "UserProfileImpl", "(", "oldUserNode", ".", "getName", "(", ")", ")", ";", "Node", "attrNode", "=", "null", ";", "try", "{", "att...
Migrates user profile from old storage into new. @param oldUserNode the node where user properties are stored (from old structure)
[ "Migrates", "user", "profile", "from", "old", "storage", "into", "new", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L247-L280
135,693
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.saveUserProfile
private void saveUserProfile(Session session, UserProfile profile, boolean broadcast) throws RepositoryException, Exception { Node userNode = utils.getUserNode(session, profile.getUserName()); Node profileNode = getProfileNode(userNode); boolean isNewProfile = profileNode.isNew(); if (broadcast) { preSave(profile, isNewProfile); } writeProfile(profile, profileNode); session.save(); putInCache(profile); if (broadcast) { postSave(profile, isNewProfile); } }
java
private void saveUserProfile(Session session, UserProfile profile, boolean broadcast) throws RepositoryException, Exception { Node userNode = utils.getUserNode(session, profile.getUserName()); Node profileNode = getProfileNode(userNode); boolean isNewProfile = profileNode.isNew(); if (broadcast) { preSave(profile, isNewProfile); } writeProfile(profile, profileNode); session.save(); putInCache(profile); if (broadcast) { postSave(profile, isNewProfile); } }
[ "private", "void", "saveUserProfile", "(", "Session", "session", ",", "UserProfile", "profile", ",", "boolean", "broadcast", ")", "throws", "RepositoryException", ",", "Exception", "{", "Node", "userNode", "=", "utils", ".", "getUserNode", "(", "session", ",", "...
Persist user profile to the storage.
[ "Persist", "user", "profile", "to", "the", "storage", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L285-L307
135,694
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.getProfileNode
private Node getProfileNode(Node userNode) throws RepositoryException { try { return userNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE); } catch (PathNotFoundException e) { return userNode.addNode(JCROrganizationServiceImpl.JOS_PROFILE); } }
java
private Node getProfileNode(Node userNode) throws RepositoryException { try { return userNode.getNode(JCROrganizationServiceImpl.JOS_PROFILE); } catch (PathNotFoundException e) { return userNode.addNode(JCROrganizationServiceImpl.JOS_PROFILE); } }
[ "private", "Node", "getProfileNode", "(", "Node", "userNode", ")", "throws", "RepositoryException", "{", "try", "{", "return", "userNode", ".", "getNode", "(", "JCROrganizationServiceImpl", ".", "JOS_PROFILE", ")", ";", "}", "catch", "(", "PathNotFoundException", ...
Create new profile node.
[ "Create", "new", "profile", "node", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L312-L322
135,695
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.readProfile
private UserProfile readProfile(String userName, Node profileNode) throws RepositoryException { UserProfile profile = createUserProfileInstance(userName); PropertyIterator attributes = profileNode.getProperties(); while (attributes.hasNext()) { Property prop = attributes.nextProperty(); if (prop.getName().startsWith(ATTRIBUTE_PREFIX)) { String name = prop.getName().substring(ATTRIBUTE_PREFIX.length()); String value = prop.getString(); profile.setAttribute(name, value); } } return profile; }
java
private UserProfile readProfile(String userName, Node profileNode) throws RepositoryException { UserProfile profile = createUserProfileInstance(userName); PropertyIterator attributes = profileNode.getProperties(); while (attributes.hasNext()) { Property prop = attributes.nextProperty(); if (prop.getName().startsWith(ATTRIBUTE_PREFIX)) { String name = prop.getName().substring(ATTRIBUTE_PREFIX.length()); String value = prop.getString(); profile.setAttribute(name, value); } } return profile; }
[ "private", "UserProfile", "readProfile", "(", "String", "userName", ",", "Node", "profileNode", ")", "throws", "RepositoryException", "{", "UserProfile", "profile", "=", "createUserProfileInstance", "(", "userName", ")", ";", "PropertyIterator", "attributes", "=", "pr...
Read user profile from storage. @param profileNode the node which stores profile attributes as properties with prefix {@link #ATTRIBUTE_PREFIX} @return {@link UserProfile} instance @throws RepositoryException if unexpected exception is occurred during reading
[ "Read", "user", "profile", "from", "storage", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L334-L352
135,696
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.writeProfile
private void writeProfile(UserProfile userProfile, Node profileNode) throws RepositoryException { for (Entry<String, String> attribute : userProfile.getUserInfoMap().entrySet()) { profileNode.setProperty(ATTRIBUTE_PREFIX + attribute.getKey(), attribute.getValue()); } }
java
private void writeProfile(UserProfile userProfile, Node profileNode) throws RepositoryException { for (Entry<String, String> attribute : userProfile.getUserInfoMap().entrySet()) { profileNode.setProperty(ATTRIBUTE_PREFIX + attribute.getKey(), attribute.getValue()); } }
[ "private", "void", "writeProfile", "(", "UserProfile", "userProfile", ",", "Node", "profileNode", ")", "throws", "RepositoryException", "{", "for", "(", "Entry", "<", "String", ",", "String", ">", "attribute", ":", "userProfile", ".", "getUserInfoMap", "(", ")",...
Write profile to storage. @param profileNode the node which stores profile attributes as properties with prefix {@link #ATTRIBUTE_PREFIX} @param userProfile the profile to store @throws RepositoryException if unexpected exception is occurred during writing
[ "Write", "profile", "to", "storage", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L365-L371
135,697
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.getFromCache
private UserProfile getFromCache(String userName) { return (UserProfile)cache.get(userName, CacheType.USER_PROFILE); }
java
private UserProfile getFromCache(String userName) { return (UserProfile)cache.get(userName, CacheType.USER_PROFILE); }
[ "private", "UserProfile", "getFromCache", "(", "String", "userName", ")", "{", "return", "(", "UserProfile", ")", "cache", ".", "get", "(", "userName", ",", "CacheType", ".", "USER_PROFILE", ")", ";", "}" ]
Returns user profile from cache. Can return null.
[ "Returns", "user", "profile", "from", "cache", ".", "Can", "return", "null", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L376-L379
135,698
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.putInCache
private void putInCache(UserProfile profile) { cache.put(profile.getUserName(), profile, CacheType.USER_PROFILE); }
java
private void putInCache(UserProfile profile) { cache.put(profile.getUserName(), profile, CacheType.USER_PROFILE); }
[ "private", "void", "putInCache", "(", "UserProfile", "profile", ")", "{", "cache", ".", "put", "(", "profile", ".", "getUserName", "(", ")", ",", "profile", ",", "CacheType", ".", "USER_PROFILE", ")", ";", "}" ]
Putting user profile in cache if profile is not null.
[ "Putting", "user", "profile", "in", "cache", "if", "profile", "is", "not", "null", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L384-L387
135,699
exoplatform/jcr
exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java
UserProfileHandlerImpl.preSave
private void preSave(UserProfile userProfile, boolean isNew) throws Exception { for (UserProfileEventListener listener : listeners) { listener.preSave(userProfile, isNew); } }
java
private void preSave(UserProfile userProfile, boolean isNew) throws Exception { for (UserProfileEventListener listener : listeners) { listener.preSave(userProfile, isNew); } }
[ "private", "void", "preSave", "(", "UserProfile", "userProfile", ",", "boolean", "isNew", ")", "throws", "Exception", "{", "for", "(", "UserProfileEventListener", "listener", ":", "listeners", ")", "{", "listener", ".", "preSave", "(", "userProfile", ",", "isNew...
Notifying listeners before profile creation. @param userProfile the user profile which is used in save operation @param isNew true, if we have a deal with new profile, otherwise it is false which mean update operation is in progress @throws Exception if any listener failed to handle the event
[ "Notifying", "listeners", "before", "profile", "creation", "." ]
3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2
https://github.com/exoplatform/jcr/blob/3e7f9ee1b5683640d73a4316fb4b0ad5eac5b8a2/exo.jcr.ext.services/src/main/java/org/exoplatform/services/jcr/ext/organization/UserProfileHandlerImpl.java#L408-L414