code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
public void drawContour(boolean drawContour) { mDrawContour = drawContour; if (mDrawContour) { mIconPadding += mContourWidth; } else { mIconPadding -= mContourWidth; } invalidateSelf(); }
Enable/disable contour drawing. @param drawContour
drawContour
java
Leaking/WeGit
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
Apache-2.0
public void setIntrinsicWidth(int intrinsicWidth) { mIntrinsicWidth = intrinsicWidth; }
Set intrinsic width, which is used by several controls. @param intrinsicWidth
setIntrinsicWidth
java
Leaking/WeGit
iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
https://github.com/Leaking/WeGit/blob/master/iconlibrary/src/main/java/com/github/quinn/iconlibrary/IconicFontDrawable.java
Apache-2.0
public void revealFromMenuItem(int id, Activity activity) { setVisibility(View.VISIBLE); View menuButton = activity.findViewById(id); if (menuButton != null) { FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView() .findViewById(android.R.id.content); if (layout.findViewWithTag("searchBox") == null) { int[] location = new int[2]; menuButton.getLocationInWindow(location); revealFrom((float) location[0], (float) location[1], activity, this); } } }
Reveal the searchbox from a menu item. Specify the menu item id and pass the activity so the item can be found @param id View ID @param activity Activity
revealFromMenuItem
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void hideCircularlyToMenuItem(int id, Activity activity){ View menuButton = activity.findViewById(id); if (menuButton != null) { FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView() .findViewById(android.R.id.content); if (layout.findViewWithTag("searchBox") == null) { int[] location = new int[2]; menuButton.getLocationInWindow(location); hideCircularly(location[0] + menuButton.getWidth() * 2 / 3, location[1], activity); } } }
Hide the searchbox using the circle animation which centres upon the provided menu item. Can be called regardless of result list length @param id ID of menu item @param activity Activity
hideCircularlyToMenuItem
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void startVoiceRecognition() { if (isMicEnabled()) { Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH); intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); intent.putExtra(RecognizerIntent.EXTRA_PROMPT, context.getString(R.string.speak_now)); if (mContainerActivity != null) { mContainerActivity.startActivityForResult(intent, VOICE_RECOGNITION_CODE); } else if (mContainerFragment != null) { mContainerFragment.startActivityForResult(intent, VOICE_RECOGNITION_CODE); } else if (mContainerSupportFragment != null) { mContainerSupportFragment.startActivityForResult(intent, VOICE_RECOGNITION_CODE); } } }
Start the voice input activity manually
startVoiceRecognition
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void enableVoiceRecognition(Activity context) { mContainerActivity = context; micStateChanged(); }
Enable voice recognition for Activity @param context Context
enableVoiceRecognition
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void enableVoiceRecognition(Fragment context) { mContainerFragment = context; micStateChanged(); }
Enable voice recognition for Fragment @param context Fragment
enableVoiceRecognition
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void showLoading(boolean show){ if(show){ pb.setVisibility(View.VISIBLE); mic.setVisibility(View.INVISIBLE); }else{ pb.setVisibility(View.INVISIBLE); mic.setVisibility(View.VISIBLE); } }
Set whether to show the progress bar spinner @param show Whether to show
showLoading
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void micClick() { if (!isMic) { setSearchString(""); } else { startVoiceRecognition(); } }
Mandatory method for the onClick event
micClick
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void populateEditText(String match) { toggleSearch(); String text = match.trim(); setSearchString(text); search(text); }
Populate the searchbox with words, in an arraylist. Used by the voice input @param match Matches
populateEditText
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void updateResults() { resultList.clear(); int count = 0; for (int x = 0; x < searchables.size(); x++) { SearchResult searchable = searchables.get(x); if(mSearchFilter.onFilter(searchable,getSearchText()) && count < 5) { addResult(searchable); count++; } } if (resultList.size() == 0) { results.setVisibility(View.GONE); } else { results.setVisibility(View.VISIBLE); } }
Force an update of the results
updateResults
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setInitialResults(ArrayList<SearchResult> results){ this.initialResults = results; }
Set the results that are shown (up to 5) when the searchbox is opened with no text @param results Results
setInitialResults
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setMenuListener(MenuListener menuListener) { this.menuListener = menuListener; }
Set the menu listener @param menuListener MenuListener
setMenuListener
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setSearchListener(SearchListener listener) { this.listener = listener; }
Set the search listener @param listener SearchListener
setSearchListener
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setSearchWithoutSuggestions(boolean state){ this.searchWithoutSuggestions = state; }
Set whether to search without suggestions being available (default is true). Disable if your app only works with provided options @param state Whether to show
setSearchWithoutSuggestions
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setMaxLength(int length) { search.setFilters(new InputFilter[]{new InputFilter.LengthFilter( length)}); }
Set the maximum length of the searchbox's edittext @param length Length
setMaxLength
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setLogoText(String text) { this.logoText = text; setLogoTextInt(text); }
Set the text of the logo (default text when closed) @param text Text
setLogoText
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setSearchFilter(SearchFilter filter) { this.mSearchFilter = filter; }
Set the SearchFilter used to filter out results based on the current search term @param filter SearchFilter
setSearchFilter
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public String getSearchText() { return search.getText().toString(); }
Get the searchbox's current text @return Text
getSearchText
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setAdapter(ArrayAdapter<? extends SearchResult> adapter) { mAdapter = adapter; results.setAdapter(adapter); }
Set the adapter for the search results @param adapter Adapter
setAdapter
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setSearchString(String text) { search.setText(""); search.append(text); }
Set the searchbox's current text manually @param text Text
setSearchString
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public int getNumberOfResults() { if (resultList != null)return resultList.size(); return 0; }
Return the number of results that are currently shown @return Number of Results
getNumberOfResults
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void setSearchables(ArrayList<SearchResult> searchables){ this.searchables = searchables; }
Set the searchable items from a list (replaces any current items)
setSearchables
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void addSearchable(SearchResult searchable) { if (!searchables.contains(searchable)) searchables.add(searchable); }
Add a searchable item @param searchable SearchResult
addSearchable
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
public void removeSearchable(SearchResult searchable) { if (searchables.contains(searchable)) searchables.remove(search); }
Remove a searchable item @param searchable SearchResult
removeSearchable
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchBox.java
Apache-2.0
@Override public String toString() { return title; }
Return the title of the result
toString
java
Leaking/WeGit
MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchResult.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/com/quinny898/library/persistentsearch/SearchResult.java
Apache-2.0
public static void liftingFromBottom(View view, float baseRotation, float fromY, int duration, int startDelay){ ViewHelper.setRotationX(view, baseRotation); ViewHelper.setTranslationY(view, fromY); ViewPropertyAnimator .animate(view) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(duration) .setStartDelay(startDelay) .rotationX(0) .translationY(0) .start(); }
Lifting view @param view The animation target @param baseRotation initial Rotation X in 3D space @param fromY initial Y position of view @param duration aniamtion duration @param startDelay start delay before animation begin
liftingFromBottom
java
Leaking/WeGit
MaterialSearch/src/main/java/io/codetailps/animation/ViewAnimationUtils.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/io/codetailps/animation/ViewAnimationUtils.java
Apache-2.0
public static void liftingFromBottom(View view, float baseRotation, int duration, int startDelay){ ViewHelper.setRotationX(view, baseRotation); ViewHelper.setTranslationY(view, view.getHeight() / 3); ViewPropertyAnimator .animate(view) .setInterpolator(new AccelerateDecelerateInterpolator()) .setDuration(duration) .setStartDelay(startDelay) .rotationX(0) .translationY(0) .start(); }
Lifting view @param view The animation target @param baseRotation initial Rotation X in 3D space @param duration aniamtion duration @param startDelay start delay before animation begin
liftingFromBottom
java
Leaking/WeGit
MaterialSearch/src/main/java/io/codetailps/animation/ViewAnimationUtils.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/io/codetailps/animation/ViewAnimationUtils.java
Apache-2.0
@Override public void setCenter(float centerX, float centerY){ mCenterX = centerX; mCenterY = centerY; }
Epicenter of animation circle reveal @hide
setCenter
java
Leaking/WeGit
MaterialSearch/src/main/java/io/codetailps/widget/RevealFrameLayout.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/io/codetailps/widget/RevealFrameLayout.java
Apache-2.0
@Override public void setClipOutlines(boolean clip){ mClipOutlines = clip; }
Flag that animation is enabled @hide
setClipOutlines
java
Leaking/WeGit
MaterialSearch/src/main/java/io/codetailps/widget/RevealFrameLayout.java
https://github.com/Leaking/WeGit/blob/master/MaterialSearch/src/main/java/io/codetailps/widget/RevealFrameLayout.java
Apache-2.0
public boolean isRunning() { return this.future != null && !this.future.isDone(); }
If code is currently being ran from this object. @return If code is being ran
isRunning
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public void stopExecution() { if (this.future != null) { this.exitCode = -1; this.future.cancel(true); } }
Stops the execution of the code ran by, if it's still running.
stopExecution
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public void setRunningFuture(Future<?> future) { this.future = future; }
Sets the running future, used by the {@link RunningCodeManager}. @param future The future of the running code.
setRunningFuture
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public int getExitCode() { return this.exitCode; }
Gets the exit code of the program. @return The exit code
getExitCode
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public void setExitCode(int exitCode) { this.exitCode = exitCode; }
Sets the exit code of the program. @param exitCode The exit code
setExitCode
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public RunningCode afterSuccess(Consumer<Integer> exitCode) { this.success.add(exitCode); return this; }
Executed after the code was successfully executed. @param exitCode The code to run, with the exit code @return The current {@link RunningCode}
afterSuccess
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public RunningCode afterError(Consumer<String> message) { this.error.add(message); return this; }
Executed after the code executed with errors OR forcibly via {@link RunningCode#stopExecution()}. @param message The code to run with the stop reason @return The current {@link RunningCode}
afterError
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
public RunningCode afterAll(BiConsumer<Integer, Optional<String>> exitCodeMessage) { this.any.add(exitCodeMessage); return this; }
Executed after the code executed for any reason. If it stopped from errors or forcibly via {@link RunningCode#stopExecution()}, a message will be present. @param exitCodeMessage The code to run with the exit code and stop reason, if applicable @return The current {@link RunningCode}
afterAll
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/execution/RunningCode.java
MIT
default Control getTextControl() { var textField = new Label(); textField.setText(getName()); textField.getStyleClass().add("theme-text"); return textField; }
Gets the {@link Control} of the {@link LangGUIOption#getName()} method to be placed directly in the GUI. @return The {@link Control} of the name
getTextControl
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/gui/LangGUIOption.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/gui/LangGUIOption.java
MIT
default boolean isHidden() { return false; }
Invoked when the "Change" button is clicked, if the current option has one.
isHidden
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/gui/LangGUIOption.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/gui/LangGUIOption.java
MIT
public Optional<Color> getColor(String tokenName) { var optional = this.tokenMap.entrySet().stream().filter(entry -> entry.getKey().contains(tokenName)).findFirst().map(Map.Entry::getValue).map(Color::new); if (!optional.isPresent()) LOGGER.error("No color found for token {} for {}", tokenName, this.language.getName()); return optional; }
Gets the {@link Parser} generated by the ANTLR .g4 file for the current language. @param input The {@link TokenStream} input @return The {@link Parser}
getColor
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/HighlightData.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/HighlightData.java
MIT
public void loadForCurrent() { var current = ProjectManager.getPPFProject(); if (current.equals(this.lastInitted)) return; this.lastInitted = current; getLanguageSettings().initOptions(); }
Loads settings for the current language.
loadForCurrent
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public Optional<ExtraCreationOptions> getExtraCreationOptions() { return Optional.empty(); }
Gets the {@link ExtraCreationOptions}, if present, to display a new window upon project creation displaying alternate settings specific to the language. @return The {@link ExtraCreationOptions} if present
getExtraCreationOptions
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public File getInputLocation() { return getLanguageSettings().getSetting(getInputOption()); }
Gets the source directory that files are coming from. @return The source directory
getInputLocation
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public Optional<File> getStaticParent() { return Optional.empty(); }
Gets the parent that is requires for all projects of the current language. If not present, the user will be able to set the project to go anywhere. @return The parent directory of all projects of this language, if necessary
getStaticParent
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
protected boolean lspInstallHelper(String promptText, String website, ThrowableSupplier<Boolean> install) { if (hasLSP()) return false; try { var res = JOptionPane.showOptionDialog(null, promptText, "Download Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE, new ImageIcon(ImageIO.read(Language.class.getResourceAsStream("/icons/popup/save.png"))), new String[]{"Yes", "No", "Website"}, "Yes"); if (res == 0) { return install.get(); } else if (res == 2) { Browse.browse(website); } } catch (Exception e) { getLogger().error("There was an error while trying to install the Java LSP server", e); } return false; }
Prompts the user for an installation of the lang's LSP, with options for yes, no, or going to teh given website. @param promptText The text to ask the user if they want to install the LSP @param website The website to direct the user to if they click the "Website" option @param install The code to actually install the LSP. No further checking is required if the LSP should be installed, as {@link Language#hasLSP()} has been checked before the prompt. @return If the install was successful
lspInstallHelper
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public CompilationResult compileAndExecute(MainGUI mainGUI, ImageOutputStream imageOutputStream, ImageOutputStream compilerStream) throws IOException { var imageClassesOptional = indexFiles(); if (imageClassesOptional.isEmpty()) { getLogger().error("Error while finding ImageClasses, aborting..."); return new DefaultCompilationResult(CompilationResult.Status.COMPILE_COMPLETE); } return compileAndExecute(mainGUI, imageClassesOptional.get(), imageOutputStream, compilerStream); }
Compiles and/or executes the given image. If the language does not compile, it will interpret the files. @param mainGUI The main instance of MainGUI @param imageOutputStream The ImageOutputStream that is used for all executed program output @param compilerStream The ImageOutputStream that is used for all compilation-related output @throws IOException If an IO Exception occurs @return The result of the compilation/execution
compileAndExecute
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public CompilationResult compileAndExecute(MainGUI mainGUI, List<ImageClass> imageClasses, ImageOutputStream imageOutputStream, ImageOutputStream compilerStream) throws IOException { return compileAndExecute(mainGUI, imageClasses, imageOutputStream, compilerStream, BuildSettings.DEFAULT); }
Compiles and/or executes the given image. If the language does not compile, it will interpret the files. @param mainGUI The main instance of MainGUI @param imageClasses The {@link ImageClass}s to compile/execute, usually derived from {@link #indexFiles()} @param imageOutputStream The ImageOutputStream that is used for all executed program output @param compilerStream The ImageOutputStream that is used for all compilation-related output @throws IOException If an IO Exception occurs @return The result of the compilation/execution
compileAndExecute
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
public Optional<List<ImageClass>> indexFiles() { var LOGGER = getLogger(); var mainGUI = startupLogic.getMainGUI(); if (optionsNotFilled()) { LOGGER.error("Please select files for all options"); mainGUI.setHaveError(); return Optional.empty(); } var lspWrapper = getLSPWrapper(); var documentManager = lspWrapper.getDocumentManager(); LOGGER.info("Reading {}'s DocumentManager index...", getName()); var imageClasses = documentManager.getAllDocuments().stream().map(Document::getImageClass).collect(Collectors.toList()); LOGGER.info("Found {} documents", imageClasses.size()); mainGUI.setStatusText(null); return Optional.of(imageClasses); }
Gets all the {@link ImageClass}s that will be used during execution/compilation of the program with the current language. @return All the {@link ImageClass}s to be used during compilation/execution
indexFiles
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
protected void highlightAll(Option highlightDirectorySetting, List<ImageClass> imageClasses) throws IOException { var LOGGER = getLogger(); var mainGUI = startupLogic.getMainGUI(); if (optionsNotFilled()) { LOGGER.error("Please select files for all options"); mainGUI.setHaveError(); return; } var highlightDirectory = getLanguageSettings().<File>getSetting(highlightDirectorySetting); if (highlightDirectory != null && !highlightDirectory.isDirectory()) highlightDirectory.mkdirs(); if (highlightDirectory == null || !highlightDirectory.isDirectory()) { LOGGER.error("No highlighted file directory found!"); mainGUI.setHaveError(); return; } mainGUI.setStatusText("Highlighting..."); mainGUI.setIndeterminate(true); long start = System.currentTimeMillis(); for (ImageClass imageClass : imageClasses) { imageClass.highlight(highlightDirectory); } mainGUI.setIndeterminate(false); mainGUI.setStatusText(null); LOGGER.info("Finished highlighting all images in " + (System.currentTimeMillis() - start) + "ms"); }
Highlights all {@link ImageClass}s given. @param highlightDirectorySetting The setting of a File directory to put all highlights into @param imageClasses The {@link ImageClass}s to highlight @throws IOException If an IO Exception occurs
highlightAll
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/languages/Language.java
MIT
protected boolean IsRegexPossible() { if (this.lastToken == null) { // No token has been produced yet: at the start of the input, // no division is possible, so a regex literal _is_ possible. return true; } switch (this.lastToken.getType()) { case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.Identifier: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.NullLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.BooleanLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.This: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.CloseBracket: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.CloseParen: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.OctalIntegerLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.DecimalLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.HexIntegerLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.StringLiteral: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.PlusPlus: case com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptLexer.MinusMinus: // After any of the tokens above, no regex literal can follow. return false; default: // In all other cases, a regex literal _is_ possible. return true; } }
Returns {@code true} if the lexer can match a regex literal.
IsRegexPossible
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseLexer.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseLexer.java
MIT
protected boolean p(String str) { return prev(str); }
Short form for prev(String str)
p
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
MIT
protected boolean prev(String str) { return _input.LT(-1).getText().equals(str); }
Whether the previous token value equals to @param str
prev
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
MIT
protected boolean n(String str) { return next(str); }
Short form for next(String str)
n
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
MIT
private boolean here(final int type) { // Get the token ahead of the current index. int possibleIndexEosToken = this.getCurrentToken().getTokenIndex() - 1; Token ahead = _input.get(possibleIndexEosToken); // Check if the token resides on the HIDDEN channel and if it's of the // provided type. return (ahead.getChannel() == Lexer.HIDDEN) && (ahead.getType() == type); }
Returns {@code true} iff on the current index of the parser's token stream a token of the given {@code type} exists on the {@code HIDDEN} channel. @param type the type of the token on the {@code HIDDEN} channel to check. @return {@code true} iff on the current index of the parser's token stream a token of the given {@code type} exists on the {@code HIDDEN} channel.
here
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
MIT
protected boolean lineTerminatorAhead() { // Get the token ahead of the current index. int possibleIndexEosToken = this.getCurrentToken().getTokenIndex() - 1; Token ahead = _input.get(possibleIndexEosToken); if (ahead.getChannel() != Lexer.HIDDEN) { // We're only interested in tokens on the HIDDEN channel. return false; } if (ahead.getType() == com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptParser.LineTerminator) { // There is definitely a line terminator ahead. return true; } if (ahead.getType() == com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptParser.WhiteSpaces) { // Get the token ahead of the current whitespaces. possibleIndexEosToken = this.getCurrentToken().getTokenIndex() - 2; ahead = _input.get(possibleIndexEosToken); } // Get the token's text and type. String text = ahead.getText(); int type = ahead.getType(); // Check if the token is, or contains a line terminator. return (type == com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptParser.MultiLineComment && (text.contains("\r") || text.contains("\n"))) || (type == com.uddernetworks.mspaint.code.lexer.javascript.JavaScriptParser.LineTerminator); }
Returns {@code true} iff on the current index of the parser's token stream a token exists on the {@code HIDDEN} channel which either is a line terminator, or is a multi line comment that contains a line terminator. @return {@code true} iff on the current index of the parser's token stream a token exists on the {@code HIDDEN} channel which either is a line terminator, or is a multi line comment that contains a line terminator.
lineTerminatorAhead
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lexer/javascript/JavaScriptBaseParser.java
MIT
public boolean usesWorkspaces() { return workspace; }
Gets if the LSP server uses workspaces. @return If the LSP server uses workspaces
usesWorkspaces
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lsp/LSP.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lsp/LSP.java
MIT
private String getURI() { var nonRelPath = this.file.toURI().toString(); if (this.relParent != null) nonRelPath = this.relParent.toPath().relativize(this.file.toPath()).toString(); return nonRelPath.replaceAll("\\.png?$", ""); }
Returns the URI to be used when sending file data to the LSP server, which removes the .png file extension. @return The .png-removed URI
getURI
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/code/lsp/doc/BasicDocument.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/code/lsp/doc/BasicDocument.java
MIT
public void addFile(File image, File source) { this.added.put(image.getAbsolutePath(), source.getAbsolutePath()); }
Adds a file to git @param image The image of the code saved by MS Paint @param source The scanned code .java file
addFile
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/git/GitIndex.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/git/GitIndex.java
MIT
public boolean imageChanged() { return fileObject == null || !image.exists() || !fileObject.exists() || fileObject.lastModified() < image.lastModified(); }
Gets if a file is newer than another @return True if the first file is newer than the second one
imageChanged
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/main/ModifiedDetector.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/main/ModifiedDetector.java
MIT
public boolean optionalRestriction(G setting) { return false; }
Gets if the given setting is required to be fetched via {@link SettingsAccessor#getSettingOptional(Object)} and other optional methods. This will cause the method used to throw a runtime exception. @param setting The setting to test @return False if the setting san be used by any method, true if there is no restriction present.
optionalRestriction
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/settings/SettingsAccessor.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/settings/SettingsAccessor.java
MIT
private boolean available(int port) { if (port < 0 || port > 30000) { return false; } ServerSocket ss = null; DatagramSocket ds = null; try { ss = new ServerSocket(port); ss.setReuseAddress(true); ds = new DatagramSocket(port); ds.setReuseAddress(true); return true; } catch (IOException ignored) { } finally { if (ds != null) { ds.close(); } if (ss != null) { try { ss.close(); } catch (IOException ignored) {} } } return false; }
Checks to see if a specific port is available. @param port the port to check for availability
available
java
MSPaintIDE/MSPaintIDE
src/main/java/com/uddernetworks/mspaint/socket/DefaultInternalSocketCommunicator.java
https://github.com/MSPaintIDE/MSPaintIDE/blob/master/src/main/java/com/uddernetworks/mspaint/socket/DefaultInternalSocketCommunicator.java
MIT
public Map<String, FailureDetails> getFailedDocuments() { return failedDocuments; }
@author Peter-Josef Meisch @author Illia Ulianov @since 4.1
getFailedDocuments
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/BulkFailureException.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/BulkFailureException.java
Apache-2.0
public String getMappedName() { return mappedName; }
Inherit the dynamic setting from their parent object or from the mapping type.
getMappedName
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/annotations/Dynamic.java
Apache-2.0
static ClientConfigurationBuilderWithRequiredEndpoint builder() { return new ClientConfigurationBuilder(); }
Creates a new {@link ClientConfigurationBuilder} instance. @return a new {@link ClientConfigurationBuilder} instance.
builder
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
static ClientConfiguration localhost() { return new ClientConfigurationBuilder().connectedToLocalhost().build(); }
Creates a new {@link ClientConfiguration} instance configured to localhost. <pre class="code"> // "localhost:9200" ClientConfiguration configuration = ClientConfiguration.localhost(); </pre> @return a new {@link ClientConfiguration} instance @see ClientConfigurationBuilder#connectedToLocalhost()
localhost
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
static ClientConfiguration create(String hostAndPort) { return new ClientConfigurationBuilder().connectedTo(hostAndPort).build(); }
Creates a new {@link ClientConfiguration} instance configured to a single host given {@code hostAndPort}. For example given the endpoint http://localhost:9200 <pre class="code"> ClientConfiguration configuration = ClientConfiguration.create("localhost:9200"); </pre> @return a new {@link ClientConfigurationBuilder} instance.
create
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
static ClientConfiguration create(InetSocketAddress socketAddress) { return new ClientConfigurationBuilder().connectedTo(socketAddress).build(); }
Creates a new {@link ClientConfiguration} instance configured to a single host given {@link InetSocketAddress}. For example given the endpoint http://localhost:9200 <pre class="code"> ClientConfiguration configuration = ClientConfiguration .create(InetSocketAddress.createUnresolved("localhost", 9200)); </pre> @return a new {@link ClientConfigurationBuilder} instance.
create
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
default MaybeSecureClientConfigurationBuilder connectedTo(String hostAndPort) { return connectedTo(new String[] { hostAndPort }); }
@param hostAndPort the {@literal host} and {@literal port} formatted as String {@literal host:port}. @return the {@link MaybeSecureClientConfigurationBuilder}.
connectedTo
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
default MaybeSecureClientConfigurationBuilder connectedTo(InetSocketAddress endpoint) { return connectedTo(new InetSocketAddress[] { endpoint }); }
@param endpoint the {@literal host} and {@literal port}. @return the {@link MaybeSecureClientConfigurationBuilder}.
connectedTo
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
default MaybeSecureClientConfigurationBuilder connectedToLocalhost() { return connectedTo("localhost:9200"); }
Obviously for testing. @return the {@link MaybeSecureClientConfigurationBuilder}.
connectedToLocalhost
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
default TerminalClientConfigurationBuilder withConnectTimeout(long millis) { return withConnectTimeout(Duration.ofMillis(millis)); }
Configure the {@literal milliseconds} for the connect-timeout. @param millis the timeout to use. @return the {@link TerminalClientConfigurationBuilder} @see #withConnectTimeout(Duration)
withConnectTimeout
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
default TerminalClientConfigurationBuilder withSocketTimeout(long millis) { return withSocketTimeout(Duration.ofMillis(millis)); }
Configure the {@literal milliseconds} for the socket timeout. @param millis the timeout to use. @return the {@link TerminalClientConfigurationBuilder} @see #withSocketTimeout(Duration)
withSocketTimeout
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ClientConfiguration.java
Apache-2.0
public static InetSocketAddress parse(String hostAndPort) { return InetSocketAddressParser.parse(hostAndPort, DEFAULT_PORT); }
Parse a {@literal hostAndPort} string into a {@link InetSocketAddress}. @param hostAndPort the string containing host and port or IP address and port in the format {@code host:port}. @return the parsed {@link InetSocketAddress}.
parse
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
Apache-2.0
public boolean isOnline() { return State.ONLINE.equals(state); }
@return {@literal true} if the last known {@link State} was {@link State#ONLINE}
isOnline
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
Apache-2.0
public State getState() { return state; }
@return the last known {@link State}.
getState
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/ElasticsearchHost.java
Apache-2.0
public static InetSocketAddress parse(String hostPortString, int defaultPort) { Assert.notNull(hostPortString, "HostPortString must not be null"); String host; String portString = null; if (hostPortString.startsWith("[")) { String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString); host = hostAndPort[0]; portString = hostAndPort[1]; } else { int colonPos = hostPortString.indexOf(':'); if (colonPos >= 0 && hostPortString.indexOf(':', colonPos + 1) == -1) { // Exactly 1 colon. Split into host:port. host = hostPortString.substring(0, colonPos); portString = hostPortString.substring(colonPos + 1); } else { // 0 or 2+ colons. Bare hostname or IPv6 literal. host = hostPortString; } } int port = defaultPort; if (StringUtils.hasText(portString)) { // Try to parse the whole port string as a number. Assert.isTrue(!portString.startsWith("+"), String.format("Cannot parse port number: %s", hostPortString)); try { port = Integer.parseInt(portString); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Cannot parse port number: %s", hostPortString)); } Assert.isTrue(isValidPort(port), String.format("Port number out of range: %s", hostPortString)); } return InetSocketAddress.createUnresolved(host, port); }
Parse a host and port string into a {@link InetSocketAddress}. @param hostPortString Hostname/IP address and port formatted as {@code host:port} or {@code host}. @param defaultPort default port to apply if {@code hostPostString} does not contain a port. @return a {@link InetSocketAddress} that is unresolved to avoid DNS lookups. @see InetSocketAddress#createUnresolved(String, int)
parse
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
Apache-2.0
private static String[] getHostAndPortFromBracketedHost(String hostPortString) { Assert.isTrue(hostPortString.charAt(0) == '[', String.format("Bracketed host-port string must start with a bracket: %s", hostPortString)); int colonIndex = hostPortString.indexOf(':'); int closeBracketIndex = hostPortString.lastIndexOf(']'); Assert.isTrue(colonIndex > -1 && closeBracketIndex > colonIndex, String.format("Invalid bracketed host/port: %s", hostPortString)); String host = hostPortString.substring(1, closeBracketIndex); if (closeBracketIndex + 1 == hostPortString.length()) { return new String[] { host, "" }; } else { Assert.isTrue(hostPortString.charAt(closeBracketIndex + 1) == ':', "Only a colon may follow a close bracket: " + hostPortString); for (int i = closeBracketIndex + 2; i < hostPortString.length(); ++i) { Assert.isTrue(Character.isDigit(hostPortString.charAt(i)), String.format("Port must be numeric: %s", hostPortString)); } return new String[] { host, hostPortString.substring(closeBracketIndex + 2) }; } }
Parses a bracketed host-port string, throwing IllegalArgumentException if parsing fails. @param hostPortString the full bracketed host-port specification. Post might not be specified. @return an array with 2 strings: host and port, in that order. @throws IllegalArgumentException if parsing the bracketed host-port string fails.
getHostAndPortFromBracketedHost
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
Apache-2.0
private static boolean isValidPort(int port) { return port >= 0 && port <= 65535; }
@param port the port number @return {@literal true} for valid port numbers.
isValidPort
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/InetSocketAddressParser.java
Apache-2.0
static co.elastic.clients.elasticsearch._types.query_dsl.@Nullable Query getEsQuery(@Nullable Query query, @Nullable Consumer<Query> queryConverter) { if (query == null) { return null; } if (queryConverter != null) { queryConverter.accept(query); } co.elastic.clients.elasticsearch._types.query_dsl.Query esQuery = null; if (query instanceof CriteriaQuery criteriaQuery) { esQuery = CriteriaQueryProcessor.createQuery(criteriaQuery.getCriteria()); } else if (query instanceof StringQuery stringQuery) { esQuery = Queries.wrapperQueryAsQuery(stringQuery.getSource()); } else if (query instanceof NativeQuery nativeQuery) { if (nativeQuery.getQuery() != null) { esQuery = nativeQuery.getQuery(); } else if (nativeQuery.getSpringDataQuery() != null) { esQuery = getEsQuery(nativeQuery.getSpringDataQuery(), queryConverter); } } else { throw new IllegalArgumentException("unhandled Query implementation " + query.getClass().getName()); } return esQuery; }
Convert a spring-data-elasticsearch {@literal query} to an Elasticsearch {@literal query}. @param query spring-data-elasticsearch {@literal query}. @param queryConverter correct mapped field names and the values to the converted values. @return an Elasticsearch {@literal query}.
getEsQuery
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/AbstractQueryProcessor.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/AbstractQueryProcessor.java
Apache-2.0
@Override public void close() throws IOException { // since Elasticsearch 8.16 the ElasticsearchClient implements (through ApiClient) the Closeable interface and // handles closing of the underlying transport. We now just call the base class, but keep this as we // have been implementing AutoCloseable since 4.4 and won't change that to a mere Closeable super.close(); }
Extension of the {@link ElasticsearchClient} class that implements {@link AutoCloseable}. As the underlying {@link RestClient} must be closed properly this is handled in the {@link #close()} method. @author Peter-Josef Meisch @since 4.4
close
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/AutoCloseableElasticsearchClient.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/AutoCloseableElasticsearchClient.java
Apache-2.0
@Override public ClusterHealth health() { HealthRequest healthRequest = requestConverter.clusterHealthRequest(); HealthResponse healthResponse = execute(client -> client.health(healthRequest)); return responseConverter.clusterHealth(healthResponse); }
Implementation of the {@link ClusterOperations} interface using en {@link ElasticsearchClusterClient}. @author Peter-Josef Meisch @since 4.4
health
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ClusterTemplate.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ClusterTemplate.java
Apache-2.0
private static String extractDistanceString(Distance distance) { StringBuilder sb = new StringBuilder(); sb.append((int) distance.getValue()); switch ((Metrics) distance.getMetric()) { case KILOMETERS -> sb.append("km"); case MILES -> sb.append("mi"); } return sb.toString(); }
extract the distance string from a {@link org.springframework.data.geo.Distance} object. @param distance distance object to extract string from
extractDistanceString
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/CriteriaFilterProcessor.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/CriteriaFilterProcessor.java
Apache-2.0
@Nullable private static InnerHits getInnerHits(@Nullable InnerHitsQuery query) { if (query == null) { return null; } return InnerHits.of(iqb -> iqb.from(query.getFrom()).size(query.getSize()).name(query.getName())); }
Convert a spring-data-elasticsearch {@literal inner_hits} to an Elasticsearch {@literal inner_hits} query. @param query spring-data-elasticsearch {@literal inner_hits}. @return an Elasticsearch {@literal inner_hits} query.
getInnerHits
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/CriteriaQueryProcessor.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/CriteriaQueryProcessor.java
Apache-2.0
@Nullable public static Document from(GetResult<EntityAsMap> getResponse) { Assert.notNull(getResponse, "getResponse must not be null"); if (!getResponse.found()) { return null; } Document document = getResponse.source() != null ? Document.from(getResponse.source()) : Document.create(); document.setIndex(getResponse.index()); document.setId(getResponse.id()); if (getResponse.version() != null) { document.setVersion(getResponse.version()); } if (getResponse.seqNo() != null) { document.setSeqNo(getResponse.seqNo()); } if (getResponse.primaryTerm() != null) { document.setPrimaryTerm(getResponse.primaryTerm()); } return document; }
Creates a {@link Document} from a {@link GetResponse} where the found document is contained as {@link EntityAsMap}. @param getResponse the response instance @return the Document
from
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/DocumentAdapters.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/DocumentAdapters.java
Apache-2.0
public static List<MultiGetItem<Document>> from(MgetResponse<EntityAsMap> mgetResponse) { Assert.notNull(mgetResponse, "mgetResponse must not be null"); return mgetResponse.docs().stream() // .map(itemResponse -> MultiGetItem.of( // itemResponse.isFailure() ? null : from(itemResponse.result()), // ResponseConverter.getFailure(itemResponse))) .collect(Collectors.toList()); }
Creates a list of {@link MultiGetItem}s from a {@link MgetResponse} where the data is contained as {@link EntityAsMap} instances. @param mgetResponse the response instance @return list of multiget items
from
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/DocumentAdapters.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/DocumentAdapters.java
Apache-2.0
@Override public Aggregation aggregation() { return aggregation; }
{@link AggregationContainer} for a {@link Aggregation} that holds Elasticsearch data. @author Peter-Josef Meisch @since 4.4
aggregation
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregation.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregation.java
Apache-2.0
@Override public List<ElasticsearchAggregation> aggregations() { return aggregations; }
AggregationsContainer implementation for the Elasticsearch aggregations. @author Peter-Josef Meisch @author Sascha Woo @since 4.4
aggregations
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
Apache-2.0
public Map<String, ElasticsearchAggregation> aggregationsAsMap() { return aggregationsAsMap; }
@return the {@link ElasticsearchAggregation}s keyed by aggregation name.
aggregationsAsMap
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
Apache-2.0
@Nullable public ElasticsearchAggregation get(String name) { Assert.notNull(name, "name must not be null"); return aggregationsAsMap.get(name); }
Returns the aggregation that is associated with the specified name. @param name the name of the aggregation @return the aggregation or {@literal null} if not found
get
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchAggregations.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(ClientConfiguration clientConfiguration) { Assert.notNull(clientConfiguration, "clientConfiguration must not be null"); return createReactive(getRestClient(clientConfiguration), null, DEFAULT_JSONP_MAPPER); }
Creates a new {@link ReactiveElasticsearchClient} @param clientConfiguration configuration options, must not be {@literal null}. @return the {@link ReactiveElasticsearchClient}
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(ClientConfiguration clientConfiguration, @Nullable TransportOptions transportOptions) { Assert.notNull(clientConfiguration, "ClientConfiguration must not be null!"); return createReactive(getRestClient(clientConfiguration), transportOptions, DEFAULT_JSONP_MAPPER); }
Creates a new {@link ReactiveElasticsearchClient} @param clientConfiguration configuration options, must not be {@literal null}. @param transportOptions options to be added to each request. @return the {@link ReactiveElasticsearchClient}
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(ClientConfiguration clientConfiguration, @Nullable TransportOptions transportOptions, JsonpMapper jsonpMapper) { Assert.notNull(clientConfiguration, "ClientConfiguration must not be null!"); Assert.notNull(jsonpMapper, "jsonpMapper must not be null"); return createReactive(getRestClient(clientConfiguration), transportOptions, jsonpMapper); }
Creates a new {@link ReactiveElasticsearchClient} @param clientConfiguration configuration options, must not be {@literal null}. @param transportOptions options to be added to each request. @param jsonpMapper the JsonpMapper to use @return the {@link ReactiveElasticsearchClient}
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(RestClient restClient) { return createReactive(restClient, null, DEFAULT_JSONP_MAPPER); }
Creates a new {@link ReactiveElasticsearchClient}. @param restClient the underlying {@link RestClient} @return the {@link ReactiveElasticsearchClient}
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(RestClient restClient, @Nullable TransportOptions transportOptions, JsonpMapper jsonpMapper) { Assert.notNull(restClient, "restClient must not be null"); var transport = getElasticsearchTransport(restClient, REACTIVE_CLIENT, transportOptions, jsonpMapper); return createReactive(transport); }
Creates a new {@link ReactiveElasticsearchClient}. @param restClient the underlying {@link RestClient} @param transportOptions options to be added to each request. @return the {@link ReactiveElasticsearchClient}
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ReactiveElasticsearchClient createReactive(ElasticsearchTransport transport) { Assert.notNull(transport, "transport must not be null"); return new ReactiveElasticsearchClient(transport); }
Creates a new {@link ReactiveElasticsearchClient} that uses the given {@link ElasticsearchTransport}. @param transport the transport to use @return the {@link ElasticsearchClient
createReactive
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ElasticsearchClient createImperative(ClientConfiguration clientConfiguration) { return createImperative(getRestClient(clientConfiguration), null, DEFAULT_JSONP_MAPPER); }
Creates a new imperative {@link ElasticsearchClient} @param clientConfiguration configuration options, must not be {@literal null}. @return the {@link ElasticsearchClient}
createImperative
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ElasticsearchClient createImperative(ClientConfiguration clientConfiguration, TransportOptions transportOptions) { return createImperative(getRestClient(clientConfiguration), transportOptions, DEFAULT_JSONP_MAPPER); }
Creates a new imperative {@link ElasticsearchClient} @param clientConfiguration configuration options, must not be {@literal null}. @param transportOptions options to be added to each request. @return the {@link ElasticsearchClient}
createImperative
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ElasticsearchClient createImperative(RestClient restClient) { return createImperative(restClient, null, DEFAULT_JSONP_MAPPER); }
Creates a new imperative {@link ElasticsearchClient} @param restClient the RestClient to use @return the {@link ElasticsearchClient}
createImperative
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0
public static ElasticsearchClient createImperative(RestClient restClient, @Nullable TransportOptions transportOptions, JsonpMapper jsonpMapper) { Assert.notNull(restClient, "restClient must not be null"); ElasticsearchTransport transport = getElasticsearchTransport(restClient, IMPERATIVE_CLIENT, transportOptions, jsonpMapper); return createImperative(transport); }
Creates a new imperative {@link ElasticsearchClient} @param restClient the RestClient to use @param transportOptions options to be added to each request. @param jsonpMapper the mapper for the transport to use @return the {@link ElasticsearchClient}
createImperative
java
spring-projects/spring-data-elasticsearch
src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
https://github.com/spring-projects/spring-data-elasticsearch/blob/master/src/main/java/org/springframework/data/elasticsearch/client/elc/ElasticsearchClients.java
Apache-2.0