valueOf() 공개 정적인 메소드

public static valueOf ( long l ) : Long
l long
리턴 Long
예제 #1
0
파일: List.cs 프로젝트: syatanic/fantom
        public long binaryFind(Func f)
        {
            object[] values = this.m_values;
            int      low = 0, high = m_size - 1;
            bool     oneArg = f.arity() == 1;

            while (low <= high)
            {
                int    probe = (low + high) >> 1;
                object val   = values[probe];
                object res   = oneArg ? f.call(val) : f.call(val, Long.valueOf(probe));
                long   cmp   = ((Long)res).longValue();
                if (cmp > 0)
                {
                    low = probe + 1;
                }
                else if (cmp < 0)
                {
                    high = probe - 1;
                }
                else
                {
                    return(probe);
                }
            }
            return(-(low + 1));
        }
예제 #2
0
파일: Depend.cs 프로젝트: syatanic/fantom
            private Version version()
            {
                List segs = new List(Sys.IntType, 4);
                int  seg  = consumeDigit();

                while (true)
                {
                    if ('0' <= m_cur && m_cur <= '9')
                    {
                        seg = seg * 10 + consumeDigit();
                    }
                    else
                    {
                        segs.add(Long.valueOf(seg));
                        seg = 0;
                        if (m_cur != '.')
                        {
                            break;
                        }
                        else
                        {
                            consume();
                        }
                    }
                }
                return(new Version(segs));
            }
예제 #3
0
 public static Long fromStr(string s, long radix, bool check)
 {
     try
     {
         return(Long.valueOf(Convert.ToInt64(s, (int)radix)));
     }
     catch (ArgumentException)
     {
         if (!check)
         {
             return(null);
         }
         throw ParseErr.make("Int", s).val;
     }
     catch (OverflowException)
     {
         if (!check)
         {
             return(null);
         }
         throw ParseErr.make("Int", s).val;
     }
     catch (FormatException)
     {
         if (!check)
         {
             return(null);
         }
         throw ParseErr.make("Int", s).val;
     }
 }
예제 #4
0
파일: Range.cs 프로젝트: Mzazvor/fantom
        public List toList()
        {
            int  start = (int)m_start;
            int  end   = (int)m_end;
            List acc   = new List(Sys.IntType);

            if (start < end)
            {
                if (m_exclusive)
                {
                    --end;
                }
                acc.capacity(end - start + 1);
                for (int i = start; i <= end; ++i)
                {
                    acc.add(Long.valueOf(i));
                }
            }
            else
            {
                if (m_exclusive)
                {
                    ++end;
                }
                acc.capacity(start - end + 1);
                for (int i = start; i >= end; --i)
                {
                    acc.add(Long.valueOf(i));
                }
            }
            return(acc);
        }
예제 #5
0
        public static Long fromDigit(long self, long radix)
        {
            int val = (int)self;

            if (val < 0 || val >= 128)
            {
                return(null);
            }
            int r = (int)radix;

            int ten = r < 10 ? r : 10;

            if ('0' <= val && val < '0' + ten)
            {
                return(Long.valueOf(val - '0'));
            }
            if (r > 10)
            {
                int alpha = r - 10;
                if ('a' <= val && val < 'a' + alpha)
                {
                    return(Long.valueOf(val + 10 - 'a'));
                }
                if ('A' <= val && val < 'A' + alpha)
                {
                    return(Long.valueOf(val + 10 - 'A'));
                }
            }
            return(null);
        }
예제 #6
0
파일: List.cs 프로젝트: syatanic/fantom
        public Long indexSame(object val, long off)
        {
            if (m_size == 0)
            {
                return(null);
            }
            int start = (int)off;

            if (start < 0)
            {
                start = m_size + start;
            }
            if (start >= m_size)
            {
                throw IndexErr.make(off).val;
            }

            try
            {
                for (int i = start; i < m_size; i++)
                {
                    if (val == m_values[i])
                    {
                        return(Long.valueOf(i));
                    }
                }
                return(null);
            }
            catch (IndexOutOfRangeException)
            {
                throw IndexErr.make(off).val;
            }
        }
