intValue() public method

public intValue ( ) : int
return int
示例#1
0
 public static Stream toBuffered(Stream output, Long bufSize)
 {
     if (bufSize == null || bufSize.longValue() == 0)
     return output;
       else
     return new BufferedStream(output, bufSize.intValue());
 }
示例#2
0
        public static List split(string self, Long separator, bool trim)
        {
            if (separator == null)
            {
                return(splitws(self));
            }
            int  sep  = separator.intValue();
            List toks = new List(Sys.StrType, 16);
            int  len  = self.Length;
            int  x    = 0;

            for (int i = 0; i < len; ++i)
            {
                if (self[i] != sep)
                {
                    continue;
                }
                if (x <= i)
                {
                    toks.add(splitStr(self, x, i, trim));
                }
                x = i + 1;
            }
            if (x <= len)
            {
                toks.add(splitStr(self, x, len, trim));
            }
            return(toks);
        }
示例#3
0
 //////////////////////////////////////////////////////////////////////////
 // Constructor
 //////////////////////////////////////////////////////////////////////////
 public static SysInStream make(Stream input, Long bufSize)
 {
     if (bufSize == null || bufSize.longValue() == 0)
     return new SysInStream(input);
       else
     return new SysInStream(new BufferedStream(input, bufSize.intValue()));
 }
示例#4
0
        public override InStream @in(Long bufSize)
        {
            try
              {
            System.IO.Stream ins;
            if (m_parent is Zip)
            {
              // never buffer if using ZipInputStream
              ins = new ZipEntryInputStream((m_parent as Zip).m_zipIn);
            }
            else
            {
              ins = (m_parent as ZipFile).GetInputStream(m_entry);

              // buffer if specified
              if (bufSize != null && bufSize.longValue() != 0)
            ins = new System.IO.BufferedStream(ins, bufSize.intValue());
            }

            // return as fan stream
            return new SysInStream(ins);
              }
              catch (System.IO.IOException e)
              {
            throw IOErr.make(e).val;
              }
        }
示例#5
0
        public override InStream @in(Long bufSize)
        {
            try
            {
                System.IO.Stream ins;
                if (m_parent is Zip)
                {
                    // never buffer if using ZipInputStream
                    ins = new ZipEntryInputStream((m_parent as Zip).m_zipIn);
                }
                else
                {
                    ins = (m_parent as ZipFile).GetInputStream(m_entry);

                    // buffer if specified
                    if (bufSize != null && bufSize.longValue() != 0)
                    {
                        ins = new System.IO.BufferedStream(ins, bufSize.intValue());
                    }
                }

                // return as fan stream
                return(new SysInStream(ins));
            }
            catch (System.IO.IOException e)
            {
                throw IOErr.make(e).val;
            }
        }
示例#6
0
        public static string toRadix(long self, long radix, Long width)
        {
            string s = Convert.ToString(self, (int)radix);

            if (width != null && s.Length < width.intValue())
            {
                StringBuilder sb    = new StringBuilder(width.intValue());
                int           zeros = width.intValue() - s.Length;
                for (int i = 0; i < zeros; ++i)
                {
                    sb.Append('0');
                }
                sb.Append(s);
                s = sb.ToString();
            }
            return(s);
        }
示例#7
0
        //////////////////////////////////////////////////////////////////////////
        // C# Stream
        //////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Read a byte using a Java primitive int.  Most
        /// reads route to this method for efficient mapping to
        /// a java.io.InputStream.  If we aren't overriding this
        /// method, then route back to read() for the subclass
        /// to handle.
        /// </summary>
        public virtual int r()
        {
            Long n = read();

            if (n == null)
            {
                return(-1);
            }
            return(n.intValue());
        }
示例#8
0
        public virtual string readStrToken(Long max, Func f)
        {
            // max limit
            int maxChars = (max != null) ? max.intValue() : System.Int32.MaxValue;

            if (maxChars <= 0)
            {
                return(string.Empty);
            }

            // read first char, if at end of file bail
            int c = rChar();

            if (c < 0)
            {
                return(null);
            }

            // loop reading chars until our closure returns false
            StringBuilder buf = new StringBuilder();

            while (true)
            {
                // check for \n, \r\n, or \r
                bool terminate;
                if (f == null)
                {
                    terminate = FanInt.isSpace(c);
                }
                else
                {
                    terminate = ((Boolean)f.call(c)).booleanValue();
                }
                if (terminate)
                {
                    unreadChar(c);
                    break;
                }

                // Append to working buffer
                buf.Append((char)c);
                if (buf.Length >= maxChars)
                {
                    break;
                }

                // read next char
                c = rChar();
                if (c < 0)
                {
                    break;
                }
            }
            return(buf.ToString());
        }
