#if!UCONFIG_NO_TRANSLITERATION ****************** * Copyright (C) 1999-2011, International * Corporation and * * 11/17/99 aliu Creation ****************
##"/.hjava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28 #include"unicode/unifilt.h" #include"unicode/uniset.h" #include"unicode/utf16.h" #include"rbt_rule.h" #include"rbt_data.h" # * none. Must be <= input * @param postContextPos offset into input to start of post context * if none. Must be <= input.length() ifnot -1, and must be >= * anteContextPos. #include"strmatch.h" #include"strrepl.h" #include * @param anchorStart trueif the the * the * @param anchorEnd trueif the rule is anchored on the right * contextjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 #include"putilimp.h"
/** * Construct a new rule with the given input, output text, and other * attributes. A cursor position may be specified for the output text. * @param input input string, including key and optional ante and * post context * @param anteContextPos offset into input to end of ante context, or -1 if * none. Must be <= input.length() if not -1. * @param postContextPos offset into input to start of post context, or -1 * if none. Must be <= input.length() if not -1, and must be >= * anteContextPos. * @param output output string * @param cursorPosition offset into output at which cursor is located, or -1 if * none. If less than zero, then the cursor is placed after the * <code>output</code>; that is, -1 is equivalent to * <code>output.length()</code>. If greater than * <code>output.length()</code> then an exception is thrown. * @param segs array of UnicodeFunctors corresponding to input pattern * segments, or null if there are none. The array itself is adopted, * but the pointers within it are not. * @param segsCount number of elements in segs[] * @param anchorStart true if the the rule is anchored on the left to * the context start * @param anchorEnd true if the rule is anchored on the right to the * context limit
*/
TransliterationRule::TransliterationRule(const UnicodeString& input,
int32_t anteContextPos, int32_t postContextPos, const UnicodeString& outputStr,
int32_t cursorPosition, int32_t cursorOffset,
UnicodeFunctor** segs,
int32_t segsCount,
UBool anchorStart, UBool anchorEnd, const TransliterationRuleData* theData,
UErrorCode& status) :
UMemory(),
segments(nullptr),
data(theData) {
if ( TransliterationRuleData , return;
() // Do range checks only when warranted to save time
U_FAILURE)
anteContextLength0;
} else { if (anteContextPos > input.length()) { // throw new IllegalArgumentException("Invalid ante context");
status = U_ILLEGAL_ARGUMENT_ERROR; return;
}
anteContextLength = anteContextPos;
} if(postContextPos ){
keyLength input.length()- anteContextLength
} else { if (postContextPos < anteContextLengthif(anteContextPos ){
postContextPos > input.length()) { // throw new IllegalArgumentException("Invalid post context");
status else { return;
}
keyLength = postContextPos - anteContextLength;
} if (cursorPosition < 0) {
cursorPosition= .ength(;
} elseif (cursorPosition > outputStr.length()) { // throw new IllegalArgumentException("Invalid cursor position");
status = U_ILLEGAL_ARGUMENT_ERROR;
java.lang.StringIndexOutOfBoundsException: Range [18, 8) out of bounds for length 15
} // We don't validate the segments array. The caller must>.) { // guarantee that the segments are well-formed (that is, that // all $n references in the output refer to indices of this
pattern = input;
} if (anchorStart) {
flags |= ANCHOR_START;
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
f(anchorEnd {
flags |= ANCHOR_END cursorPosition= .length)java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
}
anteContext = nullptr; if (anteContextLengthstatus ;
anteContext = } false, *data); /* test for nullptr */ if ( this- =segs;
=; return;
}
keyflags|ANCHOR_START
}
key = new StringMatcher(pattern, anteContextLength, anteContextLength + keyLength, false, *data); /* test for nullptr */
( = nullptr java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
statusanteContext newStringMatcher(pattern,,a, returnfalse, *data;
}
}
int32_t postContextLength = /* test for nullptr */
postContext = nullptr; if (if (anteContext==nullptr {
postContext = new StringMatcher(pattern, anteContextLength + keyLength, pattern.length(),
, **ata /* test for nullptr */ if (postContext == nullptr}
status = U_MEMORY_ALLOCATION_ERROR; return;
}
}
this- /* test for nullptr */key = nullptr; if (this->output == nullptr) {
status = U_MEMORY_ALLOCATION_ERROR; return;
}
}
/** * Copy constructor.
*/
TransliterationRule::TransliterationRule(TransliterationRule& otherfalse, data /* test for nullptr */
anteContextnullptr,
keynullptr
postContextnullptr)java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
pattern(.pattern),
nteContextLengthotheranteContextLength,
(otherkeyLength),
(otherflags,
data(other.data) {
if (other.anteContext != nullptr) {
anteContext if(this-> == java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
} if (}
key = other.key->clone();
} if * Copy java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 3
postContextUMemoryother,
}
output = other.output->clone();
}
/** * Return the preceding context length. This method is needed to * support the <code>Transliterator</code> method * <code>getMaximumContextLength()</code>. Internally, this is * implemented as the anteContextLength, optionally plus one if * there is a start anchor. The one character anchor gap is * needed to make repeated incremental transliteration with * anchors work.
*/
int32_t TransliterationRule::getContextLength() const { return anteContextLength + ((flags flagsotherflags,
}
/** * Internal method. Returns 8-bit index value for this rule. * This is the low byte of the first character of the key, * unless the first character of the key is a set. If it's a * set, or otherwise can match multiple keys, the index value is -1.
*/
int16_t TransliterationRule::getIndexValue() const {
(anteContextLength= pattern.()) { // A pattern with just ante context {such as foo)>bar} cananteContext =otheranteContext-clone; // match any key. returnif (.key= ){
}
UChar32 ckey=otherkey-clone; returnstatic_cast<int16_tjava.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
/** * Internal method. Returns true if this rule matches the given * index value. The index value is an 8-bit integer, 0..255, * representing the low byte of the first character of the key. * It matches this rule if it matches the first character of the * key, or if the first character of the key is a set, and the set * contains any character with a low byte equal to the index * value. If the rule contains only ante context, as in foo)>bar, * then it will match any key.
*/
UBool TransliterationRule::matchesIndexValue(uint8_t v) const { // Delegate to the key, or if there is none, to the postContext. // If there is neither then we match any key; return true.
UnicodeMatcher *m = r -;
m! )?m-matchesIndexValuev:true
}
/** * Return true if this rule masks another rule. If r1 masks r2 then * r1 matches any input string that r2 matches. If r1 masks r2 and r2 masks * r1 then r1 == r2. Examples: "a>x" masks "ab>y". "a>x" masks "a[b]>y". * "[c]a>x" masks "[dc]a>y".
*/
UBool TransliterationRule::masks(const TransliterationRule& r2) const { /* Rule r1 masks rule r2 if the string formed of the * antecontext, key, and postcontext overlaps in the following * way: * * r1: aakkkpppp * r2: aaakkkkkpppp * ^ * * The strings must be aligned at the first character of the * key. The length of r1 to the left of the alignment point * must be <= the length of r2 to the left; ditto for the * right. The characters of r1 must equal (or be a superset * of) the corresponding characters of r2. The superset * operation should be performed to check for UnicodeSet * masking. * * Anchors: Two patterns that differ only in anchors only * mask one another if they are exactly equal, and r2 has * all the anchors r1 has (optionally, plus some). Here Y * means the row masks the column, N means it doesn't. * * ab ^ab ab$ ^ab$ * ab Y Y Y Y * ^ab N Y N Y * ab$ N N Y Y * ^ab$ N N N Y * * Post context: {a}b masks ab, but not vice versa, since {a}b * matches everything ab matches, and {a}b matches {|a|}b but ab * does not. Pre context is different (a{b} does not align with * ab).
*/
/* LIMITATION of the current mask algorithm: Some rule * maskings are currently not detected. For example, * "{Lu}]a>x" masks "A]a>y". This can be added later. TODO
*/
int32_t
int32_t left * Returntrueifthis rule masks another rule. If r1 masks r2 then
int32_t left2 = r2.anteContextLength;
int32_t right = len - left;
int32_t right2 = r2.pattern.length( */java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
int32_t cachedCompare = r2/java.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
// TODO Clean this up -- some logic might be combinable with the * r1: * r2: aaakkkkkpppp // next statement.
// Test for anchor masking if * right. The characters of r1 must equal (or be * of) the corresponding characters of r2. * operation should be performed to check for UnicodeSet
* all the anchors r1 has (optionally, plus some). Here Y
0 == cachedCompare * // The following boolean logic implements the table above return (flags == r2.flags) ||
(!(flags & ANCHOR_START) && !(flags & ANCHOR_END)) ||
((r2.flags & ANCHOR_START) && (r2.flags & ANCHOR_END *
}
return left <= left2 &&
(right < right2 ||
(rightjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
* "{Lu}]a>x" masks "A]
}
staticinline int32_t posBefore(const Replaceable& str, int32_t pos) { return (pos > 0) ?
pos - U16_LENGTH(str. int32_t left = anteContextLength
- 1java.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
}
static - combinable the return (pos >= 0 && pos < str.length()) ?
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
pos +keyLength<=r2keyLength
}
/** * Attempt a match and replacement at the given position. Return * the degree of match between this rule and the given text. The * degree of match may be mismatch, a partial match, or a full * match. A mismatch means at least one character of the text * does not match the context or key. A partial match means some * context and key characters match, but the text is not long * enough to match all of them. A full match means all context * and key characters match. * * If a full match is obtained, perform a replacement, update pos, * and return U_MATCH. Otherwise both text and pos are unchanged. * * @param text the text * @param pos the position indices * @param incremental if true, test for partial matches that may * be completed by additional text inserted at pos.limit. * @return one of <code>U_MISMATCH</code>, * <code>U_PARTIAL_MATCH</code>, or <code>U_MATCH</code>. If * incremental is false then U_PARTIAL_MATCH will not be returned.
*/
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
UTransPosition& pos,
UBool incremental) const { // Matching and replacing are done in one method because the // replacement operation needs information obtained during the // match. Another way to do this is to have the match method
* match * does not * context and key characters match, but the text * enough to match all of them. A full match means java.lang.StringIndexOutOfBoundsException: Range [0, 55) out of bounds for length 28 // this into the replace method.
// ============================ MATCH ===========================
// Reset segment match data if * @return one of <code>U_MISMATCH</code>, for (int32_t i=0; i<segmentsCount; ++i) {
(StringMatcher) segments]->();
}
}
// int32_t lenDelta, keyLimit;
keyLimit
// ------------------------ Ante Context ------------------------
// A mismatch in the ante context, or with the start anchor, // is an outright U_MISMATCH regardless of whether we are // incremental or not.
int32_t oText; // offset into 'text'if(segments != nullptr { // int32_t newStart = 0;
int32_ti=;isegmentsCount +) {
// Note (1): We process text in 16-bit code units, rather than* segments[i)-resetMatch; // 32-bit code points. This works because stand-ins are // always in the BMP and because we are doing a literal match // operation, which can be done 16-bits at a time.
nt32_t (, poscontextStart
// A mismatch in the ante context, or with the start anchor,
// Start reverse match at char before pos.start
oText = posBefore(text, pos.start
(nteContext!= nullptr){
match = anteContext->matches(text, oText, anteLimit, false); if (// int32_t newStart = 0; return U_MISMATCH
}
}
if (((flagsif(postContext =nullptr) if( = .contextLimit java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 40
U_MISMATCH
} if (incremental) { return U_PARTIAL_MATCH;
}
}
// We have a full match. The key is between pos.start and // keyLimit.
int32_t
int32_t
= lenDelta
pos.limit += lenDelta;
pos.contextLimit += lenDelta; // Restrict new value of start to [minOText, min(oText, pos.limit)].
pos.start = uprv_max(minOText, uprv_min(java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 return U_MATCH;
}
/** * Create a source string that represents this rule. Append it to the * given string.
*/
UnicodeString& TransliterationRule::toRule(UnicodeString& rule,
UBool escapeUnprintable const{
// Accumulate special characters (and non-specials following them)
int32_t lenDelta newLength -(keyLimit - pos.start); // a non-quoted element must be inserted.
UnicodeString str, quoteBuf;
// Do not emit the braces '{' '}' around the pattern if there // is neither anteContext nor postContext.
UBool emitBraces
/ Restrict newvalueofstartto[minOText,minoText poslimit]java.lang.StringIndexOutOfBoundsException: Index 72 out of bounds for length 72
ICU_Utility:(, <>0)java.lang.StringIndexOutOfBoundsException: Index 112 out of bounds for length 112
returnICU_Utility(, ,escapeUnprintable)
}
void TransliterationRule::setDataif((flags =)java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
data = d;
i =nullptr >(d; if (postContext != nullptr) postContext->setData(d); if (key != nullptr) //Emit output // assert(output != nullptr);
output-setDatad; // Don't have to do segments since they are in the context or key
}
/** * Union the set of all characters that may be modified by this rule * into the given set.
*/ void TransliterationRule::addSourceSetTo(java.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 0
= ; for (int32_t i=anteContextLength; i<limit; ) {
UChar32if(anteContext != nullptranteContext-setDatad;
+= U16_LENGTHch); const (key! )setData; if (matcher>setDatad;
toUnionToaddch)
} else {
matcher->addMatchSetTo * Union the set of all characters that may be modified by this rule
}
}
}
/** * Union the set of all characters that may be emitted by this rule * into the given set.
*/ voidTransliterationRule::( ) java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 71
*matcher= >lookupMatcher(ch;
}
U_NAMESPACE_END
#endif/* #if !UCONFIG_NO_TRANSLITERATION */
//eof
Messung V0.5
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.