예제 #7
0
        public static Long index(string self, string s, long off)
        {
            int i = (int)off;

            if (i < 0)
            {
                i = self.Length + i;
            }

            int r;

            if (s.Length == 1)
            {
                r = self.IndexOf(s[0], i);
            }
            else
            {
                r = self.IndexOf(s, i);
            }

            if (r < 0)
            {
                return(null);
            }
            return(Long.valueOf(r));
        }
예제 #8
0
파일: Range.cs 프로젝트: Mzazvor/fantom
 public Long first()
 {
     if (isEmpty())
     {
         return(null);
     }
     return(Long.valueOf(m_start));
 }
예제 #9
0
파일: MemBuf.cs 프로젝트: syatanic/fantom
 public override Long peek()
 {
     if (p.m_pos >= p.m_size)
     {
         return(null);
     }
     return(Long.valueOf(p.m_buf[p.m_pos] & 0xFF));
 }
예제 #10
0
 public override object trap(string name, List args)
 {
     // private undocumented access
     if (name == "flags")
     {
         return(Long.valueOf(flags()));
     }
     return(base.trap(name, args));
 }
예제 #11
0
        public static Version fromStr(string s, bool check)
        {
            List segments = new List(Sys.IntType, 4);
            int  seg      = -1;
            bool valid    = true;
            int  len      = s.Length;

            for (int i = 0; i < len; ++i)
            {
                int c = s[i];
                if (c == '.')
                {
                    if (seg < 0 || i + 1 >= len)
                    {
                        valid = false; break;
                    }
                    segments.add(Long.valueOf(seg));
                    seg = -1;
                }
                else
                {
                    if ('0' <= c && c <= '9')
                    {
                        if (seg < 0)
                        {
                            seg = c - '0';
                        }
                        else
                        {
                            seg = seg * 10 + (c - '0');
                        }
                    }
                    else
                    {
                        valid = false; break;
                    }
                }
            }
            if (seg >= 0)
            {
                segments.add(Long.valueOf(seg));
            }

            if (!valid || segments.sz() == 0)
            {
                if (check)
                {
                    throw ParseErr.make("Version", s).val;
                }
                else
                {
                    return(null);
                }
            }

            return(new Version(segments));
        }
예제 #12
0
 public override Long size()
 {
     if (m_file is DirectoryInfo)
     {
         return(null);
     }
     m_file.Refresh();
     return(Long.valueOf((m_file as FileInfo).Length));
 }
예제 #13
0
        public static Long toDigit(long self)
        {
            long val = self;

            if (0 <= val && val <= 9)
            {
                return(Long.valueOf((int)val + '0'));
            }
            return(null);
        }
예제 #14
0
        public static Long fromDigit(long self)
        {
            long val = self;

            if ('0' <= val && val <= '9')
            {
                return(Long.valueOf((int)val - '0'));
            }
            return(null);
        }
예제 #15
0
파일: List.cs 프로젝트: syatanic/fantom
 public Long findIndex(Func f)
 {
     for (int i = 0; i < m_size; ++i)
     {
         long pos = i;
         if (f.call(m_values[i], pos) == Boolean.True)
         {
             return(Long.valueOf(pos));
         }
     }
     return(null);
 }
예제 #16
0
파일: MemBuf.cs 프로젝트: syatanic/fantom
            public override Long readBuf(Buf other, long n)
            {
                if (p.m_pos >= p.m_size)
                {
                    return(null);
                }
                int len = Math.Min(p.m_size - p.m_pos, (int)n);

                other.pipeFrom(p.m_buf, p.m_pos, len);
                p.m_pos += len;
                return(Long.valueOf(len));
            }