示例#9
0
 //////////////////////////////////////////////////////////////////////////
 // Methods
 //////////////////////////////////////////////////////////////////////////
 public TcpListener bind(TcpListener fan, IpAddr addr, Long port, long backlog)
 {
     IPAddress dotnetAddr = (addr == null) ? IPAddress.Any : addr.m_peer.m_dotnet;
       int dotnetPort = (port == null) ? 0 : port.intValue();
       m_dotnet = new System.Net.Sockets.TcpListener(dotnetAddr, dotnetPort);
       m_dotnet.Server.ReceiveBufferSize = (int)m_receiveBufferSize;
       m_dotnet.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, m_reuseAddr);
       m_dotnet.Start((int)backlog);
       m_bound = true;
       return fan;
 }
示例#10
0
 public static Stream toBuffered(Stream output, Long bufSize)
 {
     if (bufSize == null || bufSize.longValue() == 0)
     {
         return(output);
     }
     else
     {
         return(new BufferedStream(output, bufSize.intValue()));
     }
 }
示例#11
0
        //////////////////////////////////////////////////////////////////////////
        // Constructor
        //////////////////////////////////////////////////////////////////////////

        public static SysInStream make(Stream input, Long bufSize)
        {
            if (bufSize == null || bufSize.longValue() == 0)
            {
                return(new SysInStream(input));
            }
            else
            {
                return(new SysInStream(new BufferedStream(input, bufSize.intValue())));
            }
        }
示例#12
0
            // Methods
            public override int Read(byte[] b, int off, int len)
            {
                buf.m_buf  = b;
                buf.m_pos  = off;
                buf.m_size = b.Length;
                Long n = ins.readBuf(buf, len);

                buf.m_buf = null;
                if (n == null)
                {
                    return(-1);
                }
                return(n.intValue());
            }
示例#13
0
 //////////////////////////////////////////////////////////////////////////
 // Communication
 //////////////////////////////////////////////////////////////////////////
 public UdpSocket bind(UdpSocket fan, IpAddr addr, Long port)
 {
     try
       {
     if (m_dotnet == null) m_dotnet = createSocket();
     IPAddress dotnetAddr = (addr == null) ? IPAddress.Any : addr.m_peer.m_dotnet;
     int dotnetPort = (port == null) ? 0 : port.intValue();
     m_dotnet.Bind(new IPEndPoint(dotnetAddr, dotnetPort));
     return fan;
       }
       catch (SocketException e)
       {
     throw IOErr.make(e).val;
       }
 }
示例#14
0
        public static string toCode(string self, Long quote, bool escapeUnicode)
        {
            StringBuilder s = new StringBuilder(self.Length + 10);

            // opening quote
            bool escu = escapeUnicode;
            int  q    = 0;

            if (quote != null)
            {
                q = quote.intValue();
                s.Append((char)q);
            }

            // NOTE: these escape sequences are duplicated in ObjEncoder
            int len = self.Length;

            for (int i = 0; i < len; ++i)
            {
                int c = self[i];
                switch (c)
                {
                case '\n': s.Append('\\').Append('n'); break;

                case '\r': s.Append('\\').Append('r'); break;

                case '\f': s.Append('\\').Append('f'); break;

                case '\t': s.Append('\\').Append('t'); break;

                case '\\': s.Append('\\').Append('\\'); break;

                case '"':  if (q == '"')
                    {
                        s.Append('\\').Append('"');
                    }
                    else
                    {
                        s.Append((char)c);
                    } break;

                case '`':  if (q == '`')
                    {
                        s.Append('\\').Append('`');
                    }
                    else
                    {
                        s.Append((char)c);
                    } break;

                case '\'': if (q == '\'')
                    {
                        s.Append('\\').Append('\'');
                    }
                    else
                    {
                        s.Append((char)c);
                    } break;

                case '$':  s.Append('\\').Append('$'); break;

                default:
                    if (c < ' ' || (escu && c > 127))
                    {
                        s.Append('\\').Append('u')
                        .Append((char)hex((c >> 12) & 0xf))
                        .Append((char)hex((c >> 8) & 0xf))
                        .Append((char)hex((c >> 4) & 0xf))
                        .Append((char)hex(c & 0xf));
                    }
                    else
                    {
                        s.Append((char)c);
                    }
                    break;
                }
            }

            // closing quote
            if (q != 0)
            {
                s.Append((char)q);
            }

            return(s.ToString());
        }
