javauis/lcdui_akn/javalcdui/javasrc/javax/microedition/lcdui/Ticker.java
branchRCL_3
changeset 24 6c158198356e
parent 14 04becd199f91
equal deleted inserted replaced
23:e5618cc85d74 24:6c158198356e
    26 {
    26 {
    27     final Toolkit iToolkit;
    27     final Toolkit iToolkit;
    28     private int iHandle;
    28     private int iHandle;
    29     private String iText;
    29     private String iText;
    30     private Finalizer mFinalizer;
    30     private Finalizer mFinalizer;
       
    31     private static final int MAX_TICKER_SIZE = 8000;    // less than 8KB
    31 
    32 
    32     public Ticker(String aText)
    33     public Ticker(String aText)
    33     {
    34     {
    34         if (null == aText)
    35         if (null == aText)
    35         {
    36         {
    36             throw new NullPointerException();
    37             throw new NullPointerException();
    37         }
    38         }
       
    39         else if (aText.length() > MAX_TICKER_SIZE)
       
    40         {
       
    41             aText = aText.substring(0, MAX_TICKER_SIZE - 1);
       
    42         }
       
    43 
    38         mFinalizer = new Finalizer()
    44         mFinalizer = new Finalizer()
    39         {
    45         {
    40             public void finalizeImpl()
    46             public void finalizeImpl()
    41             {
    47             {
    42                 doFinalize();
    48                 doFinalize();
    55     {
    61     {
    56         if (null == aText)
    62         if (null == aText)
    57         {
    63         {
    58             throw new NullPointerException();
    64             throw new NullPointerException();
    59         }
    65         }
       
    66         else if (aText.length() > MAX_TICKER_SIZE)
       
    67         {
       
    68             aText = aText.substring(0, MAX_TICKER_SIZE - 1);
       
    69         }
       
    70 
    60         synchronized (iToolkit)
    71         synchronized (iToolkit)
    61         {
    72         {
    62             if (iHandle <= 0) throw new RuntimeException("bad handle");
    73             if (iHandle <= 0) throw new RuntimeException("bad handle");
    63             NativeError.check(_setText(iHandle,iToolkit.getHandle(),aText));
    74             NativeError.check(_setText(iHandle,iToolkit.getHandle(),aText));
    64             iText = aText;
    75             iText = aText;