예제 #17
0
파일: Range.cs 프로젝트: Mzazvor/fantom
 public Long max()
 {
     if (isEmpty())
     {
         return(null);
     }
     if (m_end < m_start)
     {
         return(Long.valueOf(m_start));
     }
     return(Long.valueOf(m_exclusive ? m_end - 1 : m_end));
 }
예제 #18
0
 public override object trap(string name, List args)
 {
     // private undocumented access
     if (name == "lineNumber")
     {
         reflect(); return(Long.valueOf(m_lineNum));
     }
     if (name == "sourceFile")
     {
         reflect(); return(m_sourceFile);
     }
     return(base.trap(name, args));
 }
예제 #19
0
        public override Long size()
        {
            if (isDir())
            {
                return(null);
            }
            long size = m_entry.Size;

            if (size < 0)
            {
                return(null);
            }
            return(Long.valueOf(size));
        }
예제 #20
0
 public override Long peek()
 {
     try
     {
         long pos = p.getPos();
         int  n   = p.m_stream.ReadByte();
         p.setPos(pos);
         return(n < 0 ? null : Long.valueOf(n));
     }
     catch (IOException e)
     {
         throw IOErr.make(e).val;
     }
 }
예제 #21
0
파일: Unit.cs 프로젝트: syatanic/fantom
        /**
         * Parse an dimension string and intern it:
         *   dim    := <ratio> ["*" <ratio>]*
         *   ratio  := <base> <exp>
         *   base   := "kg" | "m" | "sec" | "K" | "A" | "mol" | "cd"
         */
        private static Dimension parseDim(string s)
        {
            // handle empty string as dimensionless
            if (s.Length == 0)
            {
                return(m_dimensionless);
            }

            // parse dimension
            Dimension dim    = new Dimension();
            List      ratios = FanStr.split(s, Long.valueOf((long)'*'), true);

            for (int i = 0; i < ratios.sz(); ++i)
            {
                string r = (string)ratios.get(i);
                if (r.StartsWith("kg"))
                {
                    dim.kg = SByte.Parse(r.Substring(2).Trim()); continue;
                }
                if (r.StartsWith("sec"))
                {
                    dim.sec = SByte.Parse(r.Substring(3).Trim()); continue;
                }
                if (r.StartsWith("mol"))
                {
                    dim.mol = SByte.Parse(r.Substring(3).Trim()); continue;
                }
                if (r.StartsWith("m"))
                {
                    dim.m = SByte.Parse(r.Substring(1).Trim()); continue;
                }
                if (r.StartsWith("K"))
                {
                    dim.K = SByte.Parse(r.Substring(1).Trim()); continue;
                }
                if (r.StartsWith("A"))
                {
                    dim.A = SByte.Parse(r.Substring(1).Trim()); continue;
                }
                if (r.StartsWith("cd"))
                {
                    dim.cd = SByte.Parse(r.Substring(2).Trim()); continue;
                }
                throw new Exception("Bad ratio '" + r + "'");
            }

            // intern
            return(dim.intern());
        }
예제 #22
0
파일: Slot.cs 프로젝트: syatanic/fantom
        public override object trap(string name, List args)
        {
            // private undocumented access
            string n = name;

            if (n == "flags")
            {
                return(Long.valueOf(m_flags));
            }
            if (n == "lineNumber")
            {
                return(Long.valueOf(m_lineNum));
            }
            return(base.trap(name, args));
        }
예제 #23
0
        //////////////////////////////////////////////////////////////////////////
        // Iterators
        //////////////////////////////////////////////////////////////////////////

        public static List chars(string self)
        {
            int len = self.Length;

            if (len == 0)
            {
                return(Sys.IntType.emptyList());
            }
            Long[] chars = new Long[len];
            for (int i = 0; i < len; ++i)
            {
                chars[i] = Long.valueOf(self[i]);
            }
            return(new List(Sys.IntType, chars));
        }