示例#15
0
文件: FanInt.cs 项目: xored/f4
 public static string toRadix(long self, long radix, Long width)
 {
     string s = Convert.ToString(self, (int)radix);
       if (width != null && s.Length < width.intValue())
       {
     StringBuilder sb = new StringBuilder(width.intValue());
     int zeros = width.intValue() - s.Length;
     for (int i=0; i<zeros; ++i) sb.Append('0');
     sb.Append(s);
     s = sb.ToString();
       }
       return s;
 }
示例#16
0
文件: InStream.cs 项目: nomit007/f4
        public virtual string readStrToken(Long max, Func f)
        {
            // max limit
              int maxChars = (max != null) ? max.intValue() : System.Int32.MaxValue;
              if (maxChars <= 0) return string.Empty;

              // read first char, if at end of file bail
              int c = rChar();
              if (c < 0) return null;

              // loop reading chars until our closure returns false
              StringBuilder buf = new StringBuilder();
              while (true)
              {
            // check for \n, \r\n, or \r
            bool terminate;
            if (f == null)
              terminate = FanInt.isSpace(c);
            else
              terminate = ((Boolean)f.call(c)).booleanValue();
            if (terminate)
            {
              unreadChar(c);
              break;
            }

            // Append to working buffer
            buf.Append((char)c);
            if (buf.Length >= maxChars) break;

            // read next char
            c = rChar();
            if (c < 0) break;
              }
              return buf.ToString();
        }
示例#17
0
文件: FanInt.cs 项目: nomit007/f4
 public static string toHex(long self, Long width)
 {
     long val = self;
       string s = val.ToString("X").ToLower();
       if (width != null && s.Length < width.intValue())
       {
     StringBuilder sb = new StringBuilder(width.intValue());
     int zeros = width.intValue() - s.Length;
     for (int i=0; i<zeros; ++i) sb.Append('0');
     sb.Append(s);
     s = sb.ToString();
       }
       return s;
 }
示例#18
0
 public void setOutBufferSize(TcpSocket fan, Long v)
 {
     if (m_in != null) throw Err.make("Must set outBufSize before connection").val;
       m_outBufSize = (v == null) ? 0 : v.intValue();
 }
示例#19
0
文件: FanStr.cs 项目: xored/f4
        public static string toCode(string self, Long quote, bool escapeUnicode)
        {
            StringBuilder s = new StringBuilder(self.Length+10);

              // opening quote
              bool escu = escapeUnicode;
              int q = 0;
              if (quote != null)
              {
            q = quote.intValue();
            s.Append((char)q);
              }

              // NOTE: these escape sequences are duplicated in ObjEncoder
              int len = self.Length;
              for (int i=0; i<len; ++i)
              {
            int c = self[i];
            switch (c)
            {
              case '\n': s.Append('\\').Append('n'); break;
              case '\r': s.Append('\\').Append('r'); break;
              case '\f': s.Append('\\').Append('f'); break;
              case '\t': s.Append('\\').Append('t'); break;
              case '\\': s.Append('\\').Append('\\'); break;
              case '"':  if (q == '"')  s.Append('\\').Append('"');  else s.Append((char)c); break;
              case '`':  if (q == '`')  s.Append('\\').Append('`');  else s.Append((char)c); break;
              case '\'': if (q == '\'') s.Append('\\').Append('\''); else s.Append((char)c); break;
              case '$':  s.Append('\\').Append('$'); break;
              default:
            if (c < ' ' || (escu && c > 127))
            {
              s.Append('\\').Append('u')
               .Append((char)hex((c>>12)&0xf))
               .Append((char)hex((c>>8)&0xf))
               .Append((char)hex((c>>4)&0xf))
               .Append((char)hex(c&0xf));
            }
            else
            {
              s.Append((char)c);
            }
            break;
            }
              }

              // closing quote
              if (q != 0) s.Append((char)q);

              return s.ToString();
        }
示例#20
0
文件: FanStr.cs 项目: xored/f4
 public static List split(string self, Long separator, bool trim)
 {
     if (separator == null) return splitws(self);
       int sep = separator.intValue();
       List toks = new List(Sys.StrType, 16);
       int len = self.Length;
       int x = 0;
       for (int i=0; i<len; ++i)
       {
     if (self[i] != sep) continue;
     if (x <= i) toks.add(splitStr(self, x, i, trim));
     x = i+1;
       }
       if (x <= len) toks.add(splitStr(self, x, len, trim));
       return toks;
 }