Inheritance: global::java.lang.Object, global::java.io.Serializable, global::java.lang.Comparable, global::java.lang.CharSequence
		public static String getDirectoryName(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				int index2 = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				if (index2 > index) {
					index = index2;
				}
				if (index != -1) {
					if (index == path.length() - 1) {
						if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
							return null;
						} else {
							path = path.substring(0, index);
						}
					} else {
						if (path.indexOf(VOLUME_SEPARATOR_CHAR) == index - 1) {
							path = path.substring(0, index + 1);
						} else {
							path = path.substring(0, index);
						}
					}
					if (path.length() == 2 && path[1] == VOLUME_SEPARATOR_CHAR) {
						return "";
					}
				}
				return path;
			}
			return null;
		}
Exemple #2
0
        public void StringConstructor()
        {
            var s = new String("Tetsts");

            Assert.IsTrue("Tetsts".Equals(s));
            Assert.IsTrue(s.Equals("Tetsts"));
        }
 public void stringArray()
 {
     String[] objects = new String[3];
     objects[0] = "test6857";
     String[] res = testInstance.stringArray(objects);
     Assert.AreEqual((String)"test6857", res[1]);
 }
Exemple #4
0
        internal static boolean checkNumberGroupingIsValid(
            PhoneNumber number, String candidate, PhoneNumberUtil util, NumberGroupingChecker checker)
        {
            // TODO: Evaluate how this works for other locales (testing has been limited to NANPA regions)
            // and optimise if necessary.
            StringBuilder normalizedCandidate =
                PhoneNumberUtil.normalizeDigits(candidate, true /* keep non-digits */);

            String[] formattedNumberGroups = getNationalNumberGroups(util, number, null);
            if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups))
            {
                return(true);
            }
            // If this didn't pass, see if there are any alternate formats, and try them instead.
            PhoneMetadata alternateFormats =
                MetadataManager.getAlternateFormatsForCountry(number.getCountryCode());

            if (alternateFormats != null)
            {
                foreach (NumberFormat alternateFormat in alternateFormats.numberFormats())
                {
                    formattedNumberGroups = getNationalNumberGroups(util, number, alternateFormat);
                    if (checker.checkGroups(util, number, normalizedCandidate, formattedNumberGroups))
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #5
0
 public static void Main(string[] args)
 {
     try
     {
         var minecraftserver = new MinecraftServer();
         if (!GraphicsEnvironment.isHeadless() &&
             ((args.Length <= 0) || !String.instancehelper_equals(args[0], "nogui")))
         {
             ServerGUI.initGui(minecraftserver);
         }
         new ThreadServerApplication("Server thread", minecraftserver).start();
     }
     catch (java.lang.Exception exception1)
     {
         var local1 = ByteCodeHelper.MapException <java.lang.Exception>(exception1, ByteCodeHelper.MapFlags.None);
         if (local1 == null)
         {
             throw;
         }
         java.lang.Exception exception  = local1;
         java.lang.Exception exception2 = exception;
         logger.log(Level.SEVERE, "Failed to start the minecraft server", exception2);
         return;
     }
 }
Exemple #6
0
 internal static boolean containsOnlyValidXChars(
     PhoneNumber number, String candidate, PhoneNumberUtil util)
 {
     // The characters 'x' and 'X' can be (1) a carrier code, in which case they always precede the
     // national significant number or (2) an extension sign, in which case they always precede the
     // extension number. We assume a carrier code is more than 1 digit, so the first case has to
     // have more than 1 consecutive 'x' or 'X', whereas the second case can only have exactly 1 'x'
     // or 'X'. We ignore the character if it appears as the last character of the string.
     for (int index = 0; index < candidate.length() - 1; index++)
     {
         char charAtIndex = candidate.charAt(index);
         if (charAtIndex == 'x' || charAtIndex == 'X')
         {
             char charAtNextIndex = candidate.charAt(index + 1);
             if (charAtNextIndex == 'x' || charAtNextIndex == 'X')
             {
                 // This is the carrier code case, in which the 'X's always precede the national
                 // significant number.
                 index++;
                 if (util.isNumberMatch(number, candidate.substring(index)) != MatchType.NSN_MATCH)
                 {
                     return(false);
                 }
                 // This is the extension sign case, in which the 'x' or 'X' should always precede the
                 // extension number.
             }
             else if (!PhoneNumberUtil.normalizeDigitsOnly(candidate.substring(index)).equals(
                          number.getExtension()))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
        public static void main(String[] args) {
            System.out.println();
            System.out.println();
			var result = new Application().run(args);
			System.out.println("Done("+result+")");
            System.exit(result);
        }
Exemple #8
0
 /**
  * Helper method to get the national-number part of a number, formatted without any national
  * prefix, and return it as a set of digit blocks that would be formatted together.
  */
 private static String[] getNationalNumberGroups(PhoneNumberUtil util, PhoneNumber number,
                                                 NumberFormat formattingPattern)
 {
     if (formattingPattern == null)
     {
         // This will be in the format +CC-DG;ext=EXT where DG represents groups of digits.
         String rfc3966Format = util.format(number, PhoneNumberFormat.RFC3966);
         // We remove the extension part from the formatted string before splitting it into different
         // groups.
         int endIndex = rfc3966Format.indexOf(';');
         if (endIndex < 0)
         {
             endIndex = rfc3966Format.length();
         }
         // The country-code will have a '-' following it.
         int startIndex = rfc3966Format.indexOf('-') + 1;
         return(rfc3966Format.substring(startIndex, endIndex).split("-"));
     }
     else
     {
         // We format the NSN only, and split that according to the separator.
         String nationalSignificantNumber = util.getNationalSignificantNumber(number);
         return(util.formatNsnUsingPattern(nationalSignificantNumber,
                                           formattingPattern, PhoneNumberFormat.RFC3966).split("-"));
     }
 }
 LocalInfo(TypeInfo type, String name, int index, Label beginLabel, Label endLabel) {
     this.type = type;
     this.name = name;
     this.index = index;
     this.beginLabel = beginLabel;
     this.endLabel = endLabel;
 }
Exemple #10
0
        /**
         * Extracts the country calling code from the beginning of nationalNumber to
         * prefixBeforeNationalNumber when they are available, and places the remaining input into
         * nationalNumber.
         *
         * @return  true when a valid country calling code can be found.
         */
        private boolean attemptToExtractCountryCallingCode()
        {
            if (nationalNumber.length() == 0)
            {
                return(false);
            }
            StringBuilder numberWithoutCountryCallingCode = new StringBuilder();
            int           countryCode = phoneUtil.extractCountryCode(nationalNumber, numberWithoutCountryCallingCode);

            if (countryCode == 0)
            {
                return(false);
            }
            nationalNumber.setLength(0);
            nationalNumber.append(numberWithoutCountryCallingCode);
            String newRegionCode = phoneUtil.getRegionCodeForCountryCode(countryCode);

            if (PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY.equals(newRegionCode))
            {
                currentMetadata = phoneUtil.getMetadataForNonGeographicalRegion(countryCode);
            }
            else if (!newRegionCode.equals(defaultCountry))
            {
                currentMetadata = getMetadataForRegion(newRegionCode);
            }
            String countryCodeString = Integer.toString(countryCode);

            prefixBeforeNationalNumber.append(countryCodeString).append(SEPARATOR_BEFORE_NATIONAL_NUMBER);
            return(true);
        }
Exemple #11
0
        /**
         * Attempts to find the next subsequence in the searched sequence on or after {@code searchIndex}
         * that represents a phone number. Returns the next match, null if none was found.
         *
         * @param index  the search index to start searching at
         * @return  the phone number match found, null if none can be found
         */
        private PhoneNumberMatch find(int index)
        {
            Matcher matcher = PATTERN.matcher(text);

            while ((maxTries > 0) && matcher.find(index))
            {
                int          start     = matcher.start();
                CharSequence candidate = text.subSequence(start, matcher.end());

                // Check for extra numbers at the end.
                // TODO: This is the place to start when trying to support extraction of multiple phone number
                // from split notations (+41 79 123 45 67 / 68).
                candidate = trimAfterFirstMatch(PhoneNumberUtil.SECOND_NUMBER_START_PATTERN, candidate);

                PhoneNumberMatch match = extractMatch(candidate, start);
                if (match != null)
                {
                    return(match);
                }

                index = start + candidate.length();
                maxTries--;
            }

            return(null);
        }
Exemple #12
0
        private boolean createFormattingTemplate(NumberFormat format)
        {
            String numberPattern = format.getPattern();

            // The formatter doesn't format numbers when numberPattern contains "|", e.g.
            // (20|3)\d{4}. In those cases we quickly return.
            if (numberPattern.indexOf('|') != -1)
            {
                return(false);
            }

            // Replace anything in the form of [..] with \d
            numberPattern = CHARACTER_CLASS_PATTERN.matcher(numberPattern).replaceAll("\\\\d");

            // Replace any standalone digit (not the one in d{}) with \d
            numberPattern = STANDALONE_DIGIT_PATTERN.matcher(numberPattern).replaceAll("\\\\d");
            formattingTemplate.setLength(0);
            String tempTemplate = getFormattingTemplate(numberPattern, format.getFormat());

            if (tempTemplate.length() > 0)
            {
                formattingTemplate.append(tempTemplate);
                return(true);
            }
            return(false);
        }
 private void appendSubsequentLocalePart(String subsequentLocalePart, StringBuilder fullLocale)
 {
     if (subsequentLocalePart.length() > 0)
     {
         fullLocale.append('_').append(subsequentLocalePart);
     }
 }
        /**
         * Gets the name of the file that contains the mapping data for the {@code countryCallingCode} in
         * the language specified.
         *
         * @param countryCallingCode  the country calling code of phone numbers which the data file
         *     contains
         * @param language  two-letter lowercase ISO language codes as defined by ISO 639-1
         * @param script  four-letter titlecase (the first letter is uppercase and the rest of the letters
         *     are lowercase) ISO script codes as defined in ISO 15924
         * @param region  two-letter uppercase ISO country codes as defined by ISO 3166-1
         * @return  the name of the file, or empty string if no such file can be found
         */
        internal String getFileName(int countryCallingCode, String language, String script, String region)
        {
            if (language.length() == 0)
            {
                return("");
            }
            int index = Arrays.binarySearch(countryCallingCodes, countryCallingCode);

            if (index < 0)
            {
                return("");
            }
            Set <String> setOfLangs = availableLanguages.get(index);

            if (setOfLangs.size() > 0)
            {
                String languageCode = findBestMatchingLanguageCode(setOfLangs, language, script, region);
                if (languageCode.length() > 0)
                {
                    StringBuilder fileName = new StringBuilder();
                    fileName.append(countryCallingCode).append('_').append(languageCode);
                    return(fileName.toString());
                }
            }
            return("");
        }
Exemple #15
0
        // Returns true if a new template is created as opposed to reusing the existing template.
        private boolean maybeCreateNewTemplate()
        {
            // When there are multiple available formats, the formatter uses the first format where a
            // formatting template could be created.
            Iterator <NumberFormat> it = possibleFormats.iterator();

            while (it.hasNext())
            {
                NumberFormat numberFormat = it.next();
                String       pattern      = numberFormat.getPattern();
                if (currentFormattingPattern.equals(pattern))
                {
                    return(false);
                }
                if (createFormattingTemplate(numberFormat))
                {
                    currentFormattingPattern          = pattern;
                    shouldAddSpaceAfterNationalPrefix =
                        NATIONAL_PREFIX_SEPARATORS_PATTERN.matcher(
                            numberFormat.getNationalPrefixFormattingRule()).find();
                    // With a new formatting template, the matched position using the old template needs to be
                    // reset.
                    lastMatchPosition = 0;
                    return(true);
                }
                else // Remove the current number format from possibleFormats.
                {
                    it.remove();
                }
            }
            ableToFormat = false;
            return(false);
        }
Exemple #16
0
        /**
         * Attempts to extract a match from a {@code candidate} character sequence.
         *
         * @param candidate  the candidate text that might contain a phone number
         * @param offset  the offset of {@code candidate} within {@link #text}
         * @return  the match found, null if none can be found
         */
        private PhoneNumberMatch extractMatch(CharSequence candidate, int offset)
        {
            // Skip a match that is more likely a publication page reference or a date.
            if (PUB_PAGES.matcher(candidate).find() || SLASH_SEPARATED_DATES.matcher(candidate).find())
            {
                return(null);
            }
            // Skip potential time-stamps.
            if (TIME_STAMPS.matcher(candidate).find())
            {
                String followingText = text.toString().substring(offset + candidate.length());
                if (TIME_STAMPS_SUFFIX.matcher(followingText).lookingAt())
                {
                    return(null);
                }
            }

            // Try to come up with a valid match given the entire candidate.
            String           rawString = candidate.toString();
            PhoneNumberMatch match     = parseAndVerify(rawString, offset);

            if (match != null)
            {
                return(match);
            }

            // If that failed, try to find an "inner match" - there might be a phone number within this
            // candidate.
            return(extractInnerMatch(rawString, offset));
        }
 void buildPackageDocumentation(String packageName, PackageDeclarationNode packageDeclaration) {
     var comment = ParserHelper.decodeDocumentation(context.Text, packageDeclaration.DocumentationOffset,
             packageDeclaration.DocumentationLength);
     memberKind = null;
     node = packageDeclaration;
     appendDocumentation("N:" + packageName, comment);
 }
Exemple #18
0
        // Returns the national prefix extracted, or an empty string if it is not present.
        private String removeNationalPrefixFromNationalNumber()
        {
            int startOfNationalNumber = 0;

            if (isNanpaNumberWithNationalPrefix())
            {
                startOfNationalNumber = 1;
                prefixBeforeNationalNumber.append('1').append(SEPARATOR_BEFORE_NATIONAL_NUMBER);
                isCompleteNumber = true;
            }
            else if (currentMetadata.hasNationalPrefixForParsing())
            {
                Pattern nationalPrefixForParsing =
                    regexCache.getPatternForRegex(currentMetadata.getNationalPrefixForParsing());
                Matcher m = nationalPrefixForParsing.matcher(nationalNumber);
                // Since some national prefix patterns are entirely optional, check that a national prefix
                // could actually be extracted.
                if (m.lookingAt() && m.end() > 0)
                {
                    // When the national prefix is detected, we use international formatting rules instead of
                    // national ones, because national formatting rules could contain local formatting rules
                    // for numbers entered without area code.
                    isCompleteNumber      = true;
                    startOfNationalNumber = m.end();
                    prefixBeforeNationalNumber.append(nationalNumber.substring(0, startOfNationalNumber));
                }
            }
            String nationalPrefix = nationalNumber.substring(0, startOfNationalNumber);

            nationalNumber.delete(0, startOfNationalNumber);
            return(nationalPrefix);
        }
Exemple #19
0
        /**
         * Returns the description of the geographical area the {@code number} corresponds to. This method
         * distinguishes the case of an invalid prefix and a prefix for which the name is not available in
         * the current language. If the description is not available in the current language an empty
         * string is returned. If no description was found for the provided number, null is returned.
         *
         * @param number  the phone number to look up
         * @return  the description of the geographical area
         */
        internal String lookup(PhoneNumber number)
        {
            int numOfEntries = areaCodeMapStorage.getNumOfEntries();

            if (numOfEntries == 0)
            {
                return(null);
            }
            long phonePrefix =
                Long.parseLong(number.getCountryCode() + phoneUtil.getNationalSignificantNumber(number));
            int currentIndex = numOfEntries - 1;
            SortedSet <Integer> currentSetOfLengths = areaCodeMapStorage.getPossibleLengths();

            while (currentSetOfLengths.size() > 0)
            {
                Integer possibleLength = currentSetOfLengths.last();
                String  phonePrefixStr = String.valueOf(phonePrefix);
                if (phonePrefixStr.length() > possibleLength)
                {
                    phonePrefix = Long.parseLong(phonePrefixStr.substring(0, possibleLength));
                }
                currentIndex = binarySearch(0, currentIndex, phonePrefix);
                if (currentIndex < 0)
                {
                    return(null);
                }
                int currentPrefix = areaCodeMapStorage.getPrefix(currentIndex);
                if (phonePrefix == currentPrefix)
                {
                    return(areaCodeMapStorage.getDescription(currentIndex));
                }
                currentSetOfLengths = currentSetOfLengths.headSet(possibleLength);
            }
            return(null);
        }
Exemple #20
0
        internal static void fail(BufferN b,
                                  String expected, char expectedChar,
                                  String got, char gotChar)
        {
            if (b is ByteBufferN)
            {
                var bb = (ByteBufferN)b;
                int n  = Math.Min(16, bb.limit());
                for (int i = 0; i < n; i++)
                {
                    outt.print(" " + Integer.toHexString(bb.get(i) & 0xff));
                }
                outt.println();
            }

            /*if (b is CharBuffer) {
             * CharBuffer bb = (CharBuffer)b;
             * int n = Math.min(16, bb.limit());
             * for (int i = 0; i < n; i++)
             *  outt.print(" " + Integer.toHexString(bb.get(i) & 0xffff));
             * outt.println();
             * }*/
            throw new RuntimeException(toString(b)
                                       + ": Expected '" + expectedChar + "'=0x"
                                       + expected
                                       + ", got '" + gotChar + "'=0x"
                                       + got);
        }
Exemple #21
0
        /**
         * Attempts to extract a match from {@code candidate} if the whole candidate does not qualify as a
         * match.
         *
         * @param candidate  the candidate text that might contain a phone number
         * @param offset  the current offset of {@code candidate} within {@link #text}
         * @return  the match found, null if none can be found
         */
        private PhoneNumberMatch extractInnerMatch(String candidate, int offset)
        {
            // Try removing either the first or last "group" in the number and see if this gives a result.
            // We consider white space to be a possible indication of the start or end of the phone number.
            Matcher groupMatcher = GROUP_SEPARATOR.matcher(candidate);

            if (groupMatcher.find())
            {
                // Try the first group by itself.
                CharSequence firstGroupOnly = candidate.substring(0, groupMatcher.start());
                firstGroupOnly = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
                                                     firstGroupOnly);
                PhoneNumberMatch match = parseAndVerify(firstGroupOnly.toString(), offset);
                if (match != null)
                {
                    return(match);
                }
                maxTries--;

                int withoutFirstGroupStart = groupMatcher.end();
                // Try the rest of the candidate without the first group.
                CharSequence withoutFirstGroup = candidate.substring(withoutFirstGroupStart);
                withoutFirstGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
                                                        withoutFirstGroup);
                match = parseAndVerify(withoutFirstGroup.toString(), offset + withoutFirstGroupStart);
                if (match != null)
                {
                    return(match);
                }
                maxTries--;

                if (maxTries > 0)
                {
                    int lastGroupStart = withoutFirstGroupStart;
                    while (groupMatcher.find())
                    {
                        // Find the last group.
                        lastGroupStart = groupMatcher.start();
                    }
                    CharSequence withoutLastGroup = candidate.substring(0, lastGroupStart);
                    withoutLastGroup = trimAfterFirstMatch(PhoneNumberUtil.UNWANTED_END_CHAR_PATTERN,
                                                           withoutLastGroup);
                    if (withoutLastGroup.equals(firstGroupOnly))
                    {
                        // If there are only two groups, then the group "without the last group" is the same as
                        // the first group. In these cases, we don't want to re-check the number group, so we exit
                        // already.
                        return(null);
                    }
                    match = parseAndVerify(withoutLastGroup.toString(), offset);
                    if (match != null)
                    {
                        return(match);
                    }
                    maxTries--;
                }
            }
            return(null);
        }
        private StringBuilder constructFullLocale(String language, String script, String region)
        {
            StringBuilder fullLocale = new StringBuilder(language);

            appendSubsequentLocalePart(script, fullLocale);
            appendSubsequentLocalePart(region, fullLocale);
            return(fullLocale);
        }
 public NumberFormat addLeadingDigitsPattern(String value)
 {
     if (value == null) {
     throw new NullPointerException();
       }
       leadingDigitsPattern_.add(value);
       return this;
 }
		public CodeError(String filename, int id, int level, String message, int line, int column) {
			this.Filename = filename;
			this.Id = id;
			this.Level = level;
			this.Message = message;
			this.Line = line;
			this.Column = column;
		}
 /*
 public void writeFloat(float v) {
 writeInt(Float.floatToIntBits(v));
 }
 public void writeDouble(double v) {
 writeLong(Double.doubleToLongBits(v));
 }
 */
 public void writeBytes(String s)
 {
     int len = s.length();
     for (int i = 0 ; i < len ; i++) {
     @out.write((byte)s.charAt(i));
     }
     incCount(len);
 }
Exemple #26
0
 public static String StrongJ2CpString(JNIEnv env, JniLocalHandle obj)
 {
     if (JniHandle.IsNull(obj))
     {
         return(null);
     }
     return(String.CreateProxy(env, obj));
 }
Exemple #27
0
 public NumberFormat addLeadingDigitsPattern(String value)
 {
     if (value == null)
     {
         throw new NullPointerException();
     }
     leadingDigitsPattern_.add(value);
     return(this);
 }
 public static UnicodeProp forPOSIXName(String propName)
 {
     propName = posix.get(propName.toUpperCase());
     if (propName == null)
     {
         return(null);
     }
     return(valueOf(propName));
 }
Exemple #29
0
        static PhoneNumberMatcher()
        {
            /* Builds the MATCHING_BRACKETS and PATTERN regular expressions. The building blocks below exist
             * to make the pattern more easily understood. */

            String openingParens = "(\\[\uFF08\uFF3B";
            String closingParens = ")\\]\uFF09\uFF3D";
            String nonParens     = "[^" + openingParens + closingParens + "]";

            /* Limit on the number of pairs of brackets in a phone number. */
            String bracketPairLimit = limit(0, 3);

            /*
             * An opening bracket at the beginning may not be closed, but subsequent ones should be.  It's
             * also possible that the leading bracket was dropped, so we shouldn't be surprised if we see a
             * closing bracket first. We limit the sets of brackets in a phone number to four.
             */
            MATCHING_BRACKETS = Pattern.compile(
                "(?:[" + openingParens + "])?" + "(?:" + nonParens + "+" + "[" + closingParens + "])?" +
                nonParens + "+" +
                "(?:[" + openingParens + "]" + nonParens + "+[" + closingParens + "])" + bracketPairLimit +
                nonParens + "*");

            /* Limit on the number of leading (plus) characters. */
            String leadLimit = limit(0, 2);
            /* Limit on the number of consecutive punctuation characters. */
            String punctuationLimit = limit(0, 4);

            /* The maximum number of digits allowed in a digit-separated block. As we allow all digits in a
             * single block, set high enough to accommodate the entire national number and the international
             * country code. */
            int digitBlockLimit =
                PhoneNumberUtil.MAX_LENGTH_FOR_NSN + PhoneNumberUtil.MAX_LENGTH_COUNTRY_CODE;

            /* Limit on the number of blocks separated by punctuation. Uses digitBlockLimit since some
             * formats use spaces to separate each digit. */
            String blockLimit = limit(0, digitBlockLimit);

            /* A punctuation sequence allowing white space. */
            String punctuation = "[" + PhoneNumberUtil.VALID_PUNCTUATION + "]" + punctuationLimit;
            /* A digits block without punctuation. */
            String digitSequence = "\\p{Nd}" + limit(1, digitBlockLimit);

            String leadClassChars = openingParens + PhoneNumberUtil.PLUS_CHARS;
            String leadClass      = "[" + leadClassChars + "]";

            LEAD_CLASS      = Pattern.compile(leadClass);
            GROUP_SEPARATOR = Pattern.compile("\\p{Z}" + "[^" + leadClassChars + "\\p{Nd}]*");

            /* Phone number pattern allowing optional punctuation. */
            PATTERN = Pattern.compile(
                "(?:" + leadClass + punctuation + ")" + leadLimit +
                digitSequence + "(?:" + punctuation + digitSequence + ")" + blockLimit +
                "(?:" + PhoneNumberUtil.EXTN_PATTERNS_FOR_MATCHING + ")?",
                PhoneNumberUtil.REGEX_FLAGS);
        }
Exemple #30
0
 public PhoneNumber setRawInput(String value)
 {
     if (value == null)
     {
         throw new NullPointerException();
     }
     _hasRawInput = true;
     rawInput_    = value;
     return(this);
 }
Exemple #31
0
        /*
         * public void writeFloat(float v) {
         *  writeInt(Float.floatToIntBits(v));
         * }
         * public void writeDouble(double v) {
         *  writeLong(Double.doubleToLongBits(v));
         * }
         */
        public void writeBytes(String s)
        {
            int len = s.length();

            for (int i = 0; i < len; i++)
            {
                @out.write((byte)s.charAt(i));
            }
            incCount(len);
        }
		public static bool hasNature(IProject project, String natureId) {
			if (project.exists() && project.isOpen()) {
				try {
					return project.hasNature(natureId);
				} catch (CoreException e) {
					Environment.logException(e);
				}
			}
			return false;
		}
		public String getMessage(Locale locale, String key, params Object[] args) {
			var rb = getResourceBundle(locale);
			if (rb != null) {
				try {
					return MessageFormat.format(rb.getString(key), args);
				} catch {
				}
			}
			return key;
		}
Exemple #34
0
 public PhoneNumber setPreferredDomesticCarrierCode(String value)
 {
     if (value == null)
     {
         throw new NullPointerException();
     }
     _hasPreferredDomesticCarrierCode = true;
     preferredDomesticCarrierCode_    = value;
     return(this);
 }
Exemple #35
0
 public PhoneNumber setExtension(String value)
 {
     if (value == null)
     {
         throw new NullPointerException();
     }
     _hasExtension = true;
     extension_    = value;
     return(this);
 }
Exemple #36
0
        /**
         * Trims away any characters after the first match of {@code pattern} in {@code candidate},
         * returning the trimmed version.
         */
        private static CharSequence trimAfterFirstMatch(Pattern pattern, CharSequence candidate)
        {
            Matcher trailingCharsMatcher = pattern.matcher(candidate);

            if (trailingCharsMatcher.find())
            {
                candidate = candidate.subSequence(0, trailingCharsMatcher.start());
            }
            return(candidate);
        }
Exemple #37
0
        internal static string GetString(this Object target, string columnName)
        {
            var getString = target
                            .getClass()
                            .getMethods()
                            .Single(x => x.getName() == Constants.Methods.GetString &&
                                    x.GetSignature() == Constants.MethodSignatures.String_String);

            java.lang.String result = (java.lang.String)getString.invoke(target, new[] { JNIEnv.ThreadEnv.NewString(columnName) });
            return(result);
        }
        public Pattern getPatternForRegex(String regex)
        {
            Pattern pattern = cache.get(regex);

            if (pattern == null)
            {
                pattern = Pattern.compile(regex);
                cache.put(regex, pattern);
            }
            return(pattern);
        }
Exemple #39
0
        public static sbyte[] ToByteArray(string e, string charset)
        {
            sbyte[] u = null;

            try { u = new java.lang.String(e).getBytes(charset); }
            catch
            {
            }

            return(u);
        }
     	: super(typeSystem, name) {
     this.typeSystem = typeSystem;
     this.descriptor = "L" + name + ";";
     numericTypeKind = TypeKinds[name];
     if (numericTypeKind == null) {
         numericTypeKind = NumericTypeKind.None;
     }
     new ClassReader(bytes).accept(new OutlineVisitor(this), ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
     
     this.genericsScope = new Scope<String, TypeInfo>();
     this.genericsScope.enterScope();
 }
 /**
    * Creates a new match.
    *
    * @param start  the start index into the target text
    * @param rawString  the matched substring of the target text
    * @param number  the matched phone number
    */
 internal PhoneNumberMatch(int start, String rawString, PhoneNumber number)
 {
     if (start < 0) {
       throw new IllegalArgumentException("Start index must be >= 0.");
     }
     if (rawString == null || number == null) {
       throw new NullPointerException();
     }
     this._start = start;
     this._rawString = rawString;
     this._number = number;
 }
 public static MemberInfo getInfo(MethodInfo getAccessor, MethodInfo setAccessor, String name) {
     var result = (getAccessor ?? setAccessor).getUserData(typeof(PropertyMemberInfo));
     if (result == null) {
         result = new PropertyMemberInfo(getAccessor, setAccessor, name);
         if (getAccessor != null) {
             getAccessor.addUserData(result);
         }
         if (setAccessor != null) {
             setAccessor.addUserData(result);
         }
     }
     return result;
 }
		public static String getFileName(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				if (index == -1) {
					index = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				}
				if (index == -1) {
					return path;
				}
				return path.substring(index + 1);
			}
			return null;
		}
 public static String quoteReplacement(String s)
 {
     if ((s.indexOf('\\') == -1) && (s.indexOf('$') == -1))
     return s;
     StringBuilder sb = new StringBuilder();
     for (int i=0; i<s.length(); i++) {
     char c = s.charAt(i);
     if (c == '\\' || c == '$') {
         sb.append('\\');
     }
     sb.append(c);
     }
     return sb.toString();
 }
		public void testArrays() {
			var c = new Container();
			
			var obj = new Object();
			var str = "abc";
			var arr = new String[] { "a", "b", "c" };
			c.addUserData(obj);
			c.addUserData(str);
			c.addUserData(arr);
			
			Assert.assertEquals(obj, c.getUserData(typeof(Object)));
			Assert.assertEquals("abc", c.getUserData(typeof(String)));
			Assert.assertEquals((Object)arr, c.getUserData(typeof(String[])));
		}
		public void addTypeToTypeRelation(String referencingType, String referencedType) {
			var referencing = referencingTypes.get(referencedType);
			if (referencing == null) {
				referencing = new HashSet<String>();
				referencingTypes[referencedType] = referencing;
			}
			referencing.add(referencingType);
			var referenced = referencedTypes.get(referencingType);
			if (referenced == null) {
				referenced = new HashSet<String>();
				referencedTypes[referencingType] = referenced;
			}
			referenced.add(referencedType);
		}
		public void addFileToTypeRelation(String fileName, String typeName) {
			var contents = fileContents.get(fileName);
			if (contents == null) {
				contents = new HashSet<String>();
				fileContents[fileName] = contents;
			}
			contents.add(typeName);
			var locations = typeLocations.get(typeName);
			if (locations == null) {
				locations = new HashSet<String>();
				typeLocations[typeName] = locations;
			}
			locations.add(fileName);
		}
 public static long decodeHexadecimalLong(String value) {
     long result = 0;
     var ndigits = 0;
     for (var i = 2; i < value.length(); i++) {
         var digit = ParserHelper.scanHexDigit(value[i]);
         if (ndigits == 0 && digit == 0) {
             continue;
         }
         result <<= 4;
         result |= digit;
         if (++ndigits == 17) {
             throw new NumberFormatException(value);
         }
     }
     return result;
 }
		public static String getFileNameWithoutExtension(String path) {
			if (path != null) {
				int index = path.lastIndexOf(DIRECTORY_SEPARATOR_CHAR);
				if (index == -1) {
					index = path.lastIndexOf(ALT_DIRECTORY_SEPARATOR_CHAR);
				}
				if (index != -1) {
					path = path.substring(index + 1);
				}
				index = path.lastIndexOf('.');
				if (index == -1) {
					return path;
				}
				return path.substring(0, index);
			}
			return null;
		}
        public Library(String[] classPath, Library parent) {
			this.classPath = new ArrayList<String>();
			foreach(string path in classPath)
				this.classPath.add(path);
            this.fileClasses = new HashMap<String, File>(128);
            int capacity = (parent == null) ? 0x5000 : 128;
            this.jarClasses = new HashMap<String, ZipFile>(capacity);
            this.classNames = new ArrayList<String>(capacity);
            this.typeInfos = new HashMap<String, TypeInfo>();
			this.constructedGenericTypes = new HashMap<TypeInfo, ArrayList<TypeInfo>>();
			this.constructedGenericMethods = new HashMap<MethodInfo, ArrayList<MethodInfo>>();
            this.parent = parent;

			if (parent == null) {
	            initializeBootClasses();
			}
            
            foreach (var path in classPath) {
                explorePath(path);
            }
        }
		public bool load(IFile file) {
			if (file.exists()) {
				try {
					var libraries = new ArrayList<ProjectLibrary>();
					var preprocessorSymbols = new HashSet<String>();
					var outputPath = "bin";
					
					var document = XmlHelper.load(new InputStreamReader(file.getContents()));
					var nodeList = document.getElementsByTagName("library");
					int length = nodeList.getLength();
					for (int i = 0; i < length; i++) {
						var e = (Element)nodeList.item(i);
						var lib = new ProjectLibrary(e.getAttribute("name"));
						var enabled = e.getAttribute("enabled");
						lib.setEnabled(enabled.length() == 0 || !enabled.equals("false"));
						libraries.add(lib);
					}
					nodeList = document.getElementsByTagName("preprocessorSymbols");
					if (nodeList.getLength() == 1) {
						foreach (var s in nodeList.item(0).getTextContent().split(";")) {
							preprocessorSymbols.add(s.trim());
						}
					}
					nodeList = document.getElementsByTagName("outputPath");
					if (nodeList.getLength() == 1) {
						outputPath = nodeList.item(0).getTextContent();
					}
					this.Libraries = libraries;
					this.PreprocessorSymbols = preprocessorSymbols;
					this.OutputPath = outputPath;
					return true;
				} catch (Exception e) {
					Environment.logException(e);
				}
			}
			this.Libraries = Query.empty<ProjectLibrary>();
			this.PreprocessorSymbols = Query.empty<String>();
			return false;
		}
 public String group(String name)
 {
     if (name == null)
     throw new NullReferenceException("Null group name");
     if (first < 0)
     throw new InvalidOperationException("No match found");
     if (!parentPattern.namedGroups().containsKey(name))
     throw new IllegalArgumentException("No group with name <" + name + ">");
     int group = parentPattern.namedGroups().get(name);
     if ((groups[group*2] == -1) || (groups[group*2+1] == -1))
     return null;
     return getSubSequence(groups[group * 2], groups[group * 2 + 1]).toString();
 }
		public ProjectLibrary(String path) {
			this.Path = path;
			this.Enabled = true;
		}
 public void addGenericConstraint(String name, TypeInfo bound) {
     checkCreated();
     foreach (var arg in genericArguments) {
         if (arg.FullName.equals(name)) {
             ((GenericParameterType)arg).genericParameterBounds.add(bound);
             return;
         }
     }
     throw new IllegalStateException("Generic parameter " + name+  " not found");
 }
 public TypeInfo addGenericArgument(String name) {
     checkCreated();
     var type = new GenericParameterType(this.Library, name, null);
     genericArguments.add(type);
     return type;
 }
 public String replaceAll(String replacement)
 {
     reset();
     boolean result = find();
     if (result) {
     StringBuffer sb = new StringBuffer();
     do {
         appendReplacement(sb, replacement);
         result = find();
     } while (result);
     appendTail(sb);
     return sb.toString();
     }
     return text.toString();
 }
 public String replaceFirst(String replacement)
 {
     if (replacement == null)
     throw new NullPointerException("replacement");
     reset();
     if (!find())
     return text.toString();
     StringBuffer sb = new StringBuffer();
     appendReplacement(sb, replacement);
     appendTail(sb);
     return sb.toString();
 }
 public void setSourceFile(String sourceFile) {
     this.sourceFile = sourceFile;
 }
 public Matcher appendReplacement(StringBuffer sb, String replacement)
 {
     // If no match, return error
     if (first < 0)
     throw new InvalidOperationException("No match available");
     // Process substitution string to replace group references with groups
     int cursor = 0;
     StringBuilder result = new StringBuilder();
     while (cursor < replacement.length()) {
     char nextChar = replacement.charAt(cursor);
     if (nextChar == '\\') {
         cursor++;
         nextChar = replacement.charAt(cursor);
         result.append(nextChar);
         cursor++;
     } else if (nextChar == '$') {
         // Skip past $
         cursor++;
         // A StringIndexOutOfBoundsException is thrown if
         // this "$" is the last character in replacement
         // string in current implementation, a IAE might be
         // more appropriate.
         nextChar = replacement.charAt(cursor);
         int refNum = -1;
         if (nextChar == '{') {
             cursor++;
             StringBuilder gsb = new StringBuilder();
             while (cursor < replacement.length()) {
                 nextChar = replacement.charAt(cursor);
                 if (ASCII.isLower(nextChar) ||
                     ASCII.isUpper(nextChar) ||
                     ASCII.isDigit(nextChar)) {
                     gsb.append(nextChar);
                     cursor++;
                 } else {
                     break;
                 }
             }
             if (gsb.length() == 0)
                 throw new IllegalArgumentException(
                     "named capturing group has 0 length name");
             if (nextChar != '}')
                 throw new IllegalArgumentException(
                     "named capturing group is missing trailing '}'");
             String gname = gsb.toString();
             if (ASCII.isDigit(gname.charAt(0)))
                 throw new IllegalArgumentException(
                     "capturing group name {" + gname +
                     "} starts with digit character");
             if (!parentPattern.namedGroups().containsKey(gname))
                 throw new IllegalArgumentException(
                     "No group with name {" + gname + "}");
             refNum = parentPattern.namedGroups().get(gname);
             cursor++;
         } else {
             // The first number is always a group
             refNum = (int)nextChar - '0';
             if ((refNum < 0)||(refNum > 9))
                 throw new IllegalArgumentException(
                     "Illegal group reference");
             cursor++;
             // Capture the largest legal group string
             boolean done = false;
             while (!done) {
                 if (cursor >= replacement.length()) {
                     break;
                 }
                 int nextDigit = replacement.charAt(cursor) - '0';
                 if ((nextDigit < 0)||(nextDigit > 9)) { // not a number
                     break;
                 }
                 int newRefNum = (refNum * 10) + nextDigit;
                 if (groupCount() < newRefNum) {
                     done = true;
                 } else {
                     refNum = newRefNum;
                     cursor++;
                 }
             }
         }
         // Append group
         if (start(refNum) != -1 && end(refNum) != -1)
             result.append(text, start(refNum), end(refNum));
     } else {
         result.append(nextChar);
         cursor++;
     }
     }
     // Append the intervening text
     sb.append(text, lastAppendPosition, first);
     // Append the match substitution
     sb.append(result);
     lastAppendPosition = last;
     return this;
 }
 public void setSourceDebugExtension(String sourceDebugExtension) {
     this.sourceDebugExtension = sourceDebugExtension;
 }