예제 #24
0
파일: Range.cs 프로젝트: Mzazvor/fantom
 public Long last()
 {
     if (isEmpty())
     {
         return(null);
     }
     if (!m_exclusive)
     {
         return(Long.valueOf(m_end));
     }
     if (m_start < m_end)
     {
         return(Long.valueOf(m_end - 1));
     }
     return(Long.valueOf(m_end + 1));
 }
예제 #25
0
 public override Long readBuf(Buf other, long n)
 {
     try
     {
         long read = other.pipeFrom(p.m_stream, n);
         if (read < 0)
         {
             return(null);
         }
         return(Long.valueOf(read));
     }
     catch (IOException e)
     {
         throw IOErr.make(e).val;
     }
 }
예제 #26
0
 public override Long readBuf(Buf buf, long n)
 {
     try
     {
         long read = buf.pipeFrom(inStream, n);
         if (read <= 0)
         {
             return(null);
         }
         return(Long.valueOf(read));
     }
     catch (IOException e)
     {
         throw IOErr.make(e).val;
     }
 }
예제 #27
0
        public static Long toDigit(long self, long radix)
        {
            int val = (int)self;
            int r   = (int)radix;

            if (val < 0 || val >= r)
            {
                return(null);
            }

            if (val < 10)
            {
                return(Long.valueOf(val + '0'));
            }
            return(Long.valueOf(val - 10 + 'a'));
        }
예제 #28
0
파일: List.cs 프로젝트: syatanic/fantom
        public Long indexr(object val, long off)
        {
            if (m_size == 0)
            {
                return(null);
            }
            int start = (int)off;

            if (start < 0)
            {
                start = m_size + start;
            }
            if (start >= m_size)
            {
                throw IndexErr.make(off).val;
            }

            try
            {
                if (val == null)
                {
                    for (int i = start; i >= 0; --i)
                    {
                        if (m_values[i] == null)
                        {
                            return(Long.valueOf(i));
                        }
                    }
                }
                else
                {
                    for (int i = start; i >= 0; --i)
                    {
                        object obj = m_values[i];
                        if (obj != null && obj.Equals(val))
                        {
                            return(Long.valueOf(i));
                        }
                    }
                }
                return(null);
            }
            catch (IndexOutOfRangeException)
            {
                throw IndexErr.make(off).val;
            }
        }
예제 #29
0
        public static Long indexrIgnoreCase(string self, string s, long off)
        {
            int vlen = self.Length, slen = s.Length;
            int r = -1;

            int i = (int)off;

            if (i < 0)
            {
                i = vlen + i;
            }
            if (i + slen >= vlen)
            {
                i = vlen - slen;
            }

            int first = s[0];

            for (; i >= 0; --i)
            {
                // test first char
                if (neic(first, self[i]))
                {
                    continue;
                }

                // test remainder of chars
                r = i;
                for (int si = 1, vi = i + 1; si < slen; ++si, ++vi)
                {
                    if (neic(s[si], self[vi]))
                    {
                        r = -1; break;
                    }
                }
                if (r >= 0)
                {
                    break;
                }
            }

            if (r < 0)
            {
                return(null);
            }
            return(Long.valueOf(r));
        }
예제 #30
0
        public static Long indexr(string self, string s, long off)
        {
            int i = (int)off;

            if (i < 0)
            {
                i = self.Length + i;
            }

            int r;

            if (s.Length == 1)
            {
                r = self.LastIndexOf(s[0], i);
            }
            else
            {
                // this doesn't match Java impl - so we have to roll
                // our own - prob alot of room for improvement...
                //r = val.LastIndexOf(sval, i, StringComparison.InvariantCulture);

                int len  = self.Length;
                int slen = s.Length;
                if (len < slen)
                {
                    return(null);
                }
                r = -1;
                for (; i >= 0; i--)
                {
                    if (nStartsWith(self, s, i))
                    {
                        r = i; break;
                    }
                }
            }

            if (r < 0)
            {
                return(null);
            }
            return(Long.valueOf(r));
        }