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
partition
stringclasses
1 value
bazaarvoice/jersey-hmac-auth
common/src/main/java/com/bazaarvoice/auth/hmac/server/AbstractAuthenticator.java
AbstractAuthenticator.validateSignature
private boolean validateSignature(Credentials credentials, String secretKey) { String clientSignature = credentials.getSignature(); String serverSignature = createSignature(credentials, secretKey); return MessageDigest.isEqual(clientSignature.getBytes(), serverSignature.getBytes()); }
java
private boolean validateSignature(Credentials credentials, String secretKey) { String clientSignature = credentials.getSignature(); String serverSignature = createSignature(credentials, secretKey); return MessageDigest.isEqual(clientSignature.getBytes(), serverSignature.getBytes()); }
[ "private", "boolean", "validateSignature", "(", "Credentials", "credentials", ",", "String", "secretKey", ")", "{", "String", "clientSignature", "=", "credentials", ".", "getSignature", "(", ")", ";", "String", "serverSignature", "=", "createSignature", "(", "creden...
Validate the signature on the request by generating a new signature here and making sure they match. The only way for them to match is if both signature are generated using the same secret key. If they match, this means that the requester has a valid secret key and can be a trusted source. @param credentials the credentials specified on the request @param secretKey the secret key that will be used to generate the signature @return true if the signature is valid
[ "Validate", "the", "signature", "on", "the", "request", "by", "generating", "a", "new", "signature", "here", "and", "making", "sure", "they", "match", ".", "The", "only", "way", "for", "them", "to", "match", "is", "if", "both", "signature", "are", "generat...
17e2a40a4b7b783de4d77ad97f8a623af6baf688
https://github.com/bazaarvoice/jersey-hmac-auth/blob/17e2a40a4b7b783de4d77ad97f8a623af6baf688/common/src/main/java/com/bazaarvoice/auth/hmac/server/AbstractAuthenticator.java#L117-L121
train
bazaarvoice/jersey-hmac-auth
common/src/main/java/com/bazaarvoice/auth/hmac/server/AbstractAuthenticator.java
AbstractAuthenticator.createSignature
private String createSignature(Credentials credentials, String secretKey) { return new SignatureGenerator().generate( secretKey, credentials.getMethod(), credentials.getTimestamp(), credentials.getPath(), credentials.getContent()); }
java
private String createSignature(Credentials credentials, String secretKey) { return new SignatureGenerator().generate( secretKey, credentials.getMethod(), credentials.getTimestamp(), credentials.getPath(), credentials.getContent()); }
[ "private", "String", "createSignature", "(", "Credentials", "credentials", ",", "String", "secretKey", ")", "{", "return", "new", "SignatureGenerator", "(", ")", ".", "generate", "(", "secretKey", ",", "credentials", ".", "getMethod", "(", ")", ",", "credentials...
Create a signature given the set of request credentials and a secret key. @param credentials the credentials specified on the request @param secretKey the secret key that will be used to generate the signature @return the signature
[ "Create", "a", "signature", "given", "the", "set", "of", "request", "credentials", "and", "a", "secret", "key", "." ]
17e2a40a4b7b783de4d77ad97f8a623af6baf688
https://github.com/bazaarvoice/jersey-hmac-auth/blob/17e2a40a4b7b783de4d77ad97f8a623af6baf688/common/src/main/java/com/bazaarvoice/auth/hmac/server/AbstractAuthenticator.java#L130-L137
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinView.java
PinView.clear
public void clear() { for (int i = 0; i < mNumberPinBoxes; i++) { getPinBox(i).getText().clear(); } checkPinBoxesAvailableOrder(); }
java
public void clear() { for (int i = 0; i < mNumberPinBoxes; i++) { getPinBox(i).getText().clear(); } checkPinBoxesAvailableOrder(); }
[ "public", "void", "clear", "(", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "mNumberPinBoxes", ";", "i", "++", ")", "{", "getPinBox", "(", "i", ")", ".", "getText", "(", ")", ".", "clear", "(", ")", ";", "}", "checkPinBoxesAvailabl...
Clear PinBoxes values
[ "Clear", "PinBoxes", "values" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinView.java#L176-L182
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinView.java
PinView.resetChildrenFocus
public void resetChildrenFocus() { for (int pinBoxesId : pinBoxesIds) { EditText pin = (EditText) findViewById(pinBoxesId); pin.setOnFocusChangeListener(this); } }
java
public void resetChildrenFocus() { for (int pinBoxesId : pinBoxesIds) { EditText pin = (EditText) findViewById(pinBoxesId); pin.setOnFocusChangeListener(this); } }
[ "public", "void", "resetChildrenFocus", "(", ")", "{", "for", "(", "int", "pinBoxesId", ":", "pinBoxesIds", ")", "{", "EditText", "pin", "=", "(", "EditText", ")", "findViewById", "(", "pinBoxesId", ")", ";", "pin", ".", "setOnFocusChangeListener", "(", "thi...
Clear PinBoxes focus
[ "Clear", "PinBoxes", "focus" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinView.java#L187-L192
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewUtils.java
PinViewUtils.convertPixelToDp
public static float convertPixelToDp(Context context, float px) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return px / (metrics.densityDpi / 160f); }
java
public static float convertPixelToDp(Context context, float px) { Resources resources = context.getResources(); DisplayMetrics metrics = resources.getDisplayMetrics(); return px / (metrics.densityDpi / 160f); }
[ "public", "static", "float", "convertPixelToDp", "(", "Context", "context", ",", "float", "px", ")", "{", "Resources", "resources", "=", "context", ".", "getResources", "(", ")", ";", "DisplayMetrics", "metrics", "=", "resources", ".", "getDisplayMetrics", "(", ...
This method converts device specific pixels to density independent pixels. @param px A value in px (pixels) unit. Which we need to convert into db @param context Context to get resources and device specific display metrics @return A float value to represent dp equivalent to px value
[ "This", "method", "converts", "device", "specific", "pixels", "to", "density", "independent", "pixels", "." ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewUtils.java#L83-L87
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewUtils.java
PinViewUtils.hideKeyboard
public static void hideKeyboard(Context context) { try { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = ((Activity) context).getCurrentFocus(); if (imm != null && currentFocus != null) { IBinder windowToken = currentFocus.getWindowToken(); if (windowToken != null) { imm.hideSoftInputFromWindow(windowToken, 0); } } } catch (Exception e) { Log.e(LOG_TAG, "Can't even hide keyboard " + e.getMessage()); } }
java
public static void hideKeyboard(Context context) { try { InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE); View currentFocus = ((Activity) context).getCurrentFocus(); if (imm != null && currentFocus != null) { IBinder windowToken = currentFocus.getWindowToken(); if (windowToken != null) { imm.hideSoftInputFromWindow(windowToken, 0); } } } catch (Exception e) { Log.e(LOG_TAG, "Can't even hide keyboard " + e.getMessage()); } }
[ "public", "static", "void", "hideKeyboard", "(", "Context", "context", ")", "{", "try", "{", "InputMethodManager", "imm", "=", "(", "InputMethodManager", ")", "context", ".", "getSystemService", "(", "Context", ".", "INPUT_METHOD_SERVICE", ")", ";", "View", "cur...
Hides the already popped up keyboard from the screen. @param context Context to get current focus.
[ "Hides", "the", "already", "popped", "up", "keyboard", "from", "the", "screen", "." ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewUtils.java#L94-L107
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.createEditModeView
private void createEditModeView(Context context) { ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.pin_view_edit_mode, this, true); }
java
private void createEditModeView(Context context) { ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)) .inflate(R.layout.pin_view_edit_mode, this, true); }
[ "private", "void", "createEditModeView", "(", "Context", "context", ")", "{", "(", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ")", ".", "inflate", "(", "R", ".", "layout", ".", "pin_view...
This method inflates the PinView to be visible from Preview Layout @param context {@link PinViewBaseHelper} needs a context to inflate Edit layout
[ "This", "method", "inflates", "the", "PinView", "to", "be", "visible", "from", "Preview", "Layout" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L91-L95
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.createView
private void createView(Context context) { ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.pin_view, this, true); inputMethodManager = (InputMethodManager) getContext().getSystemService(Service.INPUT_METHOD_SERVICE); mLinearLayoutPinTexts = (LinearLayout) findViewById(R.id.ll_pin_texts); mLinearLayoutPinBoxes = (LinearLayout) findViewById(R.id.ll_pin_edit_texts); }
java
private void createView(Context context) { ((LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.pin_view, this, true); inputMethodManager = (InputMethodManager) getContext().getSystemService(Service.INPUT_METHOD_SERVICE); mLinearLayoutPinTexts = (LinearLayout) findViewById(R.id.ll_pin_texts); mLinearLayoutPinBoxes = (LinearLayout) findViewById(R.id.ll_pin_edit_texts); }
[ "private", "void", "createView", "(", "Context", "context", ")", "{", "(", "(", "LayoutInflater", ")", "context", ".", "getSystemService", "(", "Context", ".", "LAYOUT_INFLATER_SERVICE", ")", ")", ".", "inflate", "(", "R", ".", "layout", ".", "pin_view", ","...
This method inflates the PinView @param context {@link PinViewBaseHelper} needs a context to inflate the layout
[ "This", "method", "inflates", "the", "PinView" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L102-L108
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.getAttributes
private void getAttributes(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PinView); if (typedArray != null) { try { mNumberPinBoxes = typedArray .getInteger(R.styleable.PinView_numberPinBoxes, PinViewSettings.DEFAULT_NUMBER_PIN_BOXES); mMaskPassword = typedArray .getBoolean(R.styleable.PinView_password, PinViewSettings.DEFAULT_MASK_PASSWORD); mNumberCharacters = typedArray .getInteger(R.styleable.PinView_numberCharacters, PinViewSettings.DEFAULT_NUMBER_CHARACTERS); mSplit = typedArray.getString(R.styleable.PinView_split); mKeyboardMandatory = typedArray .getBoolean(R.styleable.PinView_keyboardMandatory, PinViewSettings.DEFAULT_KEYBOARD_MANDATORY); mDeleteOnClick = typedArray .getBoolean(R.styleable.PinView_deleteOnClick, PinViewSettings.DEFAULT_DELETE_ON_CLICK); mNativePinBox = typedArray .getBoolean(R.styleable.PinView_nativePinBox, PinViewSettings.DEFAULT_NATIVE_PIN_BOX); mCustomDrawablePinBox = typedArray .getResourceId(R.styleable.PinView_drawablePinBox, PinViewSettings.DEFAULT_CUSTOM_PIN_BOX); mColorTextPinBoxes = typedArray .getColor(R.styleable.PinView_colorTextPinBox, getResources().getColor(PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX)); mColorTextTitles = typedArray .getColor(R.styleable.PinView_colorTextTitles, getResources().getColor(PinViewSettings.DEFAULT_TEXT_COLOR_TITLES)); mColorSplit = typedArray .getColor(R.styleable.PinView_colorSplit, getResources().getColor(PinViewSettings.DEFAULT_COLOR_SPLIT)); mTextSizePinBoxes = typedArray .getDimension(R.styleable.PinView_textSizePinBox, getResources().getDimension(PinViewSettings.DEFAULT_TEXT_SIZE_PIN_BOX)); mTextSizeTitles = typedArray .getDimension(R.styleable.PinView_textSizeTitles, getResources().getDimension(PinViewSettings.DEFAULT_TEXT_SIZE_TITLES)); mSizeSplit = typedArray .getDimension(R.styleable.PinView_sizeSplit, getResources().getDimension(PinViewSettings.DEFAULT_SIZE_SPLIT)); int titles; titles = typedArray.getResourceId(R.styleable.PinView_titles, -1); if (titles != -1) { setTitles(getResources().getStringArray(titles)); } if (this.mNumberPinBoxes != 0) { setPin(this.mNumberPinBoxes); } } catch (Exception e) { Log.e(LOG_TAG, "Error while creating the view PinView: ", e); } finally { typedArray.recycle(); } } }
java
private void getAttributes(Context context, AttributeSet attrs) { TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.PinView); if (typedArray != null) { try { mNumberPinBoxes = typedArray .getInteger(R.styleable.PinView_numberPinBoxes, PinViewSettings.DEFAULT_NUMBER_PIN_BOXES); mMaskPassword = typedArray .getBoolean(R.styleable.PinView_password, PinViewSettings.DEFAULT_MASK_PASSWORD); mNumberCharacters = typedArray .getInteger(R.styleable.PinView_numberCharacters, PinViewSettings.DEFAULT_NUMBER_CHARACTERS); mSplit = typedArray.getString(R.styleable.PinView_split); mKeyboardMandatory = typedArray .getBoolean(R.styleable.PinView_keyboardMandatory, PinViewSettings.DEFAULT_KEYBOARD_MANDATORY); mDeleteOnClick = typedArray .getBoolean(R.styleable.PinView_deleteOnClick, PinViewSettings.DEFAULT_DELETE_ON_CLICK); mNativePinBox = typedArray .getBoolean(R.styleable.PinView_nativePinBox, PinViewSettings.DEFAULT_NATIVE_PIN_BOX); mCustomDrawablePinBox = typedArray .getResourceId(R.styleable.PinView_drawablePinBox, PinViewSettings.DEFAULT_CUSTOM_PIN_BOX); mColorTextPinBoxes = typedArray .getColor(R.styleable.PinView_colorTextPinBox, getResources().getColor(PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX)); mColorTextTitles = typedArray .getColor(R.styleable.PinView_colorTextTitles, getResources().getColor(PinViewSettings.DEFAULT_TEXT_COLOR_TITLES)); mColorSplit = typedArray .getColor(R.styleable.PinView_colorSplit, getResources().getColor(PinViewSettings.DEFAULT_COLOR_SPLIT)); mTextSizePinBoxes = typedArray .getDimension(R.styleable.PinView_textSizePinBox, getResources().getDimension(PinViewSettings.DEFAULT_TEXT_SIZE_PIN_BOX)); mTextSizeTitles = typedArray .getDimension(R.styleable.PinView_textSizeTitles, getResources().getDimension(PinViewSettings.DEFAULT_TEXT_SIZE_TITLES)); mSizeSplit = typedArray .getDimension(R.styleable.PinView_sizeSplit, getResources().getDimension(PinViewSettings.DEFAULT_SIZE_SPLIT)); int titles; titles = typedArray.getResourceId(R.styleable.PinView_titles, -1); if (titles != -1) { setTitles(getResources().getStringArray(titles)); } if (this.mNumberPinBoxes != 0) { setPin(this.mNumberPinBoxes); } } catch (Exception e) { Log.e(LOG_TAG, "Error while creating the view PinView: ", e); } finally { typedArray.recycle(); } } }
[ "private", "void", "getAttributes", "(", "Context", "context", ",", "AttributeSet", "attrs", ")", "{", "TypedArray", "typedArray", "=", "context", ".", "obtainStyledAttributes", "(", "attrs", ",", "R", ".", "styleable", ".", "PinView", ")", ";", "if", "(", "...
Retrieve styles attributes
[ "Retrieve", "styles", "attributes" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L113-L168
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.setStylePinBox
private void setStylePinBox(EditText editText) { editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)}); if (mMaskPassword) { editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); } else{ editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } if (mNativePinBox) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation editText.setBackgroundDrawable(new EditText(getContext()).getBackground()); } else { editText.setBackground(new EditText(getContext()).getBackground()); } } else { editText.setBackgroundResource(mCustomDrawablePinBox); } if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) { editText.setTextColor(mColorTextPinBoxes); } editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes)); }
java
private void setStylePinBox(EditText editText) { editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mNumberCharacters)}); if (mMaskPassword) { editText.setTransformationMethod(PasswordTransformationMethod.getInstance()); } else{ editText.setTransformationMethod(HideReturnsTransformationMethod.getInstance()); } if (mNativePinBox) { if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) { //noinspection deprecation editText.setBackgroundDrawable(new EditText(getContext()).getBackground()); } else { editText.setBackground(new EditText(getContext()).getBackground()); } } else { editText.setBackgroundResource(mCustomDrawablePinBox); } if (mColorTextPinBoxes != PinViewSettings.DEFAULT_TEXT_COLOR_PIN_BOX) { editText.setTextColor(mColorTextPinBoxes); } editText.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizePinBoxes)); }
[ "private", "void", "setStylePinBox", "(", "EditText", "editText", ")", "{", "editText", ".", "setFilters", "(", "new", "InputFilter", "[", "]", "{", "new", "InputFilter", ".", "LengthFilter", "(", "mNumberCharacters", ")", "}", ")", ";", "if", "(", "mMaskPas...
Set a PinBox with all attributes @param editText to set attributes
[ "Set", "a", "PinBox", "with", "all", "attributes" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L200-L225
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.setStylesPinTitle
private void setStylesPinTitle(TextView pinTitle) { if (mColorTextTitles != PinViewSettings.DEFAULT_TEXT_COLOR_TITLES) { pinTitle.setTextColor(mColorTextTitles); } pinTitle.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizeTitles)); }
java
private void setStylesPinTitle(TextView pinTitle) { if (mColorTextTitles != PinViewSettings.DEFAULT_TEXT_COLOR_TITLES) { pinTitle.setTextColor(mColorTextTitles); } pinTitle.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mTextSizeTitles)); }
[ "private", "void", "setStylesPinTitle", "(", "TextView", "pinTitle", ")", "{", "if", "(", "mColorTextTitles", "!=", "PinViewSettings", ".", "DEFAULT_TEXT_COLOR_TITLES", ")", "{", "pinTitle", ".", "setTextColor", "(", "mColorTextTitles", ")", ";", "}", "pinTitle", ...
Set a Title with all attributes @param pinTitle to set attributes
[ "Set", "a", "Title", "with", "all", "attributes" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L264-L269
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.setStylesSplit
private void setStylesSplit(TextView split) { if(split!=null){ split.setText(mSplit); split.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); split.setGravity(Gravity.CENTER_VERTICAL); if (mColorSplit != PinViewSettings.DEFAULT_COLOR_SPLIT) { split.setTextColor(mColorSplit); } split.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mSizeSplit)); } }
java
private void setStylesSplit(TextView split) { if(split!=null){ split.setText(mSplit); split.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT)); split.setGravity(Gravity.CENTER_VERTICAL); if (mColorSplit != PinViewSettings.DEFAULT_COLOR_SPLIT) { split.setTextColor(mColorSplit); } split.setTextSize(PinViewUtils.convertPixelToDp(getContext(), mSizeSplit)); } }
[ "private", "void", "setStylesSplit", "(", "TextView", "split", ")", "{", "if", "(", "split", "!=", "null", ")", "{", "split", ".", "setText", "(", "mSplit", ")", ";", "split", ".", "setLayoutParams", "(", "new", "LayoutParams", "(", "ViewGroup", ".", "La...
Set a Split with all attributes @param split to set attributes
[ "Set", "a", "Split", "with", "all", "attributes" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L303-L314
train
DavidPizarro/PinView
library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java
PinViewBaseHelper.dispatchKeyEventPreIme
@Override public boolean dispatchKeyEventPreIme(KeyEvent event) { if (mKeyboardMandatory) { if (getContext() != null) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive() && event.getKeyCode() == KeyEvent.KEYCODE_BACK) { setImeVisibility(true); return true; } } } return super.dispatchKeyEventPreIme(event); }
java
@Override public boolean dispatchKeyEventPreIme(KeyEvent event) { if (mKeyboardMandatory) { if (getContext() != null) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); if (imm.isActive() && event.getKeyCode() == KeyEvent.KEYCODE_BACK) { setImeVisibility(true); return true; } } } return super.dispatchKeyEventPreIme(event); }
[ "@", "Override", "public", "boolean", "dispatchKeyEventPreIme", "(", "KeyEvent", "event", ")", "{", "if", "(", "mKeyboardMandatory", ")", "{", "if", "(", "getContext", "(", ")", "!=", "null", ")", "{", "InputMethodManager", "imm", "=", "(", "InputMethodManager...
Keyboard back button
[ "Keyboard", "back", "button" ]
b171a89694921475b5442585810b8475ef1cfe35
https://github.com/DavidPizarro/PinView/blob/b171a89694921475b5442585810b8475ef1cfe35/library/src/main/java/com/dpizarro/pinview/library/PinViewBaseHelper.java#L452-L467
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/DataLinkType.java
DataLinkType.valueOf
public static DataLinkType valueOf(short value) { for (Map.Entry<DataLinkType, Short> entry : registry.entrySet()) { if (entry.getValue() == value) { return entry.getKey(); } } return new DataLinkType((short) -1, "Unknown"); }
java
public static DataLinkType valueOf(short value) { for (Map.Entry<DataLinkType, Short> entry : registry.entrySet()) { if (entry.getValue() == value) { return entry.getKey(); } } return new DataLinkType((short) -1, "Unknown"); }
[ "public", "static", "DataLinkType", "valueOf", "(", "short", "value", ")", "{", "for", "(", "Map", ".", "Entry", "<", "DataLinkType", ",", "Short", ">", "entry", ":", "registry", ".", "entrySet", "(", ")", ")", "{", "if", "(", "entry", ".", "getValue",...
Get datalink type from value. @param value value. @return returns datalink type.
[ "Get", "datalink", "type", "from", "value", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/DataLinkType.java#L73-L80
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.netmask
@ConditionalOnClass({Inet4Address.class, PcapIf.class}) //ConditionalOnBean({PcapIf.class}) @Bean(NETMASK_BEAN_NAME) public Inet4Address netmask(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf) { Iterator<PcapAddr> iterator = pcapIf.getAddresses().iterator(); while (iterator.hasNext()) { PcapAddr pcapAddr = iterator.next(); if (pcapAddr.getNetmask() != null && pcapAddr.getNetmask().getSaFamily() == SockAddr.Family.AF_INET && pcapAddr.getNetmask().getData() != null) { Inet4Address netmask = Inet4Address.valueOf(pcapAddr.getNetmask().getData()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Default netmask: {}.", netmask); } return netmask; } } throw new UnknownNetmaskException(); }
java
@ConditionalOnClass({Inet4Address.class, PcapIf.class}) //ConditionalOnBean({PcapIf.class}) @Bean(NETMASK_BEAN_NAME) public Inet4Address netmask(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf) { Iterator<PcapAddr> iterator = pcapIf.getAddresses().iterator(); while (iterator.hasNext()) { PcapAddr pcapAddr = iterator.next(); if (pcapAddr.getNetmask() != null && pcapAddr.getNetmask().getSaFamily() == SockAddr.Family.AF_INET && pcapAddr.getNetmask().getData() != null) { Inet4Address netmask = Inet4Address.valueOf(pcapAddr.getNetmask().getData()); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Default netmask: {}.", netmask); } return netmask; } } throw new UnknownNetmaskException(); }
[ "@", "ConditionalOnClass", "(", "{", "Inet4Address", ".", "class", ",", "PcapIf", ".", "class", "}", ")", "//ConditionalOnBean({PcapIf.class})", "@", "Bean", "(", "NETMASK_BEAN_NAME", ")", "public", "Inet4Address", "netmask", "(", "@", "Qualifier", "(", "PCAP_IF_B...
Default netmask. @param pcapIf default {@link PcapIf} object. @return returns default netmask specified by {@link PcapIf} object.
[ "Default", "netmask", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L153-L171
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.macAddress
@ConditionalOnClass({MacAddress.class, PcapIf.class, PcapAddr.class, SockAddr.class, DeviceNotFoundException.class, PlatformNotSupportedException.class}) //@ConditionalOnBean(PcapIf.class) @Bean(MAC_ADDRESS_BEAN_NAME) public MacAddress macAddress(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf) throws PlatformNotSupportedException, DeviceNotFoundException, SocketException { MacAddress macAddress; if (pcapIf.isLoopback()) { macAddress = MacAddress.ZERO; if (LOGGER.isDebugEnabled()) { LOGGER.debug("No MAC address for loopback interface, use default address: {}.", macAddress); } return macAddress; } if (Platforms.isWindows()) { byte[] hardwareAddress = Jxnet.FindHardwareAddress(pcapIf.getName()); if (hardwareAddress != null && hardwareAddress.length == MacAddress.MAC_ADDRESS_LENGTH) { macAddress = MacAddress.valueOf(hardwareAddress); } else { throw new DeviceNotFoundException(); } } else { macAddress = MacAddress.fromNicName(pcapIf.getName()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Mac address: {}.", macAddress); } return macAddress; }
java
@ConditionalOnClass({MacAddress.class, PcapIf.class, PcapAddr.class, SockAddr.class, DeviceNotFoundException.class, PlatformNotSupportedException.class}) //@ConditionalOnBean(PcapIf.class) @Bean(MAC_ADDRESS_BEAN_NAME) public MacAddress macAddress(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf) throws PlatformNotSupportedException, DeviceNotFoundException, SocketException { MacAddress macAddress; if (pcapIf.isLoopback()) { macAddress = MacAddress.ZERO; if (LOGGER.isDebugEnabled()) { LOGGER.debug("No MAC address for loopback interface, use default address: {}.", macAddress); } return macAddress; } if (Platforms.isWindows()) { byte[] hardwareAddress = Jxnet.FindHardwareAddress(pcapIf.getName()); if (hardwareAddress != null && hardwareAddress.length == MacAddress.MAC_ADDRESS_LENGTH) { macAddress = MacAddress.valueOf(hardwareAddress); } else { throw new DeviceNotFoundException(); } } else { macAddress = MacAddress.fromNicName(pcapIf.getName()); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Mac address: {}.", macAddress); } return macAddress; }
[ "@", "ConditionalOnClass", "(", "{", "MacAddress", ".", "class", ",", "PcapIf", ".", "class", ",", "PcapAddr", ".", "class", ",", "SockAddr", ".", "class", ",", "DeviceNotFoundException", ".", "class", ",", "PlatformNotSupportedException", ".", "class", "}", "...
Default mac address specified by pcapIf. @param pcapIf pcapIf. @return returns mac address. @throws PlatformNotSupportedException platform not supported exception. @throws DeviceNotFoundException device not found exception. @throws SocketException socket exception.
[ "Default", "mac", "address", "specified", "by", "pcapIf", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L181-L209
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.dataLinkType
@ConditionalOnClass({Context.class, DataLinkType.class}) //@ConditionalOnBean(Context.class) @Bean(DATALINK_TYPE_BEAN_NAME) public DataLinkType dataLinkType(@Qualifier(CONTEXT_BEAN_NAME) Context context) { DataLinkType dataLinkType = context.pcapDataLink(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Datalink type: {}.", dataLinkType); } return dataLinkType; }
java
@ConditionalOnClass({Context.class, DataLinkType.class}) //@ConditionalOnBean(Context.class) @Bean(DATALINK_TYPE_BEAN_NAME) public DataLinkType dataLinkType(@Qualifier(CONTEXT_BEAN_NAME) Context context) { DataLinkType dataLinkType = context.pcapDataLink(); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Datalink type: {}.", dataLinkType); } return dataLinkType; }
[ "@", "ConditionalOnClass", "(", "{", "Context", ".", "class", ",", "DataLinkType", ".", "class", "}", ")", "//@ConditionalOnBean(Context.class)", "@", "Bean", "(", "DATALINK_TYPE_BEAN_NAME", ")", "public", "DataLinkType", "dataLinkType", "(", "@", "Qualifier", "(", ...
A handle link type. @param context application context. @return returns {@link com.ardikars.jxpacket.common.layer.DataLinkLayer}.
[ "A", "handle", "link", "type", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L216-L225
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.errbuf
@Bean(ERRBUF_BEAN_NAME) public StringBuilder errbuf() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Create error buffer with size: {}.", PCAP_ERRBUF_SIZE); } return new StringBuilder(PCAP_ERRBUF_SIZE); }
java
@Bean(ERRBUF_BEAN_NAME) public StringBuilder errbuf() { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Create error buffer with size: {}.", PCAP_ERRBUF_SIZE); } return new StringBuilder(PCAP_ERRBUF_SIZE); }
[ "@", "Bean", "(", "ERRBUF_BEAN_NAME", ")", "public", "StringBuilder", "errbuf", "(", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "(", ")", ")", "{", "LOGGER", ".", "debug", "(", "\"Create error buffer with size: {}.\"", ",", "PCAP_ERRBUF_SIZE", ")", ...
Error buffer. @return error buffer.
[ "Error", "buffer", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L231-L237
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.executorService
@Bean(EXECUTOR_SERVICE_BEAN_NAME) public ExecutorService executorService() { if (this.properties.getNumberOfThread() == 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Use cached thread pool."); } return Executors.newCachedThreadPool(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Use {} fixed thread pool.", this.properties.getNumberOfThread()); } return Executors.newFixedThreadPool(this.properties.getNumberOfThread()); }
java
@Bean(EXECUTOR_SERVICE_BEAN_NAME) public ExecutorService executorService() { if (this.properties.getNumberOfThread() == 0) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Use cached thread pool."); } return Executors.newCachedThreadPool(); } if (LOGGER.isDebugEnabled()) { LOGGER.debug("Use {} fixed thread pool.", this.properties.getNumberOfThread()); } return Executors.newFixedThreadPool(this.properties.getNumberOfThread()); }
[ "@", "Bean", "(", "EXECUTOR_SERVICE_BEAN_NAME", ")", "public", "ExecutorService", "executorService", "(", ")", "{", "if", "(", "this", ".", "properties", ".", "getNumberOfThread", "(", ")", "==", "0", ")", "{", "if", "(", "LOGGER", ".", "isDebugEnabled", "("...
Thread pool. @return returns {@link ExecutorService} object.
[ "Thread", "pool", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L243-L255
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.pcapBuilder
@ConditionalOnClass({PcapIf.class}) //@ConditionalOnBean({PcapIf.class, StringBuilder.class}) @Bean(PCAP_BUILDER_BEAN_NAME) public Pcap.Builder pcapBuilder(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf, @Qualifier(ERRBUF_BEAN_NAME) StringBuilder errbuf) { String source = pcapIf.getName(); Pcap.Builder builder = new Pcap.Builder() .source(source) .snaplen(properties.getSnapshot()) .promiscuousMode(properties.getPromiscuous()) .timeout(properties.getTimeout()) .immediateMode(properties.getImmediate()) .timestampType(properties.getTimestampType()) .direction(properties.getDirection()) .timestampPrecision(properties.getTimestampPrecision()) .rfmon(properties.getRfmon()) .enableNonBlock(!properties.getBlocking()) .dataLinkType(properties.getDatalink()) .fileName(properties.getFile()) .errbuf(errbuf); return builder; }
java
@ConditionalOnClass({PcapIf.class}) //@ConditionalOnBean({PcapIf.class, StringBuilder.class}) @Bean(PCAP_BUILDER_BEAN_NAME) public Pcap.Builder pcapBuilder(@Qualifier(PCAP_IF_BEAN_NAME) PcapIf pcapIf, @Qualifier(ERRBUF_BEAN_NAME) StringBuilder errbuf) { String source = pcapIf.getName(); Pcap.Builder builder = new Pcap.Builder() .source(source) .snaplen(properties.getSnapshot()) .promiscuousMode(properties.getPromiscuous()) .timeout(properties.getTimeout()) .immediateMode(properties.getImmediate()) .timestampType(properties.getTimestampType()) .direction(properties.getDirection()) .timestampPrecision(properties.getTimestampPrecision()) .rfmon(properties.getRfmon()) .enableNonBlock(!properties.getBlocking()) .dataLinkType(properties.getDatalink()) .fileName(properties.getFile()) .errbuf(errbuf); return builder; }
[ "@", "ConditionalOnClass", "(", "{", "PcapIf", ".", "class", "}", ")", "//@ConditionalOnBean({PcapIf.class, StringBuilder.class})", "@", "Bean", "(", "PCAP_BUILDER_BEAN_NAME", ")", "public", "Pcap", ".", "Builder", "pcapBuilder", "(", "@", "Qualifier", "(", "PCAP_IF_B...
Pcap builder. @param pcapIf pcap if. @param errbuf error buffer. @return returns pcap builder.
[ "Pcap", "builder", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L263-L284
train
jxnet/Jxnet
jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java
JxnetAutoConfiguration.context
@ConditionalOnClass({Pcap.class, Inet4Address.class, Context.class}) //@ConditionalOnBean({Pcap.Builder.class, Inet4Address.class}) @Bean(CONTEXT_BEAN_NAME) public Context context(@Qualifier(PCAP_BUILDER_BEAN_NAME) Pcap.Builder builder, @Qualifier(NETMASK_BEAN_NAME) Inet4Address netmask) { switch (properties.getPcapType()) { case DEAD: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap dead handler : {}", builder); } builder.pcapType(Pcap.PcapType.DEAD); break; case OFFLINE: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap offline hadler : {}", builder); } builder.pcapType(Pcap.PcapType.OFFLINE); break; default: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap live hadler : {}", builder); } builder.pcapType(Pcap.PcapType.LIVE); break; } Application.run(applicationName, applicationDisplayName, applicationVersion, builder); Context context = Application.getApplicationContext(); if (properties.getFilter() != null) { if (context.pcapCompile(properties.getFilter(), properties.getBpfCompileMode(), netmask.toInt()) == PcapCode.PCAP_OK) { if (context.pcapSetFilter() != PcapCode.PCAP_OK) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(context.pcapGetErr()); } } else { LOGGER.debug("Filter \'{}\' has been applied.", this.properties.getFilter()); } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn(context.pcapGetErr()); } } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("No filter has been applied."); } } return context; }
java
@ConditionalOnClass({Pcap.class, Inet4Address.class, Context.class}) //@ConditionalOnBean({Pcap.Builder.class, Inet4Address.class}) @Bean(CONTEXT_BEAN_NAME) public Context context(@Qualifier(PCAP_BUILDER_BEAN_NAME) Pcap.Builder builder, @Qualifier(NETMASK_BEAN_NAME) Inet4Address netmask) { switch (properties.getPcapType()) { case DEAD: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap dead handler : {}", builder); } builder.pcapType(Pcap.PcapType.DEAD); break; case OFFLINE: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap offline hadler : {}", builder); } builder.pcapType(Pcap.PcapType.OFFLINE); break; default: if (LOGGER.isDebugEnabled()) { LOGGER.debug("Opening pcap live hadler : {}", builder); } builder.pcapType(Pcap.PcapType.LIVE); break; } Application.run(applicationName, applicationDisplayName, applicationVersion, builder); Context context = Application.getApplicationContext(); if (properties.getFilter() != null) { if (context.pcapCompile(properties.getFilter(), properties.getBpfCompileMode(), netmask.toInt()) == PcapCode.PCAP_OK) { if (context.pcapSetFilter() != PcapCode.PCAP_OK) { if (LOGGER.isWarnEnabled()) { LOGGER.warn(context.pcapGetErr()); } } else { LOGGER.debug("Filter \'{}\' has been applied.", this.properties.getFilter()); } } else { if (LOGGER.isWarnEnabled()) { LOGGER.warn(context.pcapGetErr()); } } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("No filter has been applied."); } } return context; }
[ "@", "ConditionalOnClass", "(", "{", "Pcap", ".", "class", ",", "Inet4Address", ".", "class", ",", "Context", ".", "class", "}", ")", "//@ConditionalOnBean({Pcap.Builder.class, Inet4Address.class})", "@", "Bean", "(", "CONTEXT_BEAN_NAME", ")", "public", "Context", "...
Jxnet application context. @param builder pcap builder. @param netmask netmask. @return returns application context.
[ "Jxnet", "application", "context", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-spring-boot-autoconfigure/src/main/java/com/ardikars/jxnet/spring/boot/autoconfigure/JxnetAutoConfiguration.java#L292-L342
train
jxnet/Jxnet
jxnet-context/src/main/java/com/ardikars/jxnet/Application.java
Application.getApplicationContext
public static Context getApplicationContext() { com.ardikars.jxnet.context.Context context = com.ardikars.jxnet.context.Application.getApplicationContext(); return new ApplicationContext(context); }
java
public static Context getApplicationContext() { com.ardikars.jxnet.context.Context context = com.ardikars.jxnet.context.Application.getApplicationContext(); return new ApplicationContext(context); }
[ "public", "static", "Context", "getApplicationContext", "(", ")", "{", "com", ".", "ardikars", ".", "jxnet", ".", "context", ".", "Context", "context", "=", "com", ".", "ardikars", ".", "jxnet", ".", "context", ".", "Application", ".", "getApplicationContext",...
Get application context. @return application context.
[ "Get", "application", "context", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-context/src/main/java/com/ardikars/jxnet/Application.java#L50-L53
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java
DefaultLibraryLoader.load
@Override public void load(Callback<Void> callback, Class[] loadClasses) { boolean doNotLoad = false; for (Class clazzes : loadClasses) { try { Class.forName(clazzes.getName()); } catch (ClassNotFoundException e) { callback.onFailure(e); doNotLoad = true; } } if (!doNotLoad) { doLoad(callback); } }
java
@Override public void load(Callback<Void> callback, Class[] loadClasses) { boolean doNotLoad = false; for (Class clazzes : loadClasses) { try { Class.forName(clazzes.getName()); } catch (ClassNotFoundException e) { callback.onFailure(e); doNotLoad = true; } } if (!doNotLoad) { doLoad(callback); } }
[ "@", "Override", "public", "void", "load", "(", "Callback", "<", "Void", ">", "callback", ",", "Class", "[", "]", "loadClasses", ")", "{", "boolean", "doNotLoad", "=", "false", ";", "for", "(", "Class", "clazzes", ":", "loadClasses", ")", "{", "try", "...
Load classes then perform load native library.
[ "Load", "classes", "then", "perform", "load", "native", "library", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/util/DefaultLibraryLoader.java#L62-L76
train
jxnet/Jxnet
jxnet-example/src/main/java/com/ardikars/jxnet/example/Application.java
Application.pcapIf
public static PcapIf pcapIf(StringBuilder errbuf) throws DeviceNotFoundException { String source = Application.source; List<PcapIf> alldevsp = new ArrayList<PcapIf>(); if (PcapFindAllDevs(alldevsp, errbuf) != OK && LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Error: {}" + errbuf.toString()); } if (source == null || source.isEmpty()) { for (PcapIf dev : alldevsp) { for (PcapAddr addr : dev.getAddresses()) { if (addr.getAddr().getSaFamily() == SockAddr.Family.AF_INET && addr.getAddr().getData() != null) { Inet4Address d = Inet4Address.valueOf(addr.getAddr().getData()); if (!d.equals(Inet4Address.LOCALHOST) && !d.equals(Inet4Address.ZERO)) { return dev; } } } } } else { for (PcapIf dev : alldevsp) { if (dev.getName().equals(source)) { return dev; } } } throw new DeviceNotFoundException("No device connected to the network."); }
java
public static PcapIf pcapIf(StringBuilder errbuf) throws DeviceNotFoundException { String source = Application.source; List<PcapIf> alldevsp = new ArrayList<PcapIf>(); if (PcapFindAllDevs(alldevsp, errbuf) != OK && LOGGER.isLoggable(Level.WARNING)) { LOGGER.warning("Error: {}" + errbuf.toString()); } if (source == null || source.isEmpty()) { for (PcapIf dev : alldevsp) { for (PcapAddr addr : dev.getAddresses()) { if (addr.getAddr().getSaFamily() == SockAddr.Family.AF_INET && addr.getAddr().getData() != null) { Inet4Address d = Inet4Address.valueOf(addr.getAddr().getData()); if (!d.equals(Inet4Address.LOCALHOST) && !d.equals(Inet4Address.ZERO)) { return dev; } } } } } else { for (PcapIf dev : alldevsp) { if (dev.getName().equals(source)) { return dev; } } } throw new DeviceNotFoundException("No device connected to the network."); }
[ "public", "static", "PcapIf", "pcapIf", "(", "StringBuilder", "errbuf", ")", "throws", "DeviceNotFoundException", "{", "String", "source", "=", "Application", ".", "source", ";", "List", "<", "PcapIf", ">", "alldevsp", "=", "new", "ArrayList", "<", "PcapIf", "...
Get default pcap interface. @param errbuf error buffer. @return returns PcapIf. @throws DeviceNotFoundException device not found exception.
[ "Get", "default", "pcap", "interface", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-example/src/main/java/com/ardikars/jxnet/example/Application.java#L189-L214
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/SockAddr.java
SockAddr.getData
public byte[] getData() { if (this.data == null) { return new byte[] { }; } if (this.data.length == 0) { Family family = getSaFamily(); if (family == Family.AF_INET6) { this.data = new byte[Inet6Address.IPV6_ADDRESS_LENGTH]; } else { this.data = new byte[Inet4Address.IPV4_ADDRESS_LENGTH]; } } byte[] data = new byte[this.data.length]; System.arraycopy(this.data, 0, data, 0, data.length); return data; }
java
public byte[] getData() { if (this.data == null) { return new byte[] { }; } if (this.data.length == 0) { Family family = getSaFamily(); if (family == Family.AF_INET6) { this.data = new byte[Inet6Address.IPV6_ADDRESS_LENGTH]; } else { this.data = new byte[Inet4Address.IPV4_ADDRESS_LENGTH]; } } byte[] data = new byte[this.data.length]; System.arraycopy(this.data, 0, data, 0, data.length); return data; }
[ "public", "byte", "[", "]", "getData", "(", ")", "{", "if", "(", "this", ".", "data", "==", "null", ")", "{", "return", "new", "byte", "[", "]", "{", "}", ";", "}", "if", "(", "this", ".", "data", ".", "length", "==", "0", ")", "{", "Family",...
Returns bytes address of SockAddr. @return returns bytes address.
[ "Returns", "bytes", "address", "of", "SockAddr", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/SockAddr.java#L79-L94
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java
PcapAddr.getAddr
public SockAddr getAddr() { SockAddr sockAddr = null; if (this.addr != null) { sockAddr = new SockAddr(this.addr.getSaFamily().getValue(), this.addr.getData()); } return sockAddr; }
java
public SockAddr getAddr() { SockAddr sockAddr = null; if (this.addr != null) { sockAddr = new SockAddr(this.addr.getSaFamily().getValue(), this.addr.getData()); } return sockAddr; }
[ "public", "SockAddr", "getAddr", "(", ")", "{", "SockAddr", "sockAddr", "=", "null", ";", "if", "(", "this", ".", "addr", "!=", "null", ")", "{", "sockAddr", "=", "new", "SockAddr", "(", "this", ".", "addr", ".", "getSaFamily", "(", ")", ".", "getVal...
Getting interface address. @return returns interface address.
[ "Getting", "interface", "address", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java#L67-L73
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java
PcapAddr.getNetmask
public SockAddr getNetmask() { SockAddr sockAddr = null; if (this.netmask != null) { sockAddr = new SockAddr(this.netmask.getSaFamily().getValue(), this.netmask.getData()); } return sockAddr; }
java
public SockAddr getNetmask() { SockAddr sockAddr = null; if (this.netmask != null) { sockAddr = new SockAddr(this.netmask.getSaFamily().getValue(), this.netmask.getData()); } return sockAddr; }
[ "public", "SockAddr", "getNetmask", "(", ")", "{", "SockAddr", "sockAddr", "=", "null", ";", "if", "(", "this", ".", "netmask", "!=", "null", ")", "{", "sockAddr", "=", "new", "SockAddr", "(", "this", ".", "netmask", ".", "getSaFamily", "(", ")", ".", ...
Getting interface netmask. @return returns interface netmask.
[ "Getting", "interface", "netmask", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java#L79-L85
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java
PcapAddr.getBroadAddr
public SockAddr getBroadAddr() { SockAddr sockAddr = null; if (this.broadaddr != null) { sockAddr = new SockAddr(this.broadaddr.getSaFamily().getValue(), this.broadaddr.getData()); } return sockAddr; }
java
public SockAddr getBroadAddr() { SockAddr sockAddr = null; if (this.broadaddr != null) { sockAddr = new SockAddr(this.broadaddr.getSaFamily().getValue(), this.broadaddr.getData()); } return sockAddr; }
[ "public", "SockAddr", "getBroadAddr", "(", ")", "{", "SockAddr", "sockAddr", "=", "null", ";", "if", "(", "this", ".", "broadaddr", "!=", "null", ")", "{", "sockAddr", "=", "new", "SockAddr", "(", "this", ".", "broadaddr", ".", "getSaFamily", "(", ")", ...
Getting interface broadcast address. @return returns interface broadcast address.
[ "Getting", "interface", "broadcast", "address", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java#L91-L97
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java
PcapAddr.getDstAddr
public SockAddr getDstAddr() { SockAddr sockAddr = null; if (this.dstaddr != null) { sockAddr = new SockAddr(this.dstaddr.getSaFamily().getValue(), this.dstaddr.getData()); } return sockAddr; }
java
public SockAddr getDstAddr() { SockAddr sockAddr = null; if (this.dstaddr != null) { sockAddr = new SockAddr(this.dstaddr.getSaFamily().getValue(), this.dstaddr.getData()); } return sockAddr; }
[ "public", "SockAddr", "getDstAddr", "(", ")", "{", "SockAddr", "sockAddr", "=", "null", ";", "if", "(", "this", ".", "dstaddr", "!=", "null", ")", "{", "sockAddr", "=", "new", "SockAddr", "(", "this", ".", "dstaddr", ".", "getSaFamily", "(", ")", ".", ...
Getting interface destination address. @return returns interface destination address.
[ "Getting", "interface", "destination", "address", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapAddr.java#L103-L109
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapPktHdr.java
PcapPktHdr.newInstance
public static PcapPktHdr newInstance(final int caplen, final int len, final int tvSec, final long tvUsec) { return new PcapPktHdr(caplen, len, tvSec, tvUsec); }
java
public static PcapPktHdr newInstance(final int caplen, final int len, final int tvSec, final long tvUsec) { return new PcapPktHdr(caplen, len, tvSec, tvUsec); }
[ "public", "static", "PcapPktHdr", "newInstance", "(", "final", "int", "caplen", ",", "final", "int", "len", ",", "final", "int", "tvSec", ",", "final", "long", "tvUsec", ")", "{", "return", "new", "PcapPktHdr", "(", "caplen", ",", "len", ",", "tvSec", ",...
Create new PcapPktHdr instance. @param caplen capture length. @param len length. @param tvSec tv_sec. @param tvUsec tv_usec. @return returns PcapPktHdr.
[ "Create", "new", "PcapPktHdr", "instance", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapPktHdr.java#L67-L69
train
jxnet/Jxnet
jxnet-core/src/main/java/com/ardikars/jxnet/PcapPktHdr.java
PcapPktHdr.copy
public PcapPktHdr copy() { PcapPktHdr pktHdr = new PcapPktHdr(); pktHdr.caplen = this.caplen; pktHdr.len = this.len; pktHdr.tv_sec = this.tv_sec; pktHdr.tv_usec = this.tv_usec; return pktHdr; }
java
public PcapPktHdr copy() { PcapPktHdr pktHdr = new PcapPktHdr(); pktHdr.caplen = this.caplen; pktHdr.len = this.len; pktHdr.tv_sec = this.tv_sec; pktHdr.tv_usec = this.tv_usec; return pktHdr; }
[ "public", "PcapPktHdr", "copy", "(", ")", "{", "PcapPktHdr", "pktHdr", "=", "new", "PcapPktHdr", "(", ")", ";", "pktHdr", ".", "caplen", "=", "this", ".", "caplen", ";", "pktHdr", ".", "len", "=", "this", ".", "len", ";", "pktHdr", ".", "tv_sec", "="...
Copy this instance. @return returns new {@link PcapPktHdr} instance.
[ "Copy", "this", "instance", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-core/src/main/java/com/ardikars/jxnet/PcapPktHdr.java#L144-L151
train
jxnet/Jxnet
jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/BenchmarkApplication.java
BenchmarkApplication.run
public void run(String... args) { int maxIteration = 10; int totalMoreFast = 0; int totalMoreFastWithThreadPool = 0; int totalMoreFastPacketThreadPool = 0; for (int i = 0; i < maxIteration; i++) { LOGGER.info("**********************************"); long jxnetRunnerRes = jxnetRunner.run(); long jxnetWithThreadPoolRunnerRes = jxnetWithThreadPoolRunner.run(); long jxnetPacketThreadPoolRunnerRes = springJxnetWithThreadPoolRunner.run(); long pcap4jRunnerRes = pcap4jRunner.run(); long pcap4jWithThreadPoolRunnerRes = pcap4jWithThreadPoolRunner.run(); long pcap4jPacketThreadPoolRunnerRes = pcap4jPacketWithThreadPoolRunner.run(); LOGGER.info("Jxnet x Pcap4j"); boolean moreFast = jxnetRunnerRes < pcap4jRunnerRes; boolean moreFastWithThreadPool = jxnetWithThreadPoolRunnerRes < pcap4jWithThreadPoolRunnerRes; boolean moreFastPacketThreadPool = jxnetPacketThreadPoolRunnerRes < pcap4jPacketThreadPoolRunnerRes; if (moreFast) { totalMoreFast++; } if (moreFastWithThreadPool) { totalMoreFastWithThreadPool++; } if (moreFastPacketThreadPool) { totalMoreFastPacketThreadPool++; } LOGGER.info("Is Jxnet runner more fast? {} : {}", moreFast ? "YES" : "NO", jxnetRunnerRes + " and " + pcap4jRunnerRes); LOGGER.info("Is Jxnet with thread pool runner more fast? {} : {}", moreFastWithThreadPool ? "YES" : "NO", jxnetWithThreadPoolRunnerRes + " and " + pcap4jWithThreadPoolRunnerRes); LOGGER.info("IS Jxnet packet with thread pool runner more fast? {} : {}", moreFastPacketThreadPool ? "YES" : "NO", jxnetPacketThreadPoolRunnerRes + " and " + pcap4jPacketThreadPoolRunnerRes); LOGGER.info("**********************************\n"); } LOGGER.info("Total jxnet more fast : {}/{}", totalMoreFast, maxIteration); LOGGER.info("Total jxnet more fast with thread pool : {}/{}", totalMoreFastWithThreadPool, maxIteration); LOGGER.info("Total jxnet more fast packet decoder with thread pool : {}/{}", totalMoreFastPacketThreadPool, maxIteration); executorService.shutdownNow(); }
java
public void run(String... args) { int maxIteration = 10; int totalMoreFast = 0; int totalMoreFastWithThreadPool = 0; int totalMoreFastPacketThreadPool = 0; for (int i = 0; i < maxIteration; i++) { LOGGER.info("**********************************"); long jxnetRunnerRes = jxnetRunner.run(); long jxnetWithThreadPoolRunnerRes = jxnetWithThreadPoolRunner.run(); long jxnetPacketThreadPoolRunnerRes = springJxnetWithThreadPoolRunner.run(); long pcap4jRunnerRes = pcap4jRunner.run(); long pcap4jWithThreadPoolRunnerRes = pcap4jWithThreadPoolRunner.run(); long pcap4jPacketThreadPoolRunnerRes = pcap4jPacketWithThreadPoolRunner.run(); LOGGER.info("Jxnet x Pcap4j"); boolean moreFast = jxnetRunnerRes < pcap4jRunnerRes; boolean moreFastWithThreadPool = jxnetWithThreadPoolRunnerRes < pcap4jWithThreadPoolRunnerRes; boolean moreFastPacketThreadPool = jxnetPacketThreadPoolRunnerRes < pcap4jPacketThreadPoolRunnerRes; if (moreFast) { totalMoreFast++; } if (moreFastWithThreadPool) { totalMoreFastWithThreadPool++; } if (moreFastPacketThreadPool) { totalMoreFastPacketThreadPool++; } LOGGER.info("Is Jxnet runner more fast? {} : {}", moreFast ? "YES" : "NO", jxnetRunnerRes + " and " + pcap4jRunnerRes); LOGGER.info("Is Jxnet with thread pool runner more fast? {} : {}", moreFastWithThreadPool ? "YES" : "NO", jxnetWithThreadPoolRunnerRes + " and " + pcap4jWithThreadPoolRunnerRes); LOGGER.info("IS Jxnet packet with thread pool runner more fast? {} : {}", moreFastPacketThreadPool ? "YES" : "NO", jxnetPacketThreadPoolRunnerRes + " and " + pcap4jPacketThreadPoolRunnerRes); LOGGER.info("**********************************\n"); } LOGGER.info("Total jxnet more fast : {}/{}", totalMoreFast, maxIteration); LOGGER.info("Total jxnet more fast with thread pool : {}/{}", totalMoreFastWithThreadPool, maxIteration); LOGGER.info("Total jxnet more fast packet decoder with thread pool : {}/{}", totalMoreFastPacketThreadPool, maxIteration); executorService.shutdownNow(); }
[ "public", "void", "run", "(", "String", "...", "args", ")", "{", "int", "maxIteration", "=", "10", ";", "int", "totalMoreFast", "=", "0", ";", "int", "totalMoreFastWithThreadPool", "=", "0", ";", "int", "totalMoreFastPacketThreadPool", "=", "0", ";", "for", ...
Run bencmarking test. @param args args.
[ "Run", "bencmarking", "test", "." ]
3ef28eb83c149ff134df1841d12bcbea3d8fe163
https://github.com/jxnet/Jxnet/blob/3ef28eb83c149ff134df1841d12bcbea3d8fe163/jxnet-benchmark/src/main/java/com/ardikars/jxnet/benchmark/BenchmarkApplication.java#L72-L113
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-wikimodel/src/main/java/org/xwiki/rendering/internal/parser/wikimodel/DefaultXWikiGeneratorListener.java
DefaultXWikiGeneratorListener.convertParameters
protected Map<String, String> convertParameters(WikiParameters params) { Map<String, String> xwikiParams; if (params.getSize() > 0) { xwikiParams = new LinkedHashMap<String, String>(); for (WikiParameter wikiParameter : params.toList()) { xwikiParams.put(wikiParameter.getKey(), wikiParameter.getValue()); } } else { xwikiParams = Listener.EMPTY_PARAMETERS; } return xwikiParams; }
java
protected Map<String, String> convertParameters(WikiParameters params) { Map<String, String> xwikiParams; if (params.getSize() > 0) { xwikiParams = new LinkedHashMap<String, String>(); for (WikiParameter wikiParameter : params.toList()) { xwikiParams.put(wikiParameter.getKey(), wikiParameter.getValue()); } } else { xwikiParams = Listener.EMPTY_PARAMETERS; } return xwikiParams; }
[ "protected", "Map", "<", "String", ",", "String", ">", "convertParameters", "(", "WikiParameters", "params", ")", "{", "Map", "<", "String", ",", "String", ">", "xwikiParams", ";", "if", "(", "params", ".", "getSize", "(", ")", ">", "0", ")", "{", "xwi...
Convert Wikimodel parameters to XWiki parameters format. @param params the wikimodel parameters to convert @return the parameters in XWiki format
[ "Convert", "Wikimodel", "parameters", "to", "XWiki", "parameters", "format", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-wikimodel/src/main/java/org/xwiki/rendering/internal/parser/wikimodel/DefaultXWikiGeneratorListener.java#L194-L208
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-wikimodel/src/main/java/org/xwiki/rendering/internal/parser/wikimodel/DefaultXWikiGeneratorListener.java
DefaultXWikiGeneratorListener.convertAndSeparateParameters
protected Pair<Map<String, String>, Map<String, String>> convertAndSeparateParameters(WikiParameters params) { Map<String, String> resourceParameters; Map<String, String> genericParameters; if (params.getSize() > 0) { resourceParameters = new LinkedHashMap<String, String>(); genericParameters = new LinkedHashMap<String, String>(); for (WikiParameter wikiParameter : params.toList()) { String key = wikiParameter.getKey(); if (DocumentResourceReference.ANCHOR.equals(key) || DocumentResourceReference.QUERY_STRING.equals(key)) { resourceParameters.put(key, wikiParameter.getValue()); } else { genericParameters.put(key, wikiParameter.getValue()); } } } else { resourceParameters = Listener.EMPTY_PARAMETERS; genericParameters = Listener.EMPTY_PARAMETERS; } return new ImmutablePair<Map<String, String>, Map<String, String>>(resourceParameters, genericParameters); }
java
protected Pair<Map<String, String>, Map<String, String>> convertAndSeparateParameters(WikiParameters params) { Map<String, String> resourceParameters; Map<String, String> genericParameters; if (params.getSize() > 0) { resourceParameters = new LinkedHashMap<String, String>(); genericParameters = new LinkedHashMap<String, String>(); for (WikiParameter wikiParameter : params.toList()) { String key = wikiParameter.getKey(); if (DocumentResourceReference.ANCHOR.equals(key) || DocumentResourceReference.QUERY_STRING.equals(key)) { resourceParameters.put(key, wikiParameter.getValue()); } else { genericParameters.put(key, wikiParameter.getValue()); } } } else { resourceParameters = Listener.EMPTY_PARAMETERS; genericParameters = Listener.EMPTY_PARAMETERS; } return new ImmutablePair<Map<String, String>, Map<String, String>>(resourceParameters, genericParameters); }
[ "protected", "Pair", "<", "Map", "<", "String", ",", "String", ">", ",", "Map", "<", "String", ",", "String", ">", ">", "convertAndSeparateParameters", "(", "WikiParameters", "params", ")", "{", "Map", "<", "String", ",", "String", ">", "resourceParameters",...
Convert Wikimodel parameters to XWiki parameters format, separating anchor and query string parameters which we consider ResourceReference parameters from the rest which we consider generic event parameters. @param params the wikimodel parameters to convert @return the parameters in XWiki format, the left side of the pair is the ResourceReference parameters and the right side the generic event parameters
[ "Convert", "Wikimodel", "parameters", "to", "XWiki", "parameters", "format", "separating", "anchor", "and", "query", "string", "parameters", "which", "we", "consider", "ResourceReference", "parameters", "from", "the", "rest", "which", "we", "consider", "generic", "e...
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-wikimodel/src/main/java/org/xwiki/rendering/internal/parser/wikimodel/DefaultXWikiGeneratorListener.java#L218-L242
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/chaining/LookaheadChainingListener.java
LookaheadChainingListener.transferStart
public void transferStart(QueueListener eventsToTransfer) { while (!eventsToTransfer.isEmpty()) { Event event = eventsToTransfer.removeLast(); this.previousEvents.offerFirst(event); } }
java
public void transferStart(QueueListener eventsToTransfer) { while (!eventsToTransfer.isEmpty()) { Event event = eventsToTransfer.removeLast(); this.previousEvents.offerFirst(event); } }
[ "public", "void", "transferStart", "(", "QueueListener", "eventsToTransfer", ")", "{", "while", "(", "!", "eventsToTransfer", ".", "isEmpty", "(", ")", ")", "{", "Event", "event", "=", "eventsToTransfer", ".", "removeLast", "(", ")", ";", "this", ".", "previ...
Transfer all passed events by removing the from the passed parameter and moving them to the beginning of the event stack. @param eventsToTransfer the collection of events to move @since 10.5RC1
[ "Transfer", "all", "passed", "events", "by", "removing", "the", "from", "the", "passed", "parameter", "and", "moving", "them", "to", "the", "beginning", "of", "the", "event", "stack", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/chaining/LookaheadChainingListener.java#L554-L560
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiFormat.java
WikiFormat.addStyle
public WikiFormat addStyle(WikiStyle style) { if (fStyles.contains(style)) { return this; } WikiFormat clone = getClone(); clone.fStyles.add(style); return clone; }
java
public WikiFormat addStyle(WikiStyle style) { if (fStyles.contains(style)) { return this; } WikiFormat clone = getClone(); clone.fStyles.add(style); return clone; }
[ "public", "WikiFormat", "addStyle", "(", "WikiStyle", "style", ")", "{", "if", "(", "fStyles", ".", "contains", "(", "style", ")", ")", "{", "return", "this", ";", "}", "WikiFormat", "clone", "=", "getClone", "(", ")", ";", "clone", ".", "fStyles", "."...
Creates a new style set and adds the given style to it. @param style the style to add @return a new copy of the style set containing the given style
[ "Creates", "a", "new", "style", "set", "and", "adds", "the", "given", "style", "to", "it", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiFormat.java#L100-L108
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiFormat.java
WikiFormat.removeStyle
public WikiFormat removeStyle(WikiStyle style) { if (!fStyles.contains(style)) { return this; } WikiFormat clone = getClone(); clone.fStyles.remove(style); return clone; }
java
public WikiFormat removeStyle(WikiStyle style) { if (!fStyles.contains(style)) { return this; } WikiFormat clone = getClone(); clone.fStyles.remove(style); return clone; }
[ "public", "WikiFormat", "removeStyle", "(", "WikiStyle", "style", ")", "{", "if", "(", "!", "fStyles", ".", "contains", "(", "style", ")", ")", "{", "return", "this", ";", "}", "WikiFormat", "clone", "=", "getClone", "(", ")", ";", "clone", ".", "fStyl...
Creates a new style set which does not contain the specified style. @param style the style to add @return a new copy of the style set containing the given style
[ "Creates", "a", "new", "style", "set", "which", "does", "not", "contain", "the", "specified", "style", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiFormat.java#L188-L196
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiPageUtil.java
WikiPageUtil.escapeXmlString
public static String escapeXmlString(String str, boolean escapeQuots) { if (str == null) { return ""; } StringBuffer buf = new StringBuffer(); char[] array = str.toCharArray(); for (int i = 0; i < array.length; i++) { if (array[i] == '>' || array[i] == '&' || array[i] == '<' || (escapeQuots && (array[i] == '\'' || array[i] == '"'))) { buf.append("&#x" + Integer.toHexString(array[i]) + ";"); } else { buf.append(array[i]); } } return buf.toString(); }
java
public static String escapeXmlString(String str, boolean escapeQuots) { if (str == null) { return ""; } StringBuffer buf = new StringBuffer(); char[] array = str.toCharArray(); for (int i = 0; i < array.length; i++) { if (array[i] == '>' || array[i] == '&' || array[i] == '<' || (escapeQuots && (array[i] == '\'' || array[i] == '"'))) { buf.append("&#x" + Integer.toHexString(array[i]) + ";"); } else { buf.append(array[i]); } } return buf.toString(); }
[ "public", "static", "String", "escapeXmlString", "(", "String", "str", ",", "boolean", "escapeQuots", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "\"\"", ";", "}", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "char"...
Returns the escaped string. @param str the string to escape @param escapeQuots if this flag is <code>true</code> then "'" and "\"" symbols also will be escaped @return the escaped string.
[ "Returns", "the", "escaped", "string", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiPageUtil.java#L163-L182
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java
DefaultMacroContentParser.createXDOM
private XDOM createXDOM(String content, MacroTransformationContext macroContext, boolean transform, MetaData metadata, boolean inline, Syntax syntax) throws MacroExecutionException { try { XDOM result = getSyntaxParser(syntax).parse(new StringReader(content)); if (metadata != null) { result.getMetaData().addMetaData(metadata); } if (transform && macroContext.getTransformation() != null) { TransformationContext txContext = new TransformationContext(result, syntax); txContext.setId(macroContext.getId()); performTransformation((MutableRenderingContext) this.renderingContext, macroContext.getTransformation(), txContext, result); } if (inline) { result = convertToInline(result); } return result; } catch (Exception e) { throw new MacroExecutionException("Failed to parse content [" + content + "]", e); } }
java
private XDOM createXDOM(String content, MacroTransformationContext macroContext, boolean transform, MetaData metadata, boolean inline, Syntax syntax) throws MacroExecutionException { try { XDOM result = getSyntaxParser(syntax).parse(new StringReader(content)); if (metadata != null) { result.getMetaData().addMetaData(metadata); } if (transform && macroContext.getTransformation() != null) { TransformationContext txContext = new TransformationContext(result, syntax); txContext.setId(macroContext.getId()); performTransformation((MutableRenderingContext) this.renderingContext, macroContext.getTransformation(), txContext, result); } if (inline) { result = convertToInline(result); } return result; } catch (Exception e) { throw new MacroExecutionException("Failed to parse content [" + content + "]", e); } }
[ "private", "XDOM", "createXDOM", "(", "String", "content", ",", "MacroTransformationContext", "macroContext", ",", "boolean", "transform", ",", "MetaData", "metadata", ",", "boolean", "inline", ",", "Syntax", "syntax", ")", "throws", "MacroExecutionException", "{", ...
creates XDOM.
[ "creates", "XDOM", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java#L109-L134
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java
DefaultMacroContentParser.performTransformation
private void performTransformation(MutableRenderingContext renderingContext, Transformation transformation, TransformationContext context, Block block) throws MacroExecutionException { try { renderingContext.transformInContext(transformation, context, block); } catch (Exception e) { throw new MacroExecutionException("Failed to perform transformation", e); } }
java
private void performTransformation(MutableRenderingContext renderingContext, Transformation transformation, TransformationContext context, Block block) throws MacroExecutionException { try { renderingContext.transformInContext(transformation, context, block); } catch (Exception e) { throw new MacroExecutionException("Failed to perform transformation", e); } }
[ "private", "void", "performTransformation", "(", "MutableRenderingContext", "renderingContext", ",", "Transformation", "transformation", ",", "TransformationContext", "context", ",", "Block", "block", ")", "throws", "MacroExecutionException", "{", "try", "{", "renderingCont...
Calls transformInContext on renderingContext.
[ "Calls", "transformInContext", "on", "renderingContext", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java#L139-L147
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java
DefaultMacroContentParser.getSyntaxParser
private Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException { try { return this.componentManager.getInstance(Parser.class, syntax.toIdString()); } catch (ComponentLookupException e) { throw new MacroExecutionException("Failed to find source parser for syntax [" + syntax + "]", e); } }
java
private Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException { try { return this.componentManager.getInstance(Parser.class, syntax.toIdString()); } catch (ComponentLookupException e) { throw new MacroExecutionException("Failed to find source parser for syntax [" + syntax + "]", e); } }
[ "private", "Parser", "getSyntaxParser", "(", "Syntax", "syntax", ")", "throws", "MacroExecutionException", "{", "try", "{", "return", "this", ".", "componentManager", ".", "getInstance", "(", "Parser", ".", "class", ",", "syntax", ".", "toIdString", "(", ")", ...
Get the parser for the current syntax. @param syntax the current syntax of the title content @return the parser for the current syntax @throws org.xwiki.rendering.macro.MacroExecutionException Failed to find source parser.
[ "Get", "the", "parser", "for", "the", "current", "syntax", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/macro/DefaultMacroContentParser.java#L183-L190
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java
AbstractXHTMLLinkTypeRenderer.computeLabel
protected String computeLabel(ResourceReference reference) { // Look for a component implementing URILabelGenerator with a role hint matching the link scheme. // If not found then use the full reference as the label. // If there's no scheme separator then use the full reference as the label. Note that this can happen // when we're not in wiki mode (since all links are considered URIs when not in wiki mode). String label; try { URILabelGenerator uriLabelGenerator = this.componentManager.getInstance(URILabelGenerator.class, reference.getType().getScheme()); label = uriLabelGenerator.generateLabel(reference); } catch (ComponentLookupException e) { label = reference.getReference(); } return label; }
java
protected String computeLabel(ResourceReference reference) { // Look for a component implementing URILabelGenerator with a role hint matching the link scheme. // If not found then use the full reference as the label. // If there's no scheme separator then use the full reference as the label. Note that this can happen // when we're not in wiki mode (since all links are considered URIs when not in wiki mode). String label; try { URILabelGenerator uriLabelGenerator = this.componentManager.getInstance(URILabelGenerator.class, reference.getType().getScheme()); label = uriLabelGenerator.generateLabel(reference); } catch (ComponentLookupException e) { label = reference.getReference(); } return label; }
[ "protected", "String", "computeLabel", "(", "ResourceReference", "reference", ")", "{", "// Look for a component implementing URILabelGenerator with a role hint matching the link scheme.", "// If not found then use the full reference as the label.", "// If there's no scheme separator then use th...
Default implementation for computing a link label when no label has been specified. Can be overwritten by implementations to provide a different algorithm. @param reference the reference of the link for which to compute the label @return the computed label
[ "Default", "implementation", "for", "computing", "a", "link", "label", "when", "no", "label", "has", "been", "specified", ".", "Can", "be", "overwritten", "by", "implementations", "to", "provide", "a", "different", "algorithm", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java#L122-L137
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java
AbstractXHTMLLinkTypeRenderer.handleTargetAttribute
private void handleTargetAttribute(Map<String, String> anchorAttributes) { String target = anchorAttributes.get("target"); // Target can have these values: // // "_blank" which opens the link in a new window // "_self" which opens the link in the same window (default) // "_top" and "_parent" which control the top or the parent window of some frame // "frame-name" (it could be anything) which opens the link in the frame called "frame-name". // // "_self", "_top" and "_parent" are the only safe values. So we need to handle any other value... if (StringUtils.isNotBlank(target) && !"_self".equals(target) && !"_parent".equals(target) && !"_top".equals(target)) { List<String> relAttributes = new ArrayList<>(); // Parse the current values String relAttribute = anchorAttributes.get(REL); if (relAttribute != null) { relAttributes.addAll(Arrays.asList(relAttribute.split(" "))); } // Add the "noopener" attribute if (!relAttributes.contains(NOOPENER)) { relAttributes.add(NOOPENER); } // Add the "noreferrer" attribute if (!relAttributes.contains(NOREFERRER)) { relAttributes.add(NOREFERRER); } // Serialize the attributes if (!relAttributes.isEmpty()) { anchorAttributes.put(REL, String.join(" ", relAttributes)); } } }
java
private void handleTargetAttribute(Map<String, String> anchorAttributes) { String target = anchorAttributes.get("target"); // Target can have these values: // // "_blank" which opens the link in a new window // "_self" which opens the link in the same window (default) // "_top" and "_parent" which control the top or the parent window of some frame // "frame-name" (it could be anything) which opens the link in the frame called "frame-name". // // "_self", "_top" and "_parent" are the only safe values. So we need to handle any other value... if (StringUtils.isNotBlank(target) && !"_self".equals(target) && !"_parent".equals(target) && !"_top".equals(target)) { List<String> relAttributes = new ArrayList<>(); // Parse the current values String relAttribute = anchorAttributes.get(REL); if (relAttribute != null) { relAttributes.addAll(Arrays.asList(relAttribute.split(" "))); } // Add the "noopener" attribute if (!relAttributes.contains(NOOPENER)) { relAttributes.add(NOOPENER); } // Add the "noreferrer" attribute if (!relAttributes.contains(NOREFERRER)) { relAttributes.add(NOREFERRER); } // Serialize the attributes if (!relAttributes.isEmpty()) { anchorAttributes.put(REL, String.join(" ", relAttributes)); } } }
[ "private", "void", "handleTargetAttribute", "(", "Map", "<", "String", ",", "String", ">", "anchorAttributes", ")", "{", "String", "target", "=", "anchorAttributes", ".", "get", "(", "\"target\"", ")", ";", "// Target can have these values:", "//", "// \"_blank\" wh...
When a link is open in an other window or in an other frame, the loaded page has some restricted access to the parent window. Among other things, it has the ability to redirect it to an other page, which can lead to dangerous phishing attacks. See: https://mathiasbynens.github.io/rel-noopener/ or https://dev.to/phishing or https://jira.xwiki.org/browse/XRENDERING-462 To avoid this vulnerability, we automatically add the "noopener" value to the "rel" attribute of the anchor. But because Firefox does not handle it, we also need to add the "noreferer" value. @param anchorAttributes the anchor attributes (that going to be changed) @since 7.4.5 @since 8.2.2 @since 8.3M2
[ "When", "a", "link", "is", "open", "in", "an", "other", "window", "or", "in", "an", "other", "frame", "the", "loaded", "page", "has", "some", "restricted", "access", "to", "the", "parent", "window", ".", "Among", "other", "things", "it", "has", "the", ...
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java#L180-L217
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java
AbstractXHTMLLinkTypeRenderer.addAttributeValue
private String addAttributeValue(String currentValue, String valueToAdd) { String newValue; if (currentValue == null || currentValue.length() == 0) { newValue = ""; } else { newValue = currentValue + " "; } return newValue + valueToAdd; }
java
private String addAttributeValue(String currentValue, String valueToAdd) { String newValue; if (currentValue == null || currentValue.length() == 0) { newValue = ""; } else { newValue = currentValue + " "; } return newValue + valueToAdd; }
[ "private", "String", "addAttributeValue", "(", "String", "currentValue", ",", "String", "valueToAdd", ")", "{", "String", "newValue", ";", "if", "(", "currentValue", "==", "null", "||", "currentValue", ".", "length", "(", ")", "==", "0", ")", "{", "newValue"...
Add an attribute value to an existing attribute. This is useful for example for adding a value to an HTML CLASS attribute. @param currentValue the current value of the attribute (can be null) @param valueToAdd the value to add @return the current value augmented by the value to add
[ "Add", "an", "attribute", "value", "to", "an", "existing", "attribute", ".", "This", "is", "useful", "for", "example", "for", "adding", "a", "value", "to", "an", "HTML", "CLASS", "attribute", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/AbstractXHTMLLinkTypeRenderer.java#L241-L250
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java
AbstractBlock.indexOf
@Unstable public long indexOf(Block child) { CounterBlockMatcher counter = new CounterBlockMatcher(child); Block found = getFirstBlock(counter, Axes.ANCESTOR_OR_SELF); return found != null ? counter.getCount() : -1; }
java
@Unstable public long indexOf(Block child) { CounterBlockMatcher counter = new CounterBlockMatcher(child); Block found = getFirstBlock(counter, Axes.ANCESTOR_OR_SELF); return found != null ? counter.getCount() : -1; }
[ "@", "Unstable", "public", "long", "indexOf", "(", "Block", "child", ")", "{", "CounterBlockMatcher", "counter", "=", "new", "CounterBlockMatcher", "(", "child", ")", ";", "Block", "found", "=", "getFirstBlock", "(", "counter", ",", "Axes", ".", "ANCESTOR_OR_S...
Find the index of the block in the tree. @param child the block for which to find the index @return the index of the passed block in the tree, 0 is the current block and -1 means that it was not found @since 10.10RC1
[ "Find", "the", "index", "of", "the", "block", "in", "the", "tree", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/block/AbstractBlock.java#L348-L356
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xwiki/xwiki20/XWikiSerializer2.java
XWikiSerializer2.clearName
public final static String clearName(String name) { boolean stripDots = false; boolean ascii = true; return clearName(name, stripDots, ascii); }
java
public final static String clearName(String name) { boolean stripDots = false; boolean ascii = true; return clearName(name, stripDots, ascii); }
[ "public", "final", "static", "String", "clearName", "(", "String", "name", ")", "{", "boolean", "stripDots", "=", "false", ";", "boolean", "ascii", "=", "true", ";", "return", "clearName", "(", "name", ",", "stripDots", ",", "ascii", ")", ";", "}" ]
Clears the name of files; used while uploading attachments within XWiki RECOMMENDED FOR NAMES OF UPLOADED FILES. (boolean stripDots = false; boolean ascii = true;)
[ "Clears", "the", "name", "of", "files", ";", "used", "while", "uploading", "attachments", "within", "XWiki" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xwiki/xwiki20/XWikiSerializer2.java#L570-L575
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/WikiEntityUtil.java
WikiEntityUtil.getHtmlCodeByHtmlEntity
public static int getHtmlCodeByHtmlEntity(String htmlEntity) { Entity entity = fHtmlToWiki.get(htmlEntity); return entity != null ? entity.fHtmlCode : 0; }
java
public static int getHtmlCodeByHtmlEntity(String htmlEntity) { Entity entity = fHtmlToWiki.get(htmlEntity); return entity != null ? entity.fHtmlCode : 0; }
[ "public", "static", "int", "getHtmlCodeByHtmlEntity", "(", "String", "htmlEntity", ")", "{", "Entity", "entity", "=", "fHtmlToWiki", ".", "get", "(", "htmlEntity", ")", ";", "return", "entity", "!=", "null", "?", "entity", ".", "fHtmlCode", ":", "0", ";", ...
Returns an HTML code corresponding to the specified HTML entity. @param htmlEntity the HTML entity to transform to the corresponding HTML code @return an HTML code corresponding to the specified HTML entity
[ "Returns", "an", "HTML", "code", "corresponding", "to", "the", "specified", "HTML", "entity", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/WikiEntityUtil.java#L142-L146
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/WikiEntityUtil.java
WikiEntityUtil.getHtmlCodeByWikiSymbol
public static int getHtmlCodeByWikiSymbol(String wikiEntity) { Entity entity = fWikiToHtml.get(wikiEntity); return entity != null ? entity.fHtmlCode : 0; }
java
public static int getHtmlCodeByWikiSymbol(String wikiEntity) { Entity entity = fWikiToHtml.get(wikiEntity); return entity != null ? entity.fHtmlCode : 0; }
[ "public", "static", "int", "getHtmlCodeByWikiSymbol", "(", "String", "wikiEntity", ")", "{", "Entity", "entity", "=", "fWikiToHtml", ".", "get", "(", "wikiEntity", ")", ";", "return", "entity", "!=", "null", "?", "entity", ".", "fHtmlCode", ":", "0", ";", ...
Returns an HTML code corresponding to the specified wiki entity. @param wikiEntity the wiki entity to transform to the corresponding HTML entity @return an HTML code corresponding to the specified wiki entity
[ "Returns", "an", "HTML", "code", "corresponding", "to", "the", "specified", "wiki", "entity", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/WikiEntityUtil.java#L155-L159
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java
WikiScannerUtil.matchesSequence
public static boolean matchesSequence( char[] array, int arrayPos, char[] sequence) { int i; int j; for (i = arrayPos, j = 0; i < array.length && j < sequence.length; i++, j++) { if (array[i] != sequence[j]) { break; } } return j == sequence.length; }
java
public static boolean matchesSequence( char[] array, int arrayPos, char[] sequence) { int i; int j; for (i = arrayPos, j = 0; i < array.length && j < sequence.length; i++, j++) { if (array[i] != sequence[j]) { break; } } return j == sequence.length; }
[ "public", "static", "boolean", "matchesSequence", "(", "char", "[", "]", "array", ",", "int", "arrayPos", ",", "char", "[", "]", "sequence", ")", "{", "int", "i", ";", "int", "j", ";", "for", "(", "i", "=", "arrayPos", ",", "j", "=", "0", ";", "i...
Indicate if the specified sequence starts from the given position in the character array. @param array the array of characters @param arrayPos the position of the first character in the array; starting from this position the sequence should be skipped @param sequence the sequence of characters to match @return true if the sequence is found, false otherwise
[ "Indicate", "if", "the", "specified", "sequence", "starts", "from", "the", "given", "position", "in", "the", "character", "array", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L253-L266
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java
WikiScannerUtil.removeSpaces
private static int removeSpaces(char[] array, int pos, StringBuffer buf) { buf.delete(0, buf.length()); for (; pos < array.length && (array[pos] == '=' || Character.isSpaceChar(array[pos])); pos++) { if (array[pos] == '=') { buf.append(array[pos]); } } return pos; }
java
private static int removeSpaces(char[] array, int pos, StringBuffer buf) { buf.delete(0, buf.length()); for (; pos < array.length && (array[pos] == '=' || Character.isSpaceChar(array[pos])); pos++) { if (array[pos] == '=') { buf.append(array[pos]); } } return pos; }
[ "private", "static", "int", "removeSpaces", "(", "char", "[", "]", "array", ",", "int", "pos", ",", "StringBuffer", "buf", ")", "{", "buf", ".", "delete", "(", "0", ",", "buf", ".", "length", "(", ")", ")", ";", "for", "(", ";", "pos", "<", "arra...
Moves forward the current position in the array until the first not empty character is found. @param array the array of characters where the spaces are searched @param pos the current position in the array; starting from this position the spaces will be searched @param buf to this buffer all not empty characters will be added @return the new position int the array of characters
[ "Moves", "forward", "the", "current", "position", "in", "the", "array", "until", "the", "first", "not", "empty", "character", "is", "found", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L278-L289
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java
WikiScannerUtil.skipSequence
public static int skipSequence(char[] array, int arrayPos, char[] sequence) { int i; int j; for (i = arrayPos, j = 0; i < array.length && j < sequence.length; i++, j++) { if (array[i] != sequence[j]) { break; } } return j == sequence.length ? i : arrayPos; }
java
public static int skipSequence(char[] array, int arrayPos, char[] sequence) { int i; int j; for (i = arrayPos, j = 0; i < array.length && j < sequence.length; i++, j++) { if (array[i] != sequence[j]) { break; } } return j == sequence.length ? i : arrayPos; }
[ "public", "static", "int", "skipSequence", "(", "char", "[", "]", "array", ",", "int", "arrayPos", ",", "char", "[", "]", "sequence", ")", "{", "int", "i", ";", "int", "j", ";", "for", "(", "i", "=", "arrayPos", ",", "j", "=", "0", ";", "i", "<...
Skips the specified sequence if it starts from the given position in the character array. @param array the array of characters @param arrayPos the position of the first character in the array; starting from this position the sequence should be skipped @param sequence the sequence of characters to skip @return a new value of the character counter
[ "Skips", "the", "specified", "sequence", "if", "it", "starts", "from", "the", "given", "position", "in", "the", "character", "array", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L301-L311
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java
WikiScannerUtil.splitToPairs
public static int splitToPairs( String str, List<WikiParameter> list, String delimiter, String end, char escapeChar) { if (str == null) { return 0; } char[] array = str.toCharArray(); if (delimiter == null) { delimiter = " "; } char[] delimiterArray = delimiter.toCharArray(); char[] endArray = end != null ? end.toCharArray() : new char[0]; StringBuffer buf = new StringBuffer(); int i = 0; boolean[] trim = {false}; for (; i < array.length; ) { String key = null; String value = null; i = removeSpaces(array, i, buf); if (i >= array.length) { break; } int prev = i; i = skipSequence(array, i, delimiterArray); if (i >= array.length) { break; } if (i > prev) { i = removeSpaces(array, i, buf); if (i >= array.length) { break; } } // if provided ending sequence is found, we stop parsing if (end != null && matchesSequence(array, i, endArray)) { break; } i = getNextToken(array, i, delimiterArray, buf, trim, escapeChar); key = buf.toString().trim(); i = removeSpaces(array, i, buf); if (buf.indexOf("=") >= 0) { i = getNextToken( array, i, delimiterArray, buf, trim, escapeChar); value = buf.toString(); if (trim[0]) { value = value.trim(); } } WikiParameter entry = new WikiParameter(key, value); list.add(entry); } return i; }
java
public static int splitToPairs( String str, List<WikiParameter> list, String delimiter, String end, char escapeChar) { if (str == null) { return 0; } char[] array = str.toCharArray(); if (delimiter == null) { delimiter = " "; } char[] delimiterArray = delimiter.toCharArray(); char[] endArray = end != null ? end.toCharArray() : new char[0]; StringBuffer buf = new StringBuffer(); int i = 0; boolean[] trim = {false}; for (; i < array.length; ) { String key = null; String value = null; i = removeSpaces(array, i, buf); if (i >= array.length) { break; } int prev = i; i = skipSequence(array, i, delimiterArray); if (i >= array.length) { break; } if (i > prev) { i = removeSpaces(array, i, buf); if (i >= array.length) { break; } } // if provided ending sequence is found, we stop parsing if (end != null && matchesSequence(array, i, endArray)) { break; } i = getNextToken(array, i, delimiterArray, buf, trim, escapeChar); key = buf.toString().trim(); i = removeSpaces(array, i, buf); if (buf.indexOf("=") >= 0) { i = getNextToken( array, i, delimiterArray, buf, trim, escapeChar); value = buf.toString(); if (trim[0]) { value = value.trim(); } } WikiParameter entry = new WikiParameter(key, value); list.add(entry); } return i; }
[ "public", "static", "int", "splitToPairs", "(", "String", "str", ",", "List", "<", "WikiParameter", ">", "list", ",", "String", "delimiter", ",", "String", "end", ",", "char", "escapeChar", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", ...
Splits the given string into a set of key-value pairs; all extracted values will be added to the given list @param str the string to split @param list to this list all extracted values will be added @param delimiter a delimiter for individual key/value pairs @param end the ending sequence, if null it's not taken into account @param escapeChar the escaping character @return the index where parser stopped
[ "Splits", "the", "given", "string", "into", "a", "set", "of", "key", "-", "value", "pairs", ";", "all", "extracted", "values", "will", "be", "added", "to", "the", "given", "list" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L369-L434
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java
WikiScannerUtil.unescape
public static String unescape(String str, char escape) { if (str == null) { return ""; } StringBuffer buf = new StringBuffer(); char[] array = str.toCharArray(); boolean escaped = false; for (int i = 0; i < array.length; i++) { char ch = array[i]; if (escaped) { buf.append(ch); escaped = false; } else { escaped = (ch == escape); if (!escaped) { buf.append(ch); } } } return buf.toString(); }
java
public static String unescape(String str, char escape) { if (str == null) { return ""; } StringBuffer buf = new StringBuffer(); char[] array = str.toCharArray(); boolean escaped = false; for (int i = 0; i < array.length; i++) { char ch = array[i]; if (escaped) { buf.append(ch); escaped = false; } else { escaped = (ch == escape); if (!escaped) { buf.append(ch); } } } return buf.toString(); }
[ "public", "static", "String", "unescape", "(", "String", "str", ",", "char", "escape", ")", "{", "if", "(", "str", "==", "null", ")", "{", "return", "\"\"", ";", "}", "StringBuffer", "buf", "=", "new", "StringBuffer", "(", ")", ";", "char", "[", "]",...
Unescapes the given string and returns the result. @param str the string to unescape @param escape the symbol used to escape characters @return an unescaped string
[ "Unescapes", "the", "given", "string", "and", "returns", "the", "result", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/WikiScannerUtil.java#L455-L476
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-linkchecker/src/main/java/org/xwiki/rendering/internal/transformation/linkchecker/DefaultLinkCheckerThread.java
DefaultLinkCheckerThread.processLinkQueue
protected void processLinkQueue() { long timeout = this.configuration.getCheckTimeout(); List<Pattern> excludedReferencePatterns = this.configuration.getExcludedReferencePatterns(); // Unqueue till we find an item that needs to be processed. We process an item if: // - it isn't present in the state map // - it is present but not enough time has elapsed since its last check time LinkQueueItem queueItem = null; boolean shouldBeChecked = false; while (!this.linkQueue.isEmpty() && !shouldBeChecked) { queueItem = this.linkQueue.poll(); // Don't check excluded references shouldBeChecked = isExcluded(queueItem.getContentReference(), excludedReferencePatterns); if (!shouldBeChecked) { break; } Map<String, LinkState> contentReferences = this.linkStateManager.getLinkStates().get(queueItem.getLinkReference()); if (contentReferences != null) { LinkState state = contentReferences.get(queueItem.getContentReference()); if (state != null && (System.currentTimeMillis() - state.getLastCheckedTime() <= timeout)) { shouldBeChecked = false; } } } if (shouldBeChecked && queueItem != null) { checkLink(queueItem); } }
java
protected void processLinkQueue() { long timeout = this.configuration.getCheckTimeout(); List<Pattern> excludedReferencePatterns = this.configuration.getExcludedReferencePatterns(); // Unqueue till we find an item that needs to be processed. We process an item if: // - it isn't present in the state map // - it is present but not enough time has elapsed since its last check time LinkQueueItem queueItem = null; boolean shouldBeChecked = false; while (!this.linkQueue.isEmpty() && !shouldBeChecked) { queueItem = this.linkQueue.poll(); // Don't check excluded references shouldBeChecked = isExcluded(queueItem.getContentReference(), excludedReferencePatterns); if (!shouldBeChecked) { break; } Map<String, LinkState> contentReferences = this.linkStateManager.getLinkStates().get(queueItem.getLinkReference()); if (contentReferences != null) { LinkState state = contentReferences.get(queueItem.getContentReference()); if (state != null && (System.currentTimeMillis() - state.getLastCheckedTime() <= timeout)) { shouldBeChecked = false; } } } if (shouldBeChecked && queueItem != null) { checkLink(queueItem); } }
[ "protected", "void", "processLinkQueue", "(", ")", "{", "long", "timeout", "=", "this", ".", "configuration", ".", "getCheckTimeout", "(", ")", ";", "List", "<", "Pattern", ">", "excludedReferencePatterns", "=", "this", ".", "configuration", ".", "getExcludedRef...
Read the queue and find links to process, removing links that have already been checked out recently.
[ "Read", "the", "queue", "and", "find", "links", "to", "process", "removing", "links", "that", "have", "already", "been", "checked", "out", "recently", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-linkchecker/src/main/java/org/xwiki/rendering/internal/transformation/linkchecker/DefaultLinkCheckerThread.java#L145-L178
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java
TocTreeBuilder.generateTree
private Block generateTree(List<HeaderBlock> headers, int start, int depth, boolean numbered, String documentReference) { Block tocBlock = null; int currentLevel = start - 1; Block currentBlock = null; for (HeaderBlock headerBlock : headers) { int headerLevel = headerBlock.getLevel().getAsInt(); if (headerLevel >= start && headerLevel <= depth) { // Move to next header in toc tree if (currentLevel < headerLevel) { while (currentLevel < headerLevel) { if (currentBlock instanceof ListBLock) { currentBlock = addItemBlock(currentBlock, null, documentReference); } currentBlock = createChildListBlock(numbered, currentBlock); ++currentLevel; } } else { while (currentLevel > headerLevel) { currentBlock = currentBlock.getParent().getParent(); --currentLevel; } currentBlock = currentBlock.getParent(); } currentBlock = addItemBlock(currentBlock, headerBlock, documentReference); } } if (currentBlock != null) { tocBlock = currentBlock.getRoot(); } return tocBlock; }
java
private Block generateTree(List<HeaderBlock> headers, int start, int depth, boolean numbered, String documentReference) { Block tocBlock = null; int currentLevel = start - 1; Block currentBlock = null; for (HeaderBlock headerBlock : headers) { int headerLevel = headerBlock.getLevel().getAsInt(); if (headerLevel >= start && headerLevel <= depth) { // Move to next header in toc tree if (currentLevel < headerLevel) { while (currentLevel < headerLevel) { if (currentBlock instanceof ListBLock) { currentBlock = addItemBlock(currentBlock, null, documentReference); } currentBlock = createChildListBlock(numbered, currentBlock); ++currentLevel; } } else { while (currentLevel > headerLevel) { currentBlock = currentBlock.getParent().getParent(); --currentLevel; } currentBlock = currentBlock.getParent(); } currentBlock = addItemBlock(currentBlock, headerBlock, documentReference); } } if (currentBlock != null) { tocBlock = currentBlock.getRoot(); } return tocBlock; }
[ "private", "Block", "generateTree", "(", "List", "<", "HeaderBlock", ">", "headers", ",", "int", "start", ",", "int", "depth", ",", "boolean", "numbered", ",", "String", "documentReference", ")", "{", "Block", "tocBlock", "=", "null", ";", "int", "currentLev...
Convert headers into list block tree. @param headers the headers to convert. @param start the "start" parameter value. @param depth the "depth" parameter value. @param numbered the "numbered" parameter value. @return the root block of generated block tree or null if no header was matching the specified parameters
[ "Convert", "headers", "into", "list", "block", "tree", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java#L115-L154
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java
TocTreeBuilder.createTocEntry
private ListItemBlock createTocEntry(HeaderBlock headerBlock, String documentReference) { // Create the link to target the header anchor DocumentResourceReference reference = new DocumentResourceReference(documentReference); reference.setAnchor(headerBlock.getId()); LinkBlock linkBlock = new LinkBlock(this.tocBlockFilter.generateLabel(headerBlock), reference, false); return new ListItemBlock(Collections.singletonList(linkBlock)); }
java
private ListItemBlock createTocEntry(HeaderBlock headerBlock, String documentReference) { // Create the link to target the header anchor DocumentResourceReference reference = new DocumentResourceReference(documentReference); reference.setAnchor(headerBlock.getId()); LinkBlock linkBlock = new LinkBlock(this.tocBlockFilter.generateLabel(headerBlock), reference, false); return new ListItemBlock(Collections.singletonList(linkBlock)); }
[ "private", "ListItemBlock", "createTocEntry", "(", "HeaderBlock", "headerBlock", ",", "String", "documentReference", ")", "{", "// Create the link to target the header anchor", "DocumentResourceReference", "reference", "=", "new", "DocumentResourceReference", "(", "documentRefere...
Create a new toc list item based on section title. @param headerBlock the {@link HeaderBlock}. @return the new list item block.
[ "Create", "a", "new", "toc", "list", "item", "based", "on", "section", "title", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java#L188-L196
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java
TocTreeBuilder.createChildListBlock
private ListBLock createChildListBlock(boolean numbered, Block parentBlock) { ListBLock childListBlock = numbered ? new NumberedListBlock(Collections.emptyList()) : new BulletedListBlock(Collections.emptyList()); if (parentBlock != null) { parentBlock.addChild(childListBlock); } return childListBlock; }
java
private ListBLock createChildListBlock(boolean numbered, Block parentBlock) { ListBLock childListBlock = numbered ? new NumberedListBlock(Collections.emptyList()) : new BulletedListBlock(Collections.emptyList()); if (parentBlock != null) { parentBlock.addChild(childListBlock); } return childListBlock; }
[ "private", "ListBLock", "createChildListBlock", "(", "boolean", "numbered", ",", "Block", "parentBlock", ")", "{", "ListBLock", "childListBlock", "=", "numbered", "?", "new", "NumberedListBlock", "(", "Collections", ".", "emptyList", "(", ")", ")", ":", "new", "...
Create a new ListBlock and add it in the provided parent block. @param numbered indicate if the list has to be numbered or with bullets @param parentBlock the block where to add the new list block. @return the new list block.
[ "Create", "a", "new", "ListBlock", "and", "add", "it", "in", "the", "provided", "parent", "block", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-toc/src/main/java/org/xwiki/rendering/internal/macro/toc/TocTreeBuilder.java#L205-L215
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java
XHTMLWhitespaceXMLFilter.appendInlineEvent
private void appendInlineEvent(Event event) throws SAXException { cleanContentLeadingSpaces(); cleanContentExtraWhiteSpaces(); if (getContent().length() > 0) { sendPreviousContent(false); fPreviousInlineText.append(getContent()); if (getContent().charAt(getContent().length() - 1) == ' ') { fPreviousContent = getContent().toString(); fPreviousElements.add(event); } else { sendCharacters(getContent().toString().toCharArray()); sendInlineEvent(event); } getContent().setLength(0); } else { if (fPreviousInlineText.length() == 0) { // There is no inline text before this inline element sendInlineEvent(event); } else { // The last inline text ends with a space fPreviousElements.add(event); } } }
java
private void appendInlineEvent(Event event) throws SAXException { cleanContentLeadingSpaces(); cleanContentExtraWhiteSpaces(); if (getContent().length() > 0) { sendPreviousContent(false); fPreviousInlineText.append(getContent()); if (getContent().charAt(getContent().length() - 1) == ' ') { fPreviousContent = getContent().toString(); fPreviousElements.add(event); } else { sendCharacters(getContent().toString().toCharArray()); sendInlineEvent(event); } getContent().setLength(0); } else { if (fPreviousInlineText.length() == 0) { // There is no inline text before this inline element sendInlineEvent(event); } else { // The last inline text ends with a space fPreviousElements.add(event); } } }
[ "private", "void", "appendInlineEvent", "(", "Event", "event", ")", "throws", "SAXException", "{", "cleanContentLeadingSpaces", "(", ")", ";", "cleanContentExtraWhiteSpaces", "(", ")", ";", "if", "(", "getContent", "(", ")", ".", "length", "(", ")", ">", "0", ...
Append an inline element. Inline elements ending with a space are stacked waiting for a non space character or the end of the inline content.
[ "Append", "an", "inline", "element", ".", "Inline", "elements", "ending", "with", "a", "space", "are", "stacked", "waiting", "for", "a", "non", "space", "character", "or", "the", "end", "of", "the", "inline", "content", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java#L348-L376
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java
XHTMLWhitespaceXMLFilter.startNonVisibleElement
protected void startNonVisibleElement() throws SAXException { if (shouldRemoveWhiteSpaces()) { cleanContentLeadingSpaces(); cleanContentExtraWhiteSpaces(); if (getContent().length() > 0) { sendPreviousContent(false); fPreviousInlineText.append(getContent()); if (getContent().charAt(getContent().length() - 1) == ' ') { fPreviousContent = getContent().toString(); } else { sendCharacters(getContent().toString().toCharArray()); } } // The is some text ending with a space before the non visible // element. The space will move after the element if it's needed (if // the element is followed by inline text); if (fPreviousContent != null) { sendCharacters(fPreviousContent.toCharArray(), 0, fPreviousContent.length() - 1); fPreviousContent = " "; } } else { // Send current content sendCharacters(getContent().toString().toCharArray()); } getContent().setLength(0); // Do not clean white spaces when in non visible element ++fNoCleanUpLevel; }
java
protected void startNonVisibleElement() throws SAXException { if (shouldRemoveWhiteSpaces()) { cleanContentLeadingSpaces(); cleanContentExtraWhiteSpaces(); if (getContent().length() > 0) { sendPreviousContent(false); fPreviousInlineText.append(getContent()); if (getContent().charAt(getContent().length() - 1) == ' ') { fPreviousContent = getContent().toString(); } else { sendCharacters(getContent().toString().toCharArray()); } } // The is some text ending with a space before the non visible // element. The space will move after the element if it's needed (if // the element is followed by inline text); if (fPreviousContent != null) { sendCharacters(fPreviousContent.toCharArray(), 0, fPreviousContent.length() - 1); fPreviousContent = " "; } } else { // Send current content sendCharacters(getContent().toString().toCharArray()); } getContent().setLength(0); // Do not clean white spaces when in non visible element ++fNoCleanUpLevel; }
[ "protected", "void", "startNonVisibleElement", "(", ")", "throws", "SAXException", "{", "if", "(", "shouldRemoveWhiteSpaces", "(", ")", ")", "{", "cleanContentLeadingSpaces", "(", ")", ";", "cleanContentExtraWhiteSpaces", "(", ")", ";", "if", "(", "getContent", "(...
Append an non visible element.
[ "Append", "an", "non", "visible", "element", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java#L408-L443
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java
XHTMLWhitespaceXMLFilter.trimLeadingWhiteSpaces
protected void trimLeadingWhiteSpaces() { if (shouldRemoveWhiteSpaces() && getContent().length() > 0) { String result = trimLeadingWhiteSpaces(getContent()); getContent().setLength(0); getContent().append(result); } }
java
protected void trimLeadingWhiteSpaces() { if (shouldRemoveWhiteSpaces() && getContent().length() > 0) { String result = trimLeadingWhiteSpaces(getContent()); getContent().setLength(0); getContent().append(result); } }
[ "protected", "void", "trimLeadingWhiteSpaces", "(", ")", "{", "if", "(", "shouldRemoveWhiteSpaces", "(", ")", "&&", "getContent", "(", ")", ".", "length", "(", ")", ">", "0", ")", "{", "String", "result", "=", "trimLeadingWhiteSpaces", "(", "getContent", "("...
when in CDATA or PRE elements).
[ "when", "in", "CDATA", "or", "PRE", "elements", ")", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/filter/XHTMLWhitespaceXMLFilter.java#L507-L514
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-html/src/main/java/org/xwiki/rendering/internal/macro/html/HTMLMacro.java
HTMLMacro.cleanHTML
private String cleanHTML(String content, MacroTransformationContext context) throws MacroExecutionException { String cleanedContent = content; HTMLCleanerConfiguration cleanerConfiguration = getCleanerConfiguration(context); // Note that we trim the content since we want to be lenient with the user in case he has entered // some spaces/newlines before a XML declaration (prolog). Otherwise the XML parser would fail to parse. Document document = this.htmlCleaner.clean(new StringReader(cleanedContent), cleanerConfiguration); // Since XML can only have a single root node and since we want to allow users to put // content such as the following, we need to wrap the content in a root node: // <tag1> // .. // </tag1> // <tag2> // </tag2> // In addition we also need to ensure the XHTML DTD is defined so that valid XHTML entities can be // specified. // Remove the HTML envelope since this macro is only a fragment of a page which will already have an // HTML envelope when rendered. We remove it so that the HTML <head> tag isn't output. HTMLUtils.stripHTMLEnvelope(document); // If in inline mode verify we have inline HTML content and remove the top level paragraph if there's one if (context.isInline()) { // TODO: Improve this since when're inside a table cell or a list item we can allow non inline items too Element root = document.getDocumentElement(); if (root.getChildNodes().getLength() == 1 && root.getFirstChild().getNodeType() == Node.ELEMENT_NODE && root.getFirstChild().getNodeName().equalsIgnoreCase("p")) { HTMLUtils.stripFirstElementInside(document, HTMLConstants.TAG_HTML, HTMLConstants.TAG_P); } else { throw new MacroExecutionException( "When using the HTML macro inline, you can only use inline HTML content." + " Block HTML content (such as tables) cannot be displayed." + " Try leaving an empty line before and after the HTML macro."); } } // Don't print the XML declaration nor the XHTML DocType. cleanedContent = HTMLUtils.toString(document, true, true); // Don't print the top level html element (which is always present and at the same location // since it's been normalized by the HTML cleaner) // Note: we trim the first 7 characters since they correspond to a leading new line (generated by // XMLUtils.toString() since the doctype is printed on a line by itself followed by a new line) + // the 6 chars from "<html>". cleanedContent = cleanedContent.substring(7, cleanedContent.length() - 8); return cleanedContent; }
java
private String cleanHTML(String content, MacroTransformationContext context) throws MacroExecutionException { String cleanedContent = content; HTMLCleanerConfiguration cleanerConfiguration = getCleanerConfiguration(context); // Note that we trim the content since we want to be lenient with the user in case he has entered // some spaces/newlines before a XML declaration (prolog). Otherwise the XML parser would fail to parse. Document document = this.htmlCleaner.clean(new StringReader(cleanedContent), cleanerConfiguration); // Since XML can only have a single root node and since we want to allow users to put // content such as the following, we need to wrap the content in a root node: // <tag1> // .. // </tag1> // <tag2> // </tag2> // In addition we also need to ensure the XHTML DTD is defined so that valid XHTML entities can be // specified. // Remove the HTML envelope since this macro is only a fragment of a page which will already have an // HTML envelope when rendered. We remove it so that the HTML <head> tag isn't output. HTMLUtils.stripHTMLEnvelope(document); // If in inline mode verify we have inline HTML content and remove the top level paragraph if there's one if (context.isInline()) { // TODO: Improve this since when're inside a table cell or a list item we can allow non inline items too Element root = document.getDocumentElement(); if (root.getChildNodes().getLength() == 1 && root.getFirstChild().getNodeType() == Node.ELEMENT_NODE && root.getFirstChild().getNodeName().equalsIgnoreCase("p")) { HTMLUtils.stripFirstElementInside(document, HTMLConstants.TAG_HTML, HTMLConstants.TAG_P); } else { throw new MacroExecutionException( "When using the HTML macro inline, you can only use inline HTML content." + " Block HTML content (such as tables) cannot be displayed." + " Try leaving an empty line before and after the HTML macro."); } } // Don't print the XML declaration nor the XHTML DocType. cleanedContent = HTMLUtils.toString(document, true, true); // Don't print the top level html element (which is always present and at the same location // since it's been normalized by the HTML cleaner) // Note: we trim the first 7 characters since they correspond to a leading new line (generated by // XMLUtils.toString() since the doctype is printed on a line by itself followed by a new line) + // the 6 chars from "<html>". cleanedContent = cleanedContent.substring(7, cleanedContent.length() - 8); return cleanedContent; }
[ "private", "String", "cleanHTML", "(", "String", "content", ",", "MacroTransformationContext", "context", ")", "throws", "MacroExecutionException", "{", "String", "cleanedContent", "=", "content", ";", "HTMLCleanerConfiguration", "cleanerConfiguration", "=", "getCleanerConf...
Clean the HTML entered by the user, transforming it into valid XHTML. @param content the content to clean @param context the macro transformation context @return the cleaned HTML as a string representing valid XHTML @throws MacroExecutionException if the macro is inline and the content is not inline HTML
[ "Clean", "the", "HTML", "entered", "by", "the", "user", "transforming", "it", "into", "valid", "XHTML", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-html/src/main/java/org/xwiki/rendering/internal/macro/html/HTMLMacro.java#L181-L231
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-html/src/main/java/org/xwiki/rendering/internal/macro/html/HTMLMacro.java
HTMLMacro.renderWikiSyntax
private String renderWikiSyntax(String content, Transformation transformation, MacroTransformationContext context) throws MacroExecutionException { String xhtml; try { // Parse the wiki syntax XDOM xdom = this.contentParser.parse(content, context, false, false); // Force clean=false for sub HTML macro: // - at this point we don't know the context of the macro, it can be some <div> directly followed by the // html macro, it this case the macro will be parsed as inline block // - by forcing clean=false, we also make the html macro merge the whole html before cleaning so the cleaner // have the chole context and can clean better List<MacroBlock> macros = xdom.getBlocks(MACROBLOCKMATCHER, Axes.DESCENDANT); for (MacroBlock macro : macros) { if ("html".equals(macro.getId())) { macro.setParameter("clean", "false"); } } MacroBlock htmlMacroBlock = context.getCurrentMacroBlock(); MacroMarkerBlock htmlMacroMarker = new MacroMarkerBlock(htmlMacroBlock.getId(), htmlMacroBlock.getParameters(), htmlMacroBlock.getContent(), xdom.getChildren(), htmlMacroBlock.isInline()); // Make sure the context XDOM contains the html macro content htmlMacroBlock.getParent().replaceChild(htmlMacroMarker, htmlMacroBlock); try { // Execute the Macro transformation ((MutableRenderingContext) this.renderingContext).transformInContext(transformation, context.getTransformationContext(), htmlMacroMarker); } finally { // Restore context XDOM to its previous state htmlMacroMarker.getParent().replaceChild(htmlMacroBlock, htmlMacroMarker); } // Render the whole parsed content as a XHTML string WikiPrinter printer = new DefaultWikiPrinter(); PrintRenderer renderer = this.xhtmlRendererFactory.createRenderer(printer); for (Block block : htmlMacroMarker.getChildren()) { block.traverse(renderer); } xhtml = printer.toString(); } catch (Exception e) { throw new MacroExecutionException("Failed to parse content [" + content + "].", e); } return xhtml; }
java
private String renderWikiSyntax(String content, Transformation transformation, MacroTransformationContext context) throws MacroExecutionException { String xhtml; try { // Parse the wiki syntax XDOM xdom = this.contentParser.parse(content, context, false, false); // Force clean=false for sub HTML macro: // - at this point we don't know the context of the macro, it can be some <div> directly followed by the // html macro, it this case the macro will be parsed as inline block // - by forcing clean=false, we also make the html macro merge the whole html before cleaning so the cleaner // have the chole context and can clean better List<MacroBlock> macros = xdom.getBlocks(MACROBLOCKMATCHER, Axes.DESCENDANT); for (MacroBlock macro : macros) { if ("html".equals(macro.getId())) { macro.setParameter("clean", "false"); } } MacroBlock htmlMacroBlock = context.getCurrentMacroBlock(); MacroMarkerBlock htmlMacroMarker = new MacroMarkerBlock(htmlMacroBlock.getId(), htmlMacroBlock.getParameters(), htmlMacroBlock.getContent(), xdom.getChildren(), htmlMacroBlock.isInline()); // Make sure the context XDOM contains the html macro content htmlMacroBlock.getParent().replaceChild(htmlMacroMarker, htmlMacroBlock); try { // Execute the Macro transformation ((MutableRenderingContext) this.renderingContext).transformInContext(transformation, context.getTransformationContext(), htmlMacroMarker); } finally { // Restore context XDOM to its previous state htmlMacroMarker.getParent().replaceChild(htmlMacroBlock, htmlMacroMarker); } // Render the whole parsed content as a XHTML string WikiPrinter printer = new DefaultWikiPrinter(); PrintRenderer renderer = this.xhtmlRendererFactory.createRenderer(printer); for (Block block : htmlMacroMarker.getChildren()) { block.traverse(renderer); } xhtml = printer.toString(); } catch (Exception e) { throw new MacroExecutionException("Failed to parse content [" + content + "].", e); } return xhtml; }
[ "private", "String", "renderWikiSyntax", "(", "String", "content", ",", "Transformation", "transformation", ",", "MacroTransformationContext", "context", ")", "throws", "MacroExecutionException", "{", "String", "xhtml", ";", "try", "{", "// Parse the wiki syntax", "XDOM",...
Parse the passed context using a wiki syntax parser and render the result as an XHTML string. @param content the content to parse @param transformation the macro transformation to execute macros when wiki is set to true @param context the context of the macros transformation process @return the output XHTML as a string containing the XWiki Syntax resolved as XHTML @throws MacroExecutionException in case there's a parsing problem
[ "Parse", "the", "passed", "context", "using", "a", "wiki", "syntax", "parser", "and", "render", "the", "result", "as", "an", "XHTML", "string", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-html/src/main/java/org/xwiki/rendering/internal/macro/html/HTMLMacro.java#L242-L295
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiReferenceParser.java
WikiReferenceParser.getParameters
protected WikiParameters getParameters(String[] chunks) { return WikiParameters.newWikiParameters(chunks.length > 2 ? chunks[2] .trim() : null); }
java
protected WikiParameters getParameters(String[] chunks) { return WikiParameters.newWikiParameters(chunks.length > 2 ? chunks[2] .trim() : null); }
[ "protected", "WikiParameters", "getParameters", "(", "String", "[", "]", "chunks", ")", "{", "return", "WikiParameters", ".", "newWikiParameters", "(", "chunks", ".", "length", ">", "2", "?", "chunks", "[", "2", "]", ".", "trim", "(", ")", ":", "null", "...
Extracts parameters part of the original reference and returns it as a WikiParameters. @param chunks the array of chunks @return the parameters
[ "Extracts", "parameters", "part", "of", "the", "original", "reference", "and", "returns", "it", "as", "a", "WikiParameters", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiReferenceParser.java#L63-L67
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiReferenceParser.java
WikiReferenceParser.splitToChunks
protected String[] splitToChunks(String str) { String delimiter = "[|>]"; String[] chunks = str.split(delimiter); return chunks; }
java
protected String[] splitToChunks(String str) { String delimiter = "[|>]"; String[] chunks = str.split(delimiter); return chunks; }
[ "protected", "String", "[", "]", "splitToChunks", "(", "String", "str", ")", "{", "String", "delimiter", "=", "\"[|>]\"", ";", "String", "[", "]", "chunks", "=", "str", ".", "split", "(", "delimiter", ")", ";", "return", "chunks", ";", "}" ]
Returns the given string split to individual segments @param str the string to split @return the given string split to individual segments
[ "Returns", "the", "given", "string", "split", "to", "individual", "segments" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiReferenceParser.java#L96-L101
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/macro/footnote/PutFootnotesMacro.java
PutFootnotesMacro.addFootnoteRef
private void addFootnoteRef(MacroMarkerBlock footnoteMacro, Block footnoteRef) { footnoteMacro.getChildren().clear(); footnoteMacro.addChild(footnoteRef); }
java
private void addFootnoteRef(MacroMarkerBlock footnoteMacro, Block footnoteRef) { footnoteMacro.getChildren().clear(); footnoteMacro.addChild(footnoteRef); }
[ "private", "void", "addFootnoteRef", "(", "MacroMarkerBlock", "footnoteMacro", ",", "Block", "footnoteRef", ")", "{", "footnoteMacro", ".", "getChildren", "(", ")", ".", "clear", "(", ")", ";", "footnoteMacro", ".", "addChild", "(", "footnoteRef", ")", ";", "}...
Add a footnote to the list of document footnotes. If such a list doesn't exist yet, create it and append it to the end of the document. @param footnoteMacro the {{footnote}} macro being processed @param footnoteRef the generated block corresponding to the footnote to be inserted
[ "Add", "a", "footnote", "to", "the", "list", "of", "document", "footnotes", ".", "If", "such", "a", "list", "doesn", "t", "exist", "yet", "create", "it", "and", "append", "it", "to", "the", "end", "of", "the", "document", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/macro/footnote/PutFootnotesMacro.java#L175-L179
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/macro/footnote/PutFootnotesMacro.java
PutFootnotesMacro.createFootnoteBlock
private ListItemBlock createFootnoteBlock(String content, int counter, MacroTransformationContext context) throws MacroExecutionException { List<Block> parsedContent; try { parsedContent = this.contentParser.parse(content, context, false, true).getChildren(); } catch (MacroExecutionException e) { parsedContent = Collections.<Block>singletonList(new WordBlock(content)); } Block result = new WordBlock("^"); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteBackRef"); result = new ListItemBlock(Collections.singletonList(result)); result.addChild(new SpaceBlock()); result.addChildren(parsedContent); return (ListItemBlock) result; }
java
private ListItemBlock createFootnoteBlock(String content, int counter, MacroTransformationContext context) throws MacroExecutionException { List<Block> parsedContent; try { parsedContent = this.contentParser.parse(content, context, false, true).getChildren(); } catch (MacroExecutionException e) { parsedContent = Collections.<Block>singletonList(new WordBlock(content)); } Block result = new WordBlock("^"); DocumentResourceReference reference = new DocumentResourceReference(null); reference.setAnchor(FOOTNOTE_REFERENCE_ID_PREFIX + counter); result = new LinkBlock(Collections.singletonList(result), reference, false); result.setParameter(ID_ATTRIBUTE_NAME, FOOTNOTE_ID_PREFIX + counter); result.setParameter(CLASS_ATTRIBUTE_NAME, "footnoteBackRef"); result = new ListItemBlock(Collections.singletonList(result)); result.addChild(new SpaceBlock()); result.addChildren(parsedContent); return (ListItemBlock) result; }
[ "private", "ListItemBlock", "createFootnoteBlock", "(", "String", "content", ",", "int", "counter", ",", "MacroTransformationContext", "context", ")", "throws", "MacroExecutionException", "{", "List", "<", "Block", ">", "parsedContent", ";", "try", "{", "parsedContent...
Generate the footnote block, a numbered list item containing a backlink to the footnote's reference, and the actual footnote text, parsed into XDOM. @param content the string representation of the actual footnote text; the content of the macro @param counter the current footnote counter @param context the macro transformation context, used for obtaining the correct parser for parsing the content @return the generated footnote block @throws MacroExecutionException if parsing the content fails
[ "Generate", "the", "footnote", "block", "a", "numbered", "list", "item", "containing", "a", "backlink", "to", "the", "footnote", "s", "reference", "and", "the", "actual", "footnote", "text", "parsed", "into", "XDOM", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-footnotes/src/main/java/org/xwiki/rendering/internal/macro/footnote/PutFootnotesMacro.java#L210-L229
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java
WikiParameters.getParameters
public WikiParameter[] getParameters(String key) { Map<String, WikiParameter[]> map = getParameters(); WikiParameter[] list = map.get(key); return list; }
java
public WikiParameter[] getParameters(String key) { Map<String, WikiParameter[]> map = getParameters(); WikiParameter[] list = map.get(key); return list; }
[ "public", "WikiParameter", "[", "]", "getParameters", "(", "String", "key", ")", "{", "Map", "<", "String", ",", "WikiParameter", "[", "]", ">", "map", "=", "getParameters", "(", ")", ";", "WikiParameter", "[", "]", "list", "=", "map", ".", "get", "(",...
Returns all parameters with this key @param key the key of the parameter @return the wiki parameter by key
[ "Returns", "all", "parameters", "with", "this", "key" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java#L205-L210
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java
WikiParameters.toList
public List<WikiParameter> toList() { List<WikiParameter> result = new ArrayList<WikiParameter>(fList); return result; }
java
public List<WikiParameter> toList() { List<WikiParameter> result = new ArrayList<WikiParameter>(fList); return result; }
[ "public", "List", "<", "WikiParameter", ">", "toList", "(", ")", "{", "List", "<", "WikiParameter", ">", "result", "=", "new", "ArrayList", "<", "WikiParameter", ">", "(", "fList", ")", ";", "return", "result", ";", "}" ]
Returns a new list containing all parameters defined in this object. @return a list of all parameters
[ "Returns", "a", "new", "list", "containing", "all", "parameters", "defined", "in", "this", "object", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/WikiParameters.java#L264-L268
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/DocumentXHTMLLinkTypeRenderer.java
DocumentXHTMLLinkTypeRenderer.beginInternalLink
private void beginInternalLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters) { Map<String, String> spanAttributes = new LinkedHashMap<String, String>(); Map<String, String> anchorAttributes = new LinkedHashMap<String, String>(); // Add all parameters to the A attributes anchorAttributes.putAll(parameters); if (StringUtils.isEmpty(reference.getReference())) { spanAttributes.put(CLASS, WIKILINK); renderAutoLink(reference, spanAttributes, anchorAttributes); } else if (this.wikiModel.isDocumentAvailable(reference)) { spanAttributes.put(CLASS, WIKILINK); anchorAttributes.put(XHTMLLinkRenderer.HREF, this.wikiModel.getDocumentViewURL(reference)); } else { // The wiki document doesn't exist spanAttributes.put(CLASS, "wikicreatelink"); anchorAttributes.put(XHTMLLinkRenderer.HREF, this.wikiModel.getDocumentEditURL(reference)); } getXHTMLWikiPrinter().printXMLStartElement(SPAN, spanAttributes); getXHTMLWikiPrinter().printXMLStartElement(XHTMLLinkRenderer.ANCHOR, anchorAttributes); }
java
private void beginInternalLink(ResourceReference reference, boolean freestanding, Map<String, String> parameters) { Map<String, String> spanAttributes = new LinkedHashMap<String, String>(); Map<String, String> anchorAttributes = new LinkedHashMap<String, String>(); // Add all parameters to the A attributes anchorAttributes.putAll(parameters); if (StringUtils.isEmpty(reference.getReference())) { spanAttributes.put(CLASS, WIKILINK); renderAutoLink(reference, spanAttributes, anchorAttributes); } else if (this.wikiModel.isDocumentAvailable(reference)) { spanAttributes.put(CLASS, WIKILINK); anchorAttributes.put(XHTMLLinkRenderer.HREF, this.wikiModel.getDocumentViewURL(reference)); } else { // The wiki document doesn't exist spanAttributes.put(CLASS, "wikicreatelink"); anchorAttributes.put(XHTMLLinkRenderer.HREF, this.wikiModel.getDocumentEditURL(reference)); } getXHTMLWikiPrinter().printXMLStartElement(SPAN, spanAttributes); getXHTMLWikiPrinter().printXMLStartElement(XHTMLLinkRenderer.ANCHOR, anchorAttributes); }
[ "private", "void", "beginInternalLink", "(", "ResourceReference", "reference", ",", "boolean", "freestanding", ",", "Map", "<", "String", ",", "String", ">", "parameters", ")", "{", "Map", "<", "String", ",", "String", ">", "spanAttributes", "=", "new", "Linke...
Start of an internal link. @param reference the reference to the link @param freestanding if true then the link is a free standing URI directly in the text @param parameters a generic list of parameters. Example: style="background-color: blue"
[ "Start", "of", "an", "internal", "link", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-xhtml/src/main/java/org/xwiki/rendering/internal/renderer/xhtml/link/DocumentXHTMLLinkTypeRenderer.java#L113-L136
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-ctsreport/src/main/java/org/xwiki/rendering/internal/macro/ctsreport/ResultExtractor.java
ResultExtractor.normalize
public void normalize(Set<String> testNames, Map<String, Pair<Set<Test>, Set<Test>>> tests) { for (Pair<Set<Test>, Set<Test>> inOutTests : tests.values()) { addNotApplicableTests(testNames, inOutTests.getLeft()); addNotApplicableTests(testNames, inOutTests.getRight()); } }
java
public void normalize(Set<String> testNames, Map<String, Pair<Set<Test>, Set<Test>>> tests) { for (Pair<Set<Test>, Set<Test>> inOutTests : tests.values()) { addNotApplicableTests(testNames, inOutTests.getLeft()); addNotApplicableTests(testNames, inOutTests.getRight()); } }
[ "public", "void", "normalize", "(", "Set", "<", "String", ">", "testNames", ",", "Map", "<", "String", ",", "Pair", "<", "Set", "<", "Test", ">", ",", "Set", "<", "Test", ">", ">", ">", "tests", ")", "{", "for", "(", "Pair", "<", "Set", "<", "T...
Add not applicable tests for all syntaxes. @param testNames the test names (eg "simple/bold/bold1") @param tests the tests by syntaxes
[ "Add", "not", "applicable", "tests", "for", "all", "syntaxes", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-ctsreport/src/main/java/org/xwiki/rendering/internal/macro/ctsreport/ResultExtractor.java#L95-L101
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/syntax/SyntaxType.java
SyntaxType.register
private static SyntaxType register(String id, String name) { SyntaxType syntaxType = new SyntaxType(id, name); KNOWN_SYNTAX_TYPES.put(id, syntaxType); return syntaxType; }
java
private static SyntaxType register(String id, String name) { SyntaxType syntaxType = new SyntaxType(id, name); KNOWN_SYNTAX_TYPES.put(id, syntaxType); return syntaxType; }
[ "private", "static", "SyntaxType", "register", "(", "String", "id", ",", "String", "name", ")", "{", "SyntaxType", "syntaxType", "=", "new", "SyntaxType", "(", "id", ",", "name", ")", ";", "KNOWN_SYNTAX_TYPES", ".", "put", "(", "id", ",", "syntaxType", ")"...
Register a Syntax Type. @param id see {@link SyntaxType#SyntaxType(String, String)} @param name see {@link SyntaxType#SyntaxType(String, String)} @return the created Syntax Type object
[ "Register", "a", "Syntax", "Type", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/syntax/SyntaxType.java#L171-L176
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/InternalWikiScannerContext.java
InternalWikiScannerContext.onMacro
public void onMacro(String name, WikiParameters params, String content) { checkBlockContainer(); fMacroName = name; fMacroParameters = params; fMacroContent = content; }
java
public void onMacro(String name, WikiParameters params, String content) { checkBlockContainer(); fMacroName = name; fMacroParameters = params; fMacroContent = content; }
[ "public", "void", "onMacro", "(", "String", "name", ",", "WikiParameters", "params", ",", "String", "content", ")", "{", "checkBlockContainer", "(", ")", ";", "fMacroName", "=", "name", ";", "fMacroParameters", "=", "params", ";", "fMacroContent", "=", "conten...
Waiting for following events to know if the macro is inline or not.
[ "Waiting", "for", "following", "events", "to", "know", "if", "the", "macro", "is", "inline", "or", "not", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/InternalWikiScannerContext.java#L1013-L1020
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/InternalWikiScannerContext.java
InternalWikiScannerContext.onVerbatim
public void onVerbatim(String str, WikiParameters params) { checkBlockContainer(); fVerbatimContent = str; fVerbatimParameters = params; }
java
public void onVerbatim(String str, WikiParameters params) { checkBlockContainer(); fVerbatimContent = str; fVerbatimParameters = params; }
[ "public", "void", "onVerbatim", "(", "String", "str", ",", "WikiParameters", "params", ")", "{", "checkBlockContainer", "(", ")", ";", "fVerbatimContent", "=", "str", ";", "fVerbatimParameters", "=", "params", ";", "}" ]
Waiting for following events to know if the verbatim is inline or not.
[ "Waiting", "for", "following", "events", "to", "know", "if", "the", "verbatim", "is", "inline", "or", "not", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/impl/InternalWikiScannerContext.java#L1131-L1137
train
xwiki/xwiki-rendering
xwiki-rendering-macros/xwiki-rendering-macro-content/src/main/java/org/xwiki/rendering/internal/macro/content/ContentMacro.java
ContentMacro.getSyntaxParser
protected Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException { if (this.componentManager.hasComponent(Parser.class, syntax.toIdString())) { try { return this.componentManager.getInstance(Parser.class, syntax.toIdString()); } catch (ComponentLookupException e) { throw new MacroExecutionException( String.format("Failed to lookup Parser for syntax [%s]", syntax.toIdString()), e); } } else { throw new MacroExecutionException(String.format("Cannot find Parser for syntax [%s]", syntax.toIdString())); } }
java
protected Parser getSyntaxParser(Syntax syntax) throws MacroExecutionException { if (this.componentManager.hasComponent(Parser.class, syntax.toIdString())) { try { return this.componentManager.getInstance(Parser.class, syntax.toIdString()); } catch (ComponentLookupException e) { throw new MacroExecutionException( String.format("Failed to lookup Parser for syntax [%s]", syntax.toIdString()), e); } } else { throw new MacroExecutionException(String.format("Cannot find Parser for syntax [%s]", syntax.toIdString())); } }
[ "protected", "Parser", "getSyntaxParser", "(", "Syntax", "syntax", ")", "throws", "MacroExecutionException", "{", "if", "(", "this", ".", "componentManager", ".", "hasComponent", "(", "Parser", ".", "class", ",", "syntax", ".", "toIdString", "(", ")", ")", ")"...
Get the parser for the passed Syntax. @param syntax the Syntax for which to find the Parser @return the matching Parser that can be used to parse content in the passed Syntax @throws MacroExecutionException if there's no Parser in the system for the passed Syntax
[ "Get", "the", "parser", "for", "the", "passed", "Syntax", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-macros/xwiki-rendering-macro-content/src/main/java/org/xwiki/rendering/internal/macro/content/ContentMacro.java#L113-L125
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xwiki/xwiki20/XWikiReferenceParser.java
XWikiReferenceParser.parseReference
private void parseReference(char[] array, int i, StringBuffer reference, StringBuffer parameters) { int nb; for (boolean escaped = false; i < array.length; ++i) { char c = array[i]; if (!escaped) { if (array[i] == '~' && !escaped) { escaped = true; } else if ((nb = countFirstChar(array, i, '|')) >= 2) { for (; nb > 2; --nb) { reference.append(array[i++]); } i += 2; parameters.append(array, i, array.length - i); break; } else { reference.append(c); } } else { reference.append(c); escaped = false; } } }
java
private void parseReference(char[] array, int i, StringBuffer reference, StringBuffer parameters) { int nb; for (boolean escaped = false; i < array.length; ++i) { char c = array[i]; if (!escaped) { if (array[i] == '~' && !escaped) { escaped = true; } else if ((nb = countFirstChar(array, i, '|')) >= 2) { for (; nb > 2; --nb) { reference.append(array[i++]); } i += 2; parameters.append(array, i, array.length - i); break; } else { reference.append(c); } } else { reference.append(c); escaped = false; } } }
[ "private", "void", "parseReference", "(", "char", "[", "]", "array", ",", "int", "i", ",", "StringBuffer", "reference", ",", "StringBuffer", "parameters", ")", "{", "int", "nb", ";", "for", "(", "boolean", "escaped", "=", "false", ";", "i", "<", "array",...
Extract the link and the parameters. @param array the array to extract information from @param i the current position in the array @param reference the link buffer to fill @param parameters the parameters buffer to fill
[ "Extract", "the", "link", "and", "the", "parameters", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xwiki/xwiki20/XWikiReferenceParser.java#L161-L187
train
xwiki/xwiki-rendering
xwiki-rendering-xml/src/main/java/org/xwiki/rendering/renderer/printer/XMLWikiPrinter.java
XMLWikiPrinter.printXMLComment
public void printXMLComment(String content, boolean escape) { try { this.xmlWriter.write(new DefaultComment(escape ? XMLUtils.escapeXMLComment(content) : content)); } catch (IOException e) { // TODO: add error log here } }
java
public void printXMLComment(String content, boolean escape) { try { this.xmlWriter.write(new DefaultComment(escape ? XMLUtils.escapeXMLComment(content) : content)); } catch (IOException e) { // TODO: add error log here } }
[ "public", "void", "printXMLComment", "(", "String", "content", ",", "boolean", "escape", ")", "{", "try", "{", "this", ".", "xmlWriter", ".", "write", "(", "new", "DefaultComment", "(", "escape", "?", "XMLUtils", ".", "escapeXMLComment", "(", "content", ")",...
Print a XML comment. @param content the comment content @param escape indicate if comment content has to be escaped. XML content does not support -- and - (when it's the last character). Escaping is based on backslash. "- --\ -" give "- \-\-\\ \-\ ".
[ "Print", "a", "XML", "comment", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-xml/src/main/java/org/xwiki/rendering/renderer/printer/XMLWikiPrinter.java#L219-L226
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/QueueListener.java
QueueListener.getEvent
public Event getEvent(int depth) { Event event = null; if (depth > 0 && size() > depth - 1) { event = get(depth - 1); } return event; }
java
public Event getEvent(int depth) { Event event = null; if (depth > 0 && size() > depth - 1) { event = get(depth - 1); } return event; }
[ "public", "Event", "getEvent", "(", "int", "depth", ")", "{", "Event", "event", "=", "null", ";", "if", "(", "depth", ">", "0", "&&", "size", "(", ")", ">", "depth", "-", "1", ")", "{", "event", "=", "get", "(", "depth", "-", "1", ")", ";", "...
Returns the event at the specified position in this queue. @param depth index of event to return. @return the evnet at the specified position in this queue.
[ "Returns", "the", "event", "at", "the", "specified", "position", "in", "this", "queue", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/QueueListener.java#L76-L85
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-doxia/src/main/java/org/xwiki/rendering/internal/renderer/doxia/DoxiaListener.java
DoxiaListener.popListener
private Listener popListener() { Listener listener = this.listenerStack.pop(); if (!this.listenerStack.isEmpty()) { setWrappedListener(this.listenerStack.peek()); } return listener; }
java
private Listener popListener() { Listener listener = this.listenerStack.pop(); if (!this.listenerStack.isEmpty()) { setWrappedListener(this.listenerStack.peek()); } return listener; }
[ "private", "Listener", "popListener", "(", ")", "{", "Listener", "listener", "=", "this", ".", "listenerStack", ".", "pop", "(", ")", ";", "if", "(", "!", "this", ".", "listenerStack", ".", "isEmpty", "(", ")", ")", "{", "setWrappedListener", "(", "this"...
Removes the last listener from the stack. @return the last listener that has been removed from the stack
[ "Removes", "the", "last", "listener", "from", "the", "stack", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-doxia/src/main/java/org/xwiki/rendering/internal/renderer/doxia/DoxiaListener.java#L157-L164
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java
HtmlEntityUtil.getChar
public static char getChar(String symbol) { CharInfo info = (CharInfo) fSymbolMap.get(symbol); return (info != null) ? (char) info.fCode : '\0'; }
java
public static char getChar(String symbol) { CharInfo info = (CharInfo) fSymbolMap.get(symbol); return (info != null) ? (char) info.fCode : '\0'; }
[ "public", "static", "char", "getChar", "(", "String", "symbol", ")", "{", "CharInfo", "info", "=", "(", "CharInfo", ")", "fSymbolMap", ".", "get", "(", "symbol", ")", ";", "return", "(", "info", "!=", "null", ")", "?", "(", "char", ")", "info", ".", ...
A character corresponding to the given symbol. @param symbol for this symbol the corresponding character will be returned @return a character corresponding to the given symbol
[ "A", "character", "corresponding", "to", "the", "given", "symbol", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java#L459-L463
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java
HtmlEntityUtil.getDescription
public static String getDescription(char ch) { CharInfo info = (CharInfo) fCodeMap.get(Integer.valueOf(ch)); return (info != null) ? info.fDescription : null; }
java
public static String getDescription(char ch) { CharInfo info = (CharInfo) fCodeMap.get(Integer.valueOf(ch)); return (info != null) ? info.fDescription : null; }
[ "public", "static", "String", "getDescription", "(", "char", "ch", ")", "{", "CharInfo", "info", "=", "(", "CharInfo", ")", "fCodeMap", ".", "get", "(", "Integer", ".", "valueOf", "(", "ch", ")", ")", ";", "return", "(", "info", "!=", "null", ")", "?...
Returns description of the given character @param ch for this character the corresponding description will be returned @return description of the given character
[ "Returns", "description", "of", "the", "given", "character" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java#L472-L476
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java
HtmlEntityUtil.getDescription
public static String getDescription(String symbol) { CharInfo info = (CharInfo) fSymbolMap.get(symbol); return (info != null) ? info.fDescription : null; }
java
public static String getDescription(String symbol) { CharInfo info = (CharInfo) fSymbolMap.get(symbol); return (info != null) ? info.fDescription : null; }
[ "public", "static", "String", "getDescription", "(", "String", "symbol", ")", "{", "CharInfo", "info", "=", "(", "CharInfo", ")", "fSymbolMap", ".", "get", "(", "symbol", ")", ";", "return", "(", "info", "!=", "null", ")", "?", "info", ".", "fDescription...
Returns description of the given symbol. @param symbol for this symbol the corresponding description will be returned @return description of the given symbol
[ "Returns", "description", "of", "the", "given", "symbol", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/util/HtmlEntityUtil.java#L485-L489
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/transformation/macro/MacroErrorManager.java
MacroErrorManager.generateError
public void generateError(MacroBlock macroToReplace, String message, Throwable throwable) { List<Block> errorBlocks = this.errorBlockGenerator.generateErrorBlocks(message, throwable, macroToReplace.isInline()); macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
java
public void generateError(MacroBlock macroToReplace, String message, Throwable throwable) { List<Block> errorBlocks = this.errorBlockGenerator.generateErrorBlocks(message, throwable, macroToReplace.isInline()); macroToReplace.getParent().replaceChild(wrapInMacroMarker(macroToReplace, errorBlocks), macroToReplace); }
[ "public", "void", "generateError", "(", "MacroBlock", "macroToReplace", ",", "String", "message", ",", "Throwable", "throwable", ")", "{", "List", "<", "Block", ">", "errorBlocks", "=", "this", ".", "errorBlockGenerator", ".", "generateErrorBlocks", "(", "message"...
Generates Blocks to signify that the passed Macro Block has failed to execute. @param macroToReplace the block for the macro that failed to execute and that we'll replace with Block showing to the user that macro has failed @param message the message to display to the user in place of the macro result @param throwable the exception for the failed macro execution to display to the user in place of the macro result
[ "Generates", "Blocks", "to", "signify", "that", "the", "passed", "Macro", "Block", "has", "failed", "to", "execute", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-macro/src/main/java/org/xwiki/rendering/internal/transformation/macro/MacroErrorManager.java#L75-L80
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java
IconTransformation.mergeTree
private void mergeTree(Block targetTree, Block sourceTree) { for (Block block : sourceTree.getChildren()) { // Check if the current block exists in the target tree at the same place in the tree int pos = indexOf(targetTree.getChildren(), block); if (pos > -1) { Block foundBlock = targetTree.getChildren().get(pos); mergeTree(foundBlock, block); } else { targetTree.addChild(block); } } }
java
private void mergeTree(Block targetTree, Block sourceTree) { for (Block block : sourceTree.getChildren()) { // Check if the current block exists in the target tree at the same place in the tree int pos = indexOf(targetTree.getChildren(), block); if (pos > -1) { Block foundBlock = targetTree.getChildren().get(pos); mergeTree(foundBlock, block); } else { targetTree.addChild(block); } } }
[ "private", "void", "mergeTree", "(", "Block", "targetTree", ",", "Block", "sourceTree", ")", "{", "for", "(", "Block", "block", ":", "sourceTree", ".", "getChildren", "(", ")", ")", "{", "// Check if the current block exists in the target tree at the same place in the t...
Merged two XDOM trees. @param targetTree the tree to merge into @param sourceTree the tree to merge
[ "Merged", "two", "XDOM", "trees", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java#L155-L167
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java
IconTransformation.indexOf
private int indexOf(List<Block> targetBlocks, Block block) { int pos = 0; for (Block targetBlock : targetBlocks) { // Test a non deep equality if (blockEquals(targetBlock, block)) { return pos; } pos++; } return -1; }
java
private int indexOf(List<Block> targetBlocks, Block block) { int pos = 0; for (Block targetBlock : targetBlocks) { // Test a non deep equality if (blockEquals(targetBlock, block)) { return pos; } pos++; } return -1; }
[ "private", "int", "indexOf", "(", "List", "<", "Block", ">", "targetBlocks", ",", "Block", "block", ")", "{", "int", "pos", "=", "0", ";", "for", "(", "Block", "targetBlock", ":", "targetBlocks", ")", "{", "// Test a non deep equality", "if", "(", "blockEq...
Shallow indexOf implementation that only compares nodes based on their data and not their children data. @param targetBlocks the list of blocks to look into @param block the block to look for in the list of passed blocks @return the position of the block in the list of target blocks and -1 if not found
[ "Shallow", "indexOf", "implementation", "that", "only", "compares", "nodes", "based", "on", "their", "data", "and", "not", "their", "children", "data", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java#L176-L187
train
xwiki/xwiki-rendering
xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java
IconTransformation.parseTree
private void parseTree(List<Block> sourceBlocks) { Block matchStartBlock = null; int count = 0; Block mappingCursor = this.mappingTree.getChildren().get(0); Block sourceBlock = sourceBlocks.get(0); while (sourceBlock != null) { while (mappingCursor != null) { if (blockEquals(sourceBlock, mappingCursor)) { if (matchStartBlock == null) { matchStartBlock = sourceBlock; } count++; mappingCursor = mappingCursor.getChildren().get(0); // If we reach the Image Block then we've found a match! if (mappingCursor instanceof ImageBlock) { // Replace the first source block with the image block and remove all other blocks... for (int i = 0; i < count - 1; i++) { matchStartBlock.getParent().removeBlock(matchStartBlock.getNextSibling()); } sourceBlock = mappingCursor.clone(); matchStartBlock.getParent().replaceChild(sourceBlock, matchStartBlock); mappingCursor = null; matchStartBlock = null; count = 0; } else { // Look for next block match break; } } else { mappingCursor = mappingCursor.getNextSibling(); } } // Look for a match in children of the source block List<Block> filteredSourceBlocks = this.filter.filter(sourceBlock.getChildren()); if (!filteredSourceBlocks.isEmpty()) { parseTree(filteredSourceBlocks); } else if (mappingCursor == null) { // No match has been found, reset state variables mappingCursor = this.mappingTree.getChildren().get(0); count = 0; matchStartBlock = null; } sourceBlock = this.filter.getNextSibling(sourceBlock); } }
java
private void parseTree(List<Block> sourceBlocks) { Block matchStartBlock = null; int count = 0; Block mappingCursor = this.mappingTree.getChildren().get(0); Block sourceBlock = sourceBlocks.get(0); while (sourceBlock != null) { while (mappingCursor != null) { if (blockEquals(sourceBlock, mappingCursor)) { if (matchStartBlock == null) { matchStartBlock = sourceBlock; } count++; mappingCursor = mappingCursor.getChildren().get(0); // If we reach the Image Block then we've found a match! if (mappingCursor instanceof ImageBlock) { // Replace the first source block with the image block and remove all other blocks... for (int i = 0; i < count - 1; i++) { matchStartBlock.getParent().removeBlock(matchStartBlock.getNextSibling()); } sourceBlock = mappingCursor.clone(); matchStartBlock.getParent().replaceChild(sourceBlock, matchStartBlock); mappingCursor = null; matchStartBlock = null; count = 0; } else { // Look for next block match break; } } else { mappingCursor = mappingCursor.getNextSibling(); } } // Look for a match in children of the source block List<Block> filteredSourceBlocks = this.filter.filter(sourceBlock.getChildren()); if (!filteredSourceBlocks.isEmpty()) { parseTree(filteredSourceBlocks); } else if (mappingCursor == null) { // No match has been found, reset state variables mappingCursor = this.mappingTree.getChildren().get(0); count = 0; matchStartBlock = null; } sourceBlock = this.filter.getNextSibling(sourceBlock); } }
[ "private", "void", "parseTree", "(", "List", "<", "Block", ">", "sourceBlocks", ")", "{", "Block", "matchStartBlock", "=", "null", ";", "int", "count", "=", "0", ";", "Block", "mappingCursor", "=", "this", ".", "mappingTree", ".", "getChildren", "(", ")", ...
Parse a list of blocks and replace suite of Blocks matching the icon mapping definitions by image blocks. @param sourceBlocks the blocks to parse
[ "Parse", "a", "list", "of", "blocks", "and", "replace", "suite", "of", "Blocks", "matching", "the", "icon", "mapping", "definitions", "by", "image", "blocks", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-transformations/xwiki-rendering-transformation-icon/src/main/java/org/xwiki/rendering/internal/transformation/icon/IconTransformation.java#L218-L263
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java
ImageUtil.createThumb
private static BufferedImage createThumb( BufferedImage image, int thumbWidth, int thumbHeight) { int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); int[] size = getNewSize( imageWidth, imageHeight, thumbWidth, thumbHeight); if (size[0] == imageWidth && size[1] == imageHeight) { return image; } BufferedImage thumbImage = new BufferedImage( size[0], size[1], BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = thumbImage.createGraphics(); graphics2D.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null); return thumbImage; }
java
private static BufferedImage createThumb( BufferedImage image, int thumbWidth, int thumbHeight) { int imageWidth = image.getWidth(null); int imageHeight = image.getHeight(null); int[] size = getNewSize( imageWidth, imageHeight, thumbWidth, thumbHeight); if (size[0] == imageWidth && size[1] == imageHeight) { return image; } BufferedImage thumbImage = new BufferedImage( size[0], size[1], BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D = thumbImage.createGraphics(); graphics2D.setRenderingHint( RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(image, 0, 0, thumbWidth, thumbHeight, null); return thumbImage; }
[ "private", "static", "BufferedImage", "createThumb", "(", "BufferedImage", "image", ",", "int", "thumbWidth", ",", "int", "thumbHeight", ")", "{", "int", "imageWidth", "=", "image", ".", "getWidth", "(", "null", ")", ";", "int", "imageHeight", "=", "image", ...
Creates a smaller version of an image or returns the original image if it was in the specified boundaries. The returned image keeps the ratio of the original image. @param image the image to re-size @param thumbWidth the maximal width of the image @param thumbHeight the maximal height of the image @return a new re-sized image or the original image if it was in the specified boundaries
[ "Creates", "a", "smaller", "version", "of", "an", "image", "or", "returns", "the", "original", "image", "if", "it", "was", "in", "the", "specified", "boundaries", ".", "The", "returned", "image", "keeps", "the", "ratio", "of", "the", "original", "image", "...
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java#L52-L78
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java
ImageUtil.getImageSize
public static int[] getImageSize( InputStream input, int maxWidth, int maxHeight) throws IOException { int[] size = getImageSize(input); return getNewSize(size[0], size[1], maxWidth, maxHeight); }
java
public static int[] getImageSize( InputStream input, int maxWidth, int maxHeight) throws IOException { int[] size = getImageSize(input); return getNewSize(size[0], size[1], maxWidth, maxHeight); }
[ "public", "static", "int", "[", "]", "getImageSize", "(", "InputStream", "input", ",", "int", "maxWidth", ",", "int", "maxHeight", ")", "throws", "IOException", "{", "int", "[", "]", "size", "=", "getImageSize", "(", "input", ")", ";", "return", "getNewSiz...
Returns the possible size of an image from the given input stream; the returned size does not overcome the specified maximal borders but keeps the ratio of the image. This method closes the given stream. @param input the input stream with an image @param maxWidth the maximal width @param maxHeight the maximal height @return the possible size of an image from the given input stream; the returned size does not overcome the specified maximal borders but keeps the ratio of the image
[ "Returns", "the", "possible", "size", "of", "an", "image", "from", "the", "given", "input", "stream", ";", "the", "returned", "size", "does", "not", "overcome", "the", "specified", "maximal", "borders", "but", "keeps", "the", "ratio", "of", "the", "image", ...
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java#L153-L160
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java
ImageUtil.getNewSize
public static int[] getNewSize( int width, int height, int maxWidth, int maxHeight) { if (width <= maxWidth && height <= maxHeight) { return new int[]{width, height}; } double thumbRatio = (double) maxWidth / (double) maxHeight; double imageRatio = (double) width / (double) height; if (thumbRatio < imageRatio) { maxHeight = (int) (maxWidth / imageRatio); } else { maxWidth = (int) (maxHeight * imageRatio); } return new int[]{maxWidth, maxHeight}; }
java
public static int[] getNewSize( int width, int height, int maxWidth, int maxHeight) { if (width <= maxWidth && height <= maxHeight) { return new int[]{width, height}; } double thumbRatio = (double) maxWidth / (double) maxHeight; double imageRatio = (double) width / (double) height; if (thumbRatio < imageRatio) { maxHeight = (int) (maxWidth / imageRatio); } else { maxWidth = (int) (maxHeight * imageRatio); } return new int[]{maxWidth, maxHeight}; }
[ "public", "static", "int", "[", "]", "getNewSize", "(", "int", "width", ",", "int", "height", ",", "int", "maxWidth", ",", "int", "maxHeight", ")", "{", "if", "(", "width", "<=", "maxWidth", "&&", "height", "<=", "maxHeight", ")", "{", "return", "new",...
Calculates new size of an image with the specified max borders keeping the ratio between height and width of the image. @param width the initial width of an image @param height the initial height of an image @param maxWidth the maximal width of an image @param maxHeight the maximal height of an image @return a new size of an image where the height and width don't overcome the specified borders; the size keeps the initial image ratio between width and height
[ "Calculates", "new", "size", "of", "an", "image", "with", "the", "specified", "max", "borders", "keeping", "the", "ratio", "between", "height", "and", "width", "of", "the", "image", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/images/ImageUtil.java#L174-L191
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/XDOMBuilder.java
XDOMBuilder.addBlock
public void addBlock(Block block) { try { this.stack.getFirst().add(block); } catch (NoSuchElementException e) { throw new IllegalStateException("All container blocks are closed, too many calls to endBlockList()."); } }
java
public void addBlock(Block block) { try { this.stack.getFirst().add(block); } catch (NoSuchElementException e) { throw new IllegalStateException("All container blocks are closed, too many calls to endBlockList()."); } }
[ "public", "void", "addBlock", "(", "Block", "block", ")", "{", "try", "{", "this", ".", "stack", ".", "getFirst", "(", ")", ".", "add", "(", "block", ")", ";", "}", "catch", "(", "NoSuchElementException", "e", ")", "{", "throw", "new", "IllegalStateExc...
Add a block to the current block container. @param block the block to be added.
[ "Add", "a", "block", "to", "the", "current", "block", "container", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/XDOMBuilder.java#L97-L104
train
xwiki/xwiki-rendering
xwiki-rendering-syntaxes/xwiki-rendering-syntax-plain/src/main/java/org/xwiki/rendering/internal/parser/plain/PlainTextStreamParser.java
PlainTextStreamParser.readChar
private int readChar(Reader source) throws ParseException { int c; try { c = source.read(); } catch (IOException e) { throw new ParseException("Failed to read input source", e); } return c; }
java
private int readChar(Reader source) throws ParseException { int c; try { c = source.read(); } catch (IOException e) { throw new ParseException("Failed to read input source", e); } return c; }
[ "private", "int", "readChar", "(", "Reader", "source", ")", "throws", "ParseException", "{", "int", "c", ";", "try", "{", "c", "=", "source", ".", "read", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "throw", "new", "ParseException",...
Read a single char from an Reader source. @param source the input to read from @return the char read @throws ParseException in case of reading error
[ "Read", "a", "single", "char", "from", "an", "Reader", "source", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-syntaxes/xwiki-rendering-syntax-plain/src/main/java/org/xwiki/rendering/internal/parser/plain/PlainTextStreamParser.java#L67-L78
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java
GenericLinkReferenceParser.parseDocumentLink
private ResourceReference parseDocumentLink(StringBuilder content) { // Extract any query string. String queryString = null; String text = parseElementAfterString(content, SEPARATOR_QUERYSTRING); if (text != null) { queryString = removeEscapesFromExtraParts(text); } // Extract any anchor. String anchor = null; text = parseElementAfterString(content, SEPARATOR_ANCHOR); if (text != null) { anchor = removeEscapesFromExtraParts(text); } // Make sure to unescape the remaining reference string. String unescapedReferenceString = removeEscapesFromReferencePart(content.toString()); // Parse the string as an untyped link reference. ResourceReference reference = untypedLinkReferenceParser.parse(unescapedReferenceString); reference.setTyped(false); // Set any previously extracted parameters. if (StringUtils.isNotBlank(queryString)) { reference.setParameter(DocumentResourceReference.QUERY_STRING, queryString); } if (StringUtils.isNotBlank(anchor)) { reference.setParameter(DocumentResourceReference.ANCHOR, anchor); } return reference; }
java
private ResourceReference parseDocumentLink(StringBuilder content) { // Extract any query string. String queryString = null; String text = parseElementAfterString(content, SEPARATOR_QUERYSTRING); if (text != null) { queryString = removeEscapesFromExtraParts(text); } // Extract any anchor. String anchor = null; text = parseElementAfterString(content, SEPARATOR_ANCHOR); if (text != null) { anchor = removeEscapesFromExtraParts(text); } // Make sure to unescape the remaining reference string. String unescapedReferenceString = removeEscapesFromReferencePart(content.toString()); // Parse the string as an untyped link reference. ResourceReference reference = untypedLinkReferenceParser.parse(unescapedReferenceString); reference.setTyped(false); // Set any previously extracted parameters. if (StringUtils.isNotBlank(queryString)) { reference.setParameter(DocumentResourceReference.QUERY_STRING, queryString); } if (StringUtils.isNotBlank(anchor)) { reference.setParameter(DocumentResourceReference.ANCHOR, anchor); } return reference; }
[ "private", "ResourceReference", "parseDocumentLink", "(", "StringBuilder", "content", ")", "{", "// Extract any query string.", "String", "queryString", "=", "null", ";", "String", "text", "=", "parseElementAfterString", "(", "content", ",", "SEPARATOR_QUERYSTRING", ")", ...
Construct a Document Link reference out of the passed content. @param content the string containing the Document link reference @return the parsed Link Object corresponding to the Document link reference
[ "Construct", "a", "Document", "Link", "reference", "out", "of", "the", "passed", "content", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java#L165-L196
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java
GenericLinkReferenceParser.parseURILinks
private ResourceReference parseURILinks(String rawLink) { ResourceReference result = null; int uriSchemeDelimiterPos = rawLink.indexOf(':'); if (uriSchemeDelimiterPos > -1) { String scheme = rawLink.substring(0, uriSchemeDelimiterPos); String reference = rawLink.substring(uriSchemeDelimiterPos + 1); if (getAllowedURIPrefixes().contains(scheme)) { try { ResourceReferenceTypeParser parser = this.componentManagerProvider.get().getInstance(ResourceReferenceTypeParser.class, scheme); ResourceReference resourceReference = parser.parse(reference); if (resourceReference != null) { result = resourceReference; } } catch (ComponentLookupException e) { // Failed to lookup component, this shouldn't happen but ignore it. } } else { // Check if it's a URL ResourceReference resourceReference = this.urlResourceReferenceTypeParser.parse(rawLink); if (resourceReference != null) { resourceReference.setTyped(false); result = resourceReference; } } } return result; }
java
private ResourceReference parseURILinks(String rawLink) { ResourceReference result = null; int uriSchemeDelimiterPos = rawLink.indexOf(':'); if (uriSchemeDelimiterPos > -1) { String scheme = rawLink.substring(0, uriSchemeDelimiterPos); String reference = rawLink.substring(uriSchemeDelimiterPos + 1); if (getAllowedURIPrefixes().contains(scheme)) { try { ResourceReferenceTypeParser parser = this.componentManagerProvider.get().getInstance(ResourceReferenceTypeParser.class, scheme); ResourceReference resourceReference = parser.parse(reference); if (resourceReference != null) { result = resourceReference; } } catch (ComponentLookupException e) { // Failed to lookup component, this shouldn't happen but ignore it. } } else { // Check if it's a URL ResourceReference resourceReference = this.urlResourceReferenceTypeParser.parse(rawLink); if (resourceReference != null) { resourceReference.setTyped(false); result = resourceReference; } } } return result; }
[ "private", "ResourceReference", "parseURILinks", "(", "String", "rawLink", ")", "{", "ResourceReference", "result", "=", "null", ";", "int", "uriSchemeDelimiterPos", "=", "rawLink", ".", "indexOf", "(", "'", "'", ")", ";", "if", "(", "uriSchemeDelimiterPos", ">"...
Check if the passed link references is an URI link reference. @param rawLink the original reference to parse @return the parsed Link object or null if the passed reference is not an URI link reference or if no URI type parser was found for the passed URI scheme
[ "Check", "if", "the", "passed", "link", "references", "is", "an", "URI", "link", "reference", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java#L205-L233
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java
GenericLinkReferenceParser.parseInterWikiLinks
private ResourceReference parseInterWikiLinks(StringBuilder content) { ResourceReference result = null; String interWikiAlias = parseElementAfterString(content, SEPARATOR_INTERWIKI); if (interWikiAlias != null) { InterWikiResourceReference link = new InterWikiResourceReference(removeEscapes(content.toString())); link.setInterWikiAlias(removeEscapes(interWikiAlias)); result = link; } return result; }
java
private ResourceReference parseInterWikiLinks(StringBuilder content) { ResourceReference result = null; String interWikiAlias = parseElementAfterString(content, SEPARATOR_INTERWIKI); if (interWikiAlias != null) { InterWikiResourceReference link = new InterWikiResourceReference(removeEscapes(content.toString())); link.setInterWikiAlias(removeEscapes(interWikiAlias)); result = link; } return result; }
[ "private", "ResourceReference", "parseInterWikiLinks", "(", "StringBuilder", "content", ")", "{", "ResourceReference", "result", "=", "null", ";", "String", "interWikiAlias", "=", "parseElementAfterString", "(", "content", ",", "SEPARATOR_INTERWIKI", ")", ";", "if", "...
Check if the passed link references is an interwiki link reference. @param content the original content to parse @return the parsed Link object or null if the passed reference is not an interwiki link reference
[ "Check", "if", "the", "passed", "link", "references", "is", "an", "interwiki", "link", "reference", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java#L241-L251
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java
GenericLinkReferenceParser.parseElementAfterString
protected String parseElementAfterString(StringBuilder content, String separator) { String element = null; // Find the first non escaped separator (starting from the end of the content buffer). int index = content.lastIndexOf(separator); while (index != -1) { // Check if the element is found and it's not escaped. if (!shouldEscape(content, index)) { element = content.substring(index + separator.length()).trim(); content.delete(index, content.length()); break; } if (index > 0) { index = content.lastIndexOf(separator, index - 1); } else { break; } } return element; }
java
protected String parseElementAfterString(StringBuilder content, String separator) { String element = null; // Find the first non escaped separator (starting from the end of the content buffer). int index = content.lastIndexOf(separator); while (index != -1) { // Check if the element is found and it's not escaped. if (!shouldEscape(content, index)) { element = content.substring(index + separator.length()).trim(); content.delete(index, content.length()); break; } if (index > 0) { index = content.lastIndexOf(separator, index - 1); } else { break; } } return element; }
[ "protected", "String", "parseElementAfterString", "(", "StringBuilder", "content", ",", "String", "separator", ")", "{", "String", "element", "=", "null", ";", "// Find the first non escaped separator (starting from the end of the content buffer).", "int", "index", "=", "cont...
Find out the element located to the right of the passed separator. @param content the string to parse. This parameter will be modified by the method to remove the parsed content. @param separator the separator string to locate the element @return the parsed element or null if the separator string wasn't found
[ "Find", "out", "the", "element", "located", "to", "the", "right", "of", "the", "passed", "separator", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java#L260-L282
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java
GenericLinkReferenceParser.shouldEscape
private boolean shouldEscape(StringBuilder content, int charPosition) { int counter = 0; int pos = charPosition - 1; while (pos > -1 && content.charAt(pos) == ESCAPE_CHAR) { counter++; pos--; } return counter % 2 != 0; }
java
private boolean shouldEscape(StringBuilder content, int charPosition) { int counter = 0; int pos = charPosition - 1; while (pos > -1 && content.charAt(pos) == ESCAPE_CHAR) { counter++; pos--; } return counter % 2 != 0; }
[ "private", "boolean", "shouldEscape", "(", "StringBuilder", "content", ",", "int", "charPosition", ")", "{", "int", "counter", "=", "0", ";", "int", "pos", "=", "charPosition", "-", "1", ";", "while", "(", "pos", ">", "-", "1", "&&", "content", ".", "c...
Count the number of escape chars before a given character and if that number is odd then that character should be escaped. @param content the content in which to check for escapes @param charPosition the position of the char for which to decide if it should be escaped or not @return true if the character should be escaped
[ "Count", "the", "number", "of", "escape", "chars", "before", "a", "given", "character", "and", "if", "that", "number", "is", "odd", "then", "that", "character", "should", "be", "escaped", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/internal/parser/reference/GenericLinkReferenceParser.java#L292-L301
train
xwiki/xwiki-rendering
xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/impl/XhtmlHandler.java
XhtmlHandler.comment
public void comment(char[] array, int start, int length) throws SAXException { fStack.onComment(array, start, length); }
java
public void comment(char[] array, int start, int length) throws SAXException { fStack.onComment(array, start, length); }
[ "public", "void", "comment", "(", "char", "[", "]", "array", ",", "int", "start", ",", "int", "length", ")", "throws", "SAXException", "{", "fStack", ".", "onComment", "(", "array", ",", "start", ",", "length", ")", ";", "}" ]
Lexical handler methods
[ "Lexical", "handler", "methods" ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-wikimodel/src/main/java/org/xwiki/rendering/wikimodel/xhtml/impl/XhtmlHandler.java#L231-L235
train
xwiki/xwiki-rendering
xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/chaining/ListenerChain.java
ListenerChain.popListener
public void popListener(Class<? extends ChainingListener> listenerClass) { if (StackableChainingListener.class.isAssignableFrom(listenerClass)) { this.listeners.get(listenerClass).pop(); } }
java
public void popListener(Class<? extends ChainingListener> listenerClass) { if (StackableChainingListener.class.isAssignableFrom(listenerClass)) { this.listeners.get(listenerClass).pop(); } }
[ "public", "void", "popListener", "(", "Class", "<", "?", "extends", "ChainingListener", ">", "listenerClass", ")", "{", "if", "(", "StackableChainingListener", ".", "class", ".", "isAssignableFrom", "(", "listenerClass", ")", ")", "{", "this", ".", "listeners", ...
Remove the last instance corresponding to the passed listener class if it's stackable, in order to go back to the previous state. @param listenerClass the class of the chaining listener to pop
[ "Remove", "the", "last", "instance", "corresponding", "to", "the", "passed", "listener", "class", "if", "it", "s", "stackable", "in", "order", "to", "go", "back", "to", "the", "previous", "state", "." ]
a21cdfcb64ef5b76872e3eedf78c530f26d7beb0
https://github.com/xwiki/xwiki-rendering/blob/a21cdfcb64ef5b76872e3eedf78c530f26d7beb0/xwiki-rendering-api/src/main/java/org/xwiki/rendering/listener/chaining/ListenerChain.java#L179-L184
train
authlete/authlete-java-common
src/main/java/com/authlete/common/dto/Service.java
Service.setSupportedServiceProfiles
public Service setSupportedServiceProfiles(Iterable<ServiceProfile> profiles) { if (profiles == null) { this.supportedServiceProfiles = null; return this; } Set<ServiceProfile> set = new TreeSet<ServiceProfile>(); for (ServiceProfile profile : profiles) { if (profile != null) { set.add(profile); } } int size = set.size(); if (size == 0) { this.supportedServiceProfiles = null; return this; } ServiceProfile[] array = new ServiceProfile[size]; this.supportedServiceProfiles = set.toArray(array); return this; }
java
public Service setSupportedServiceProfiles(Iterable<ServiceProfile> profiles) { if (profiles == null) { this.supportedServiceProfiles = null; return this; } Set<ServiceProfile> set = new TreeSet<ServiceProfile>(); for (ServiceProfile profile : profiles) { if (profile != null) { set.add(profile); } } int size = set.size(); if (size == 0) { this.supportedServiceProfiles = null; return this; } ServiceProfile[] array = new ServiceProfile[size]; this.supportedServiceProfiles = set.toArray(array); return this; }
[ "public", "Service", "setSupportedServiceProfiles", "(", "Iterable", "<", "ServiceProfile", ">", "profiles", ")", "{", "if", "(", "profiles", "==", "null", ")", "{", "this", ".", "supportedServiceProfiles", "=", "null", ";", "return", "this", ";", "}", "Set", ...
Set the supported service profiles. @param profiles Supported service profiles. @return {@code this} object. @since 2.12
[ "Set", "the", "supported", "service", "profiles", "." ]
49c94c483713cbf5a04d805ff7dbd83766c9c964
https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/dto/Service.java#L2795-L2827
train
authlete/authlete-java-common
src/main/java/com/authlete/common/dto/Service.java
Service.supports
public boolean supports(ServiceProfile profile) { if (profile == null) { return false; } if (supportedServiceProfiles == null) { return false; } for (ServiceProfile supportedProfile : supportedServiceProfiles) { if (supportedProfile == profile) { return true; } } return false; }
java
public boolean supports(ServiceProfile profile) { if (profile == null) { return false; } if (supportedServiceProfiles == null) { return false; } for (ServiceProfile supportedProfile : supportedServiceProfiles) { if (supportedProfile == profile) { return true; } } return false; }
[ "public", "boolean", "supports", "(", "ServiceProfile", "profile", ")", "{", "if", "(", "profile", "==", "null", ")", "{", "return", "false", ";", "}", "if", "(", "supportedServiceProfiles", "==", "null", ")", "{", "return", "false", ";", "}", "for", "("...
Check if this service supports the specified profile. If {@code null} is given, {@code false} is returned. If the supported service profiles are not set to this service, {@code false} is returned. @param profile A service profile. @return {@code true} if this service supports the service profile. @since 2.12
[ "Check", "if", "this", "service", "supports", "the", "specified", "profile", "." ]
49c94c483713cbf5a04d805ff7dbd83766c9c964
https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/dto/Service.java#L2845-L2866
train
authlete/authlete-java-common
src/main/java/com/authlete/common/dto/Service.java
Service.supportsAll
public boolean supportsAll(ServiceProfile... profiles) { if (profiles == null) { return true; } for (ServiceProfile profile : profiles) { if (supports(profile) == false) { return false; } } return true; }
java
public boolean supportsAll(ServiceProfile... profiles) { if (profiles == null) { return true; } for (ServiceProfile profile : profiles) { if (supports(profile) == false) { return false; } } return true; }
[ "public", "boolean", "supportsAll", "(", "ServiceProfile", "...", "profiles", ")", "{", "if", "(", "profiles", "==", "null", ")", "{", "return", "true", ";", "}", "for", "(", "ServiceProfile", "profile", ":", "profiles", ")", "{", "if", "(", "supports", ...
Check if this service supports all the specified service profiles. If {@code null} is given, {@code true} is returned. If an empty array is given, {@code true} is returned. @param profiles Service profiles. @return {@code true} if this service supports all the specified service profiles. @since 2.12
[ "Check", "if", "this", "service", "supports", "all", "the", "specified", "service", "profiles", "." ]
49c94c483713cbf5a04d805ff7dbd83766c9c964
https://github.com/authlete/authlete-java-common/blob/49c94c483713cbf5a04d805ff7dbd83766c9c964/src/main/java/com/authlete/common/dto/Service.java#L2884-L2900
train