找回密码
 加入我们

QQ登录

只需一步,快速开始

搜索
查看: 2826|回复: 10

[webOS开发] Service 的修改方法

[复制链接]
发表于 2009-7-25 17:56 | 显示全部楼层 |阅读模式
谢谢捧场" k3 n$ d5 B1 h; ?, }8 Z) Q  E

$ P2 \/ g: p/ h! T[ 本帖最后由 mfly 于 2009-7-31 16:09 编辑 ]

评分

参与人数 1威望 +50 收起 理由
CyberVsQ + 50 谢谢分享

查看全部评分

回复

使用道具 举报

发表于 2009-7-25 20:59 | 显示全部楼层
支持!!!
回复 支持 反对

使用道具 举报

发表于 2009-7-26 01:04 | 显示全部楼层
谢谢分享
回复 支持 反对

使用道具 举报

发表于 2009-7-26 01:09 | 显示全部楼层
Services 這一个我还是似懂非懂.
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:17 | 显示全部楼层
用这个方法,结果出现这样,哪里不对呢?请指教,谢谢
  1. package com.palm.messagingrouter;
    ( p+ U, K/ y3 U0 D! Z% o
  2. 5 `% |% C9 C+ M( B% F' Q
  3. import Association.Many;) q5 L& ^( n2 L; k
  4. import com.palm.oasis.util.ZoneLogger;
    ( N3 {; b& u  y) G. \# `
  5. 4 ?* y, S) H+ c3 Z) C& }
  6. public class SmsMessageSegmentContainer extends MessageSegmentContainer% c/ u+ G: a0 g1 Q' _
  7.   implements MessagingRouterJsonConstants, MessagingRouterTilConstants- Y! y) z7 a/ o- C
  8. {7 ?6 H/ t2 K4 H1 A! q* a
  9.   private static final long serialVersionUID = 1L;0 z* S3 ]7 |9 n: C* w  @7 ~
  10.   private String completeMsgString;
    + X/ N( s4 _/ M0 f& w
  11.   private String bodyEncoding;2 s7 }6 q7 k( h  @! D1 p* L
  12.   protected static ZoneLogger logger;& Y: h9 N7 i7 A
  13.   Many segments;
    ( o- X9 e% J7 s% u( V2 F

  14. 9 H- H0 [+ N& o$ J7 F( ?3 V
  15.   public SmsMessageSegmentContainer()9 Y2 H/ U6 j  y( `9 R5 U
  16.   {
    0 t0 a7 D* u" x1 L/ O( s" U: }
  17.   }/ j- B! @5 v" C  W6 _7 X
  18. , {: s2 \/ k+ b, B; w! k
  19.   public SmsMessageSegmentContainer(long messageId, int totalSegments, String bodyEncoding)
    $ Q2 i0 I  `8 P% @9 `# `, A5 }
  20.   {
    7 Q, p' m) K7 G
  21.   }8 Z  X' r, ]0 c: t7 _9 l

  22. ) ~4 @; G" }0 O# h& E, K5 J
  23.   SmsMessageSegmentContainer(String messageId, int totalSegments, String bodyEncoding)
    ! c# n/ x0 v6 S2 K6 x: R
  24.   {
    - A4 G4 Z+ c  w4 _
  25.   }' y  C& T8 ]6 B( }

  26. , t' ]# @% E5 }% |/ k+ f$ L+ g
  27.   public String getBodyEncoding()4 U3 K2 Z( K6 h4 @! F1 A+ W
  28.   {6 A. K: _# E8 W& P
  29.     throw new Error("Unresolved compilation problem: \n");" N) _  L! P5 C" ?8 v2 b; r0 f
  30.   }
    # Q* w& l) D& j

  31. * h- \; Y# i' T" C, A
  32.   protected boolean isPrintableChar(char ch)2 t/ l, a. B. C3 r4 s
  33.   {
    # \/ A' Y& B! c/ I
  34.     throw new Error("Unresolved compilation problem: \n");  x: y/ A. A: B. W( ^; ^
  35.   }' v7 ]3 g8 f4 u6 \! O# x7 Z
  36. 1 z7 a' x7 e5 ], C; e8 h( Y
  37.   public boolean isMessageComplete()
    / @. i* |) W; n# c
  38.   {* e* N- i. R8 [7 f( ~
  39.     throw new Error("Unresolved compilation problem: \n\tMany cannot be resolved to a type\n");
    + j4 }$ k9 [, X0 a- F0 x
  40.   }
    0 u) J3 \! M7 H4 a# u5 x: u
  41. 5 Y, b/ Y/ j/ q
  42.   public String getCompletedBody()
    * ]5 b, l$ W9 i8 Y$ ?1 G
  43.   {# ]# P4 V5 L7 y4 r- G
  44.     throw new Error("Unresolved compilation problem: \n");* X# I) h, M, N  o5 x: K3 C4 G
  45.   }$ `# W& ~& \3 P' \0 f/ f

  46. : l6 P- D! Q2 a$ G
  47.   public void addNewSegment(SmsMessageFromTil msgSegment)
    ) S1 \1 R5 E; F) p8 P
  48.   {/ _/ x' `& M+ S; m" \1 i
  49.     throw new Error("Unresolved compilation problems: \n\tMany cannot be resolved to a type\n\tMany cannot be resolved to a type\n");
    , ?& @) w) `) {$ j1 W
  50.   }4 `" d1 x( U% ]' T7 u, |

  51. 2 ?* |* c/ g3 C0 g6 w: \& D0 X
  52.   private String convertToJson(boolean doHidePrivateData)' e# F8 u) T: G  l; n- E, `9 U
  53.   {$ J7 @  d0 W2 s; J: f7 }
  54.     throw new Error("Unresolved compilation problems: \n\tMany cannot be resolved to a type\n\tSyntax error on token ":", ; expected\n\tSyntax error, insert "AssignmentOperator Expression" to complete Assignment\n\tSyntax error, insert ";" to complete Statement\n\tString cannot be resolved\n\tjsonString cannot be resolved\n\tjsonString cannot be resolved\n\tjsonString cannot be resolved\n");
    # B$ m1 {' W2 w4 Y6 N/ S1 z' y
  55.   }% o6 r2 [+ T0 U4 C7 V, k/ t

  56. 1 ~/ m4 y8 }  F* s0 B6 D
  57.   public String toJSONString()
    , q& W. a; E0 t$ }! b3 P+ V
  58.   {
    - M! L7 d9 ]7 o8 \( n. C: ^, s
  59.     throw new Error("Unresolved compilation problem: \n");
    # L/ N  _* d9 r( E. E; }- _" D1 }: L
  60.   }
    3 N- A( V0 c( x; N, H" E7 j

  61. ; j* Y( `5 T9 c1 n: e
  62.   public String toDebugJSONString()  Z4 n) Q5 m: X7 s
  63.   {' \/ ]2 D, N. H) l* t
  64.     throw new Error("Unresolved compilation problem: \n");' B5 G0 d% v. Q) E. B
  65.   }2 q7 ^  I# |# I0 n7 x
  66. }
复制代码
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:23 | 显示全部楼层

原始代码是这样的

  1. package com.palm.messagingrouter;
    $ e4 n* ]* L9 w8 O. _' y4 {
  2. 9 ^, z$ Y7 x( g# {! E
  3. import com.palm.oasis.activerecord.ActiveRecord;( ^* j, ~2 r# V9 u* X/ o# P
  4. import com.palm.oasis.activerecord.ActiveRecordException;
    6 V& X2 H5 k" l' I
  5. import com.palm.oasis.activerecord.Association.Many;+ a& R* H, M' |) l2 ~
  6. import com.palm.oasis.activerecord.Batch;
    & ?! y* U% @+ N
  7. import com.palm.oasis.activerecord.SqlFind;
    1 s! z0 |7 Y8 e1 \: _
  8. import com.palm.oasis.util.Base64;. R' W$ C1 Y% b
  9. import com.palm.oasis.util.ServiceLogger;
    9 o# D! m' a6 `
  10. import com.palm.oasis.util.ZoneLogger;9 F) `/ z! _9 a3 F
  11. import java.io.ByteArrayOutputStream;
    ( f4 D3 u% f" y8 P" y
  12. import java.io.IOException;8 x9 z  N* ~# B" c
  13. import java.io.PrintStream;
      }" V+ f2 z3 S3 X5 S
  14. import java.util.Iterator;
    * K- P3 o4 b0 \1 m; n& P# b8 C
  15. import java.util.List;4 V; p) Z' R3 n) K
  16. import org.json.JSONException;
    " P5 y/ E( {* e& m6 a8 N
  17. import org.json.JSONObject;4 _+ h4 \" d7 U' W

  18. ! F( t& w4 |& U5 c* x
  19. public class SmsMessageSegmentContainer extends MessageSegmentContainer
    5 X! a9 j& D( N5 r* M
  20.   implements MessagingRouterJsonConstants, MessagingRouterTilConstants
      ^( M+ v6 S. s+ d7 D$ z
  21. {
    ; ^& C( R: y3 i: K/ g
  22.   private static final long serialVersionUID = 1L;
    & s" C) ~' _8 L6 |3 }
  23.   private String completeMsgString;
    3 K5 S& ~. S2 J. R* G' Q; ]1 W
  24.   private String bodyEncoding;) V0 m' K* B* h  e
  25.   protected static ZoneLogger logger = MessagingRouterService.getLogger(SmsMessageSegmentContainer.class.getSimpleName());
    / B$ Y7 w7 a& g7 Q6 V3 F4 N
  26.   Association.Many segments;
    , y1 ?) o# z- v* R

  27. - a+ j  N+ M0 n2 r
  28.   public SmsMessageSegmentContainer()
    ) r+ z2 f& f4 X" r" \6 {4 X
  29.   {* B2 z7 m+ w8 v  G! C
  30.     this.completeMsgString = null;% U$ M; t9 B4 O" q
  31.     this.bodyEncoding = null;
    # O, N+ r) M" u! {3 M2 ?
  32.     this.segments = hasMany(SmsMessageFromTil.class, 1);
    : V. r4 Q& m) K; C5 |* \+ b
  33.   }$ k  B1 {% m  l4 }6 @' R) c9 A0 F

  34. ; k8 z: ?( d) e4 t" h# G
  35.   public SmsMessageSegmentContainer(long messageId, int totalSegments, String bodyEncoding)
    3 ~: `7 N/ H9 ]9 H" [5 G
  36.   {' f( J% q! }( m/ B+ s; P8 V& L
  37.     super(System.currentTimeMillis(), messageId, totalSegments);; q# J- E; b& S3 w/ Q: W! R' ]- P
  38.     this.completeMsgString = null;6 {1 _2 @7 d( `$ x4 |
  39.     this.bodyEncoding = null;( e3 A. Z& X' J" ?6 X
  40.     this.segments = hasMany(SmsMessageFromTil.class, 1);& M, D" _$ H3 {; b
  41.     this.bodyEncoding = bodyEncoding;6 n/ q8 o) ?  x
  42.   }
    8 O: @+ t9 I5 j: U1 A; g
  43. 8 ~* x/ x3 ?8 w5 q* H
  44.   SmsMessageSegmentContainer(String messageId, int totalSegments, String bodyEncoding)
    $ R7 c/ i1 ]. W- ^0 F* ?
  45.   {
    3 G6 N( b" w5 Y7 Z* v6 C
  46.     super(System.currentTimeMillis(), Integer.parseInt(messageId), totalSegments);" E8 t8 A6 ^1 H  F0 N. o
  47.     this.completeMsgString = null;: p+ n+ U2 m- b% M1 K
  48.     this.bodyEncoding = null;% |: y: D) f1 ?2 F# H% v0 E% u
  49.     this.segments = hasMany(SmsMessageFromTil.class, 1);8 l5 ~, Z5 q* B5 z
  50.     this.bodyEncoding = bodyEncoding;4 j2 P, M' N& }8 w% v( A, m
  51.   }, z% g( G) ]2 I- T- }; G* _

  52. % D4 ?! v8 q" t/ p! T% X
  53.   public String getBodyEncoding()
    ) O8 k1 K; p( \5 w% C& L6 g* B
  54.   {
    8 W& {3 H" e+ {3 g4 y5 K. P: x
  55.     return this.bodyEncoding;
    / Y% T0 j/ {# X: }
  56.   }
    1 E" O, ]4 {/ X% L7 w" V% C4 y' j
  57. : I- N  F4 l( z
  58.   protected boolean isPrintableChar(char ch)4 ?7 [. l- c% k$ x3 n
  59.   {
    3 H& E/ o$ K4 y
  60.     boolean isItPrintableChar = false;
    4 a5 m2 g' A3 y; }! ?2 a/ T
  61.     if ((ch >= ' ') && (ch <= '~')) {" r+ ]" y1 ~5 o# K- x2 H' f
  62.       isItPrintableChar = true;
    $ \5 Z8 R& D: g( v" [
  63.     }2 y" ]: S+ E" s) z5 j& q9 L
  64.     else if ((ch >= 128) && (ch <= 168)) {; G% c# e8 }: m
  65.       isItPrintableChar = true;  Y% J' k; [6 Q9 m3 \1 D
  66.     }
    " S- Y1 E( E' x0 d# g
  67.     else if ((ch >= 224) && (ch <= 247))3 ^$ a# U2 f; R' M( K
  68.       isItPrintableChar = true;
    " q. {4 x# o8 F! g
  69.     return isItPrintableChar;; ]+ f% T6 A. D4 a) n* A. i2 w
  70.   }% {& q1 G- O1 p/ t. l* R/ ]: X  _3 h

  71. ; l/ |: d* H; T9 H6 _0 L- O
  72.   public boolean isMessageComplete()6 g. D; T5 c" W" `* ~
  73.   {6 [- E- E% g0 p
  74.     if (!(this.isMessageComplete))
    # @* m* w3 x) q' u0 m/ l
  75.       try' Z0 ^' t$ J4 H5 A8 [
  76.       {& D. y0 Q( d0 F$ v! U  L
  77.         synchronized (SmsMessageSegmentContainer.class)9 n! m' X) b& m' B% h2 G2 D, q
  78.         {
    + W6 q# o  N8 }
  79.           List listSmsSegments = ActiveRecord.find(this.segments.sqlAll().orderBy("segmentNumber ASC"));& _4 |0 @, a4 @+ x; _6 y
  80.           if ((listSmsSegments != null) && (listSmsSegments.size() == this.totalSegments))8 g9 I* T( F9 L
  81.           {
    3 l& N# i  i8 J4 ^; p# A' k
  82.             this.isMessageComplete = true;  W: _5 m4 d% [8 }% x: z
  83.             logger.fine("At this point all SMS message segments have been recieved so we are going to put it all together");
    / U/ _4 S5 V" [) Y' \
  84.             StringBuilder msgString = new StringBuilder(160 * this.totalSegments);& o* t! m4 {; p$ H3 I) G' I
  85.             if (msgString != null)
    5 c; t* Z- i' M( N' r+ t9 v
  86.             {
    2 t+ f8 c) W1 n( g$ q1 `$ a
  87.               if ("bbin".equals(this.bodyEncoding)): ?& f6 M9 E5 h6 G
  88.               {
    4 O! T+ V7 E4 m" ?% z3 }. g! S
  89.                 ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
    4 L& g+ N7 y9 L& @% e: R
  90.                 Iterator i$ = listSmsSegments.iterator();
    9 W$ v4 k1 m) U6 m  [$ a/ ?

  91. + o# S' F; k9 R  d' h* x1 y
  92.                 while (i$.hasNext())
    ; g1 }+ L% D2 w3 ^% q  b% p
  93.                 {. e; I) B7 }4 s2 l
  94.                   SmsMessageFromTil msg = (SmsMessageFromTil)i$.next();- p  q" ~% W7 [: P. ?, J
  95.                   if ((msg.getBody() != null) && (msg.getBody().length() != 0));0 ^- ^! N5 [8 v& `
  96.                   byteOut.write(Base64.decode(msg.getBody()));
    : K* n( f, Z& z4 w: Z: [
  97.                 }
    : H5 x! ^/ j4 N" S
  98.                 char[] testArray = byteOut.toString().toCharArray();
    * [( J* l; R  ]
  99.                 boolean isAllCharsPrintable = true;
    7 e- R: `7 B+ r+ e5 u, l0 U3 c
  100.                 int i = 0;
    3 E: H  m7 A$ p/ R% D. R
  101.                 for (i = 0; (i < testArray.length) && (isAllCharsPrintable); ++i) {
    ! H* B  E4 k% Y# g4 H
  102.                   if (!(isPrintableChar(testArray[i])))
    ) {% ~) x: j! @8 V" @
  103.                     isAllCharsPrintable = false;
      b) p1 q0 o, A. n7 z
  104.                 }
    9 ?7 W( Y" Y3 }2 ~( J
  105.                 if (isAllCharsPrintable)/ I1 [! j# H: {& M4 Q$ ~. k/ x5 P
  106.                   this.completeMsgString = byteOut.toString() + "";, H/ Y/ ?& ?. \, k! G
  107.                 else
    . n  z2 B" a9 k5 |# n, r( ]  s
  108.                   this.completeMsgString = Base64.encodeBytes(byteOut.toByteArray()) + "";( b# u0 }8 g5 O# E
  109.                 System.out.println(this.completeMsgString);1 m1 v; C$ Z6 E" E/ a
  110.               }
    & ?' u" r* z. x9 O5 Q: d" |
  111.               else {
    ) \* ^/ G3 o# N6 r3 y& ~9 k
  112.                 Iterator i$ = listSmsSegments.iterator();8 S) s) T( `% g7 I0 d/ Y

  113. / Z. Z7 [3 \  r# b. I
  114.                 while (i$.hasNext())4 G3 W4 \6 G  `, p4 z
  115.                 {
    $ g. o# W2 ~' s% _
  116.                   SmsMessageFromTil msg = (SmsMessageFromTil)i$.next();
    / `- `' z( V- ?2 b5 F* j" j  m) E
  117.                   if ((msg.getBody() != null) && (msg.getBody().length() != 0));, ^& |+ p- I# Z; W2 k
  118.                   msgString.append(TilUtils.decodeString(msg.getBodyEncoding(), msg.getBody()));, }  ]) C) r) ?+ _# a
  119.                 }. g/ q: g. s5 F% Y
  120.                 this.completeMsgString = msgString.toString() + "";
    $ ?/ M, S: s. S. A0 \
  121.               }; e' A" J( s8 r, g
  122.             }% I1 N( X; {+ R( N+ V9 \' e# C
  123.             else {/ ^6 b" M( a+ T, `
  124.               logger.severe("Error allocating memory to put Segmented SMS Message Together");
    / c8 f: H( R! j6 M% [
  125.             }# h( p  K- M) F" {
  126.           }  v" J% y9 h  W
  127.           else if ((listSmsSegments != null) && (listSmsSegments.size() > this.totalSegments)) {
    % M/ Z9 f, x. ^8 D, `
  128.             logger.severe("Too many SMS message segments found so assuming corrupted for " + this.segMsgContainerId + " in DB.  We found:" + listSmsSegments.size() + " but we expected: " + this.totalSegments); }" Y; M  }! ~# i9 q, F2 k6 `4 A& Z
  129.           listSmsSegments = null;
    8 U" I+ q  `8 ~, s! E; r! `
  130.         }3 R9 Z: y$ a! t1 b: T6 h& b
  131.       }
    % e9 W+ |. {" }8 `. U# b3 r3 J" t& L
  132.       catch (ActiveRecordException e)4 |( i8 G- N  |0 a% ^8 m% s" D$ r
  133.       {# w" V0 l6 [0 d7 x( ^3 _5 w; _& q
  134.         logger.warning("SMS Message couldn't be retrieved from the database at this time.");
    4 F) ?* b1 T: s- H, O. c
  135.       }- l0 t$ f- ]' V1 \4 [' @
  136.       catch (NullPointerException e). {! l" b( p! I- A9 r
  137.       {
    , u. z# _  [/ J: A. y: q# F* ]$ F
  138.         logger.severe("Null Pointer Error putting Segmented SMS Message Together");, \! z1 x8 a' d6 R8 o
  139.       }
    6 b0 f) h& z: t% i: g: s; s
  140.       catch (IOException e)5 v* v3 h1 F, u3 d
  141.       {
    9 J7 Y# c4 X2 ^
  142.         logger.severe("Error Decoding Binary Message");
    : r3 L0 j) ^( Q" C7 _, z. Q! S5 h
  143.       }( b2 V; e: k# _9 s. ~
  144.     return this.isMessageComplete;6 Q7 h1 E, I8 \' L
  145.   }
    & _; u7 J) G$ D9 Y: U, u" w

  146. : N5 o% B- ^; O! w6 Q
  147.   public String getCompletedBody()+ W2 x- v# \2 I( B: K7 x
  148.   {
    - f% j  B$ e; B2 H( A
  149.     if (!(isMessageComplete()))$ K1 E( Q2 e/ B6 Z% c8 L) f
  150.       logger.warning("Message Not yet Complete so you should call this after testing with isMessageComplete");& H7 V5 ~& `/ |
  151.     return this.completeMsgString;  J: a! l" J* z( J8 [
  152.   }
    + C, _2 e. r0 z" {" ~& Y

  153.   Q( `  W: s: |7 x9 T- A" a1 Q  y) V; y
  154.   public void addNewSegment(SmsMessageFromTil msgSegment)* b8 ~- J) o5 |2 e
  155.   {
    2 K# u4 D2 {7 k+ T& H) b
  156.     try
    6 h  x6 T; `' r6 `! k& f
  157.     {
    4 j" {! J% D* L. W" L
  158.       if (logger.getLogger().isFinerLoggable)
    : I# m0 ~) B3 L, `% n
  159.         logger.finer("Attempting to Adding new SMS Message with MessageId:" + msgSegment.getMessageId() + " with SegmentNo:" + msgSegment.getSegmentNumber() + " of Total Segments:" + msgSegment.getTotalNumberOfSegments());
    $ B2 @' _  ?) r6 U  u6 }- q2 }
  160.       synchronized (SmsMessageSegmentContainer.class)# v: k  ^3 r; k6 x, z: a: I8 u5 B- t) `
  161.       {( T% W5 ^0 i; L2 g4 k# C5 v1 \0 K
  162.         int numSegmentsAlreadyStoredWithThatSegNumber = ActiveRecord.count(this.segments.sqlAll().where("segmentNumber=?", new Object[] { " p; ]# O5 C' v
  163.           Integer.valueOf(msgSegment.getSegmentNumber()) }));
    : J; A1 T. `- {; @( u' Z
  164. 0 B8 o8 F$ m7 C
  165.         if (numSegmentsAlreadyStoredWithThatSegNumber == 0)
    - t, v1 O: L# m# V2 C
  166.         {
    : c  Z2 ?0 d! R* e: _" i% E
  167.           logger.finer("New SMS Segmeted Accepted.  Adding it to SMS Container");+ @5 v7 I9 P: p
  168.           logger.finer("saving segment to message holder");
    5 E! Y& `/ L9 R7 T2 m
  169.           Batch batch = new Batch();( u( L+ x$ f  x4 B8 a% F
  170.           this.segments.push(batch, msgSegment);
    2 W0 A. i, o* T5 }9 V# D, o, Q5 @
  171.           msgSegment.save(batch);
    ; o7 K/ |- \7 m. }- _) l& j3 Q( Q$ A
  172.           if (0L != msgSegment.getTimeStamp())' P* L3 I. R' {8 R: C: o
  173.             setTimeStampLastReceivedSegment(msgSegment.getTimeStamp());1 s' ]' x, C0 e/ Q
  174.           save(batch);' |/ B, T1 ?" S) M
  175.           batch.execute();9 j# O5 V8 ~5 C! T1 d) ^1 P
  176.         }
    , q% j! a% r8 G: Z* K. \
  177.         else {
    ' C, `/ H& S. f9 G: v0 i
  178.           logger.warning("Found duplicate SMS Message segment already saved");. \$ p$ ?( a$ e3 M3 e* W/ d5 D
  179.         }& V, e' x2 w7 \5 V- M: _" b
  180.       }3 f& ^1 q9 `1 b  b' }6 z. d! |6 e
  181.     }
      a# }0 e9 I& G4 X( G% R0 [
  182.     catch (ActiveRecordException e)
    / W0 V7 b) p; ^) b$ H; G/ B* }
  183.     {
    # e- q8 q+ L5 |
  184.       logger.severe("Error saving SMS Message Segment.  Data will probably be lost.");9 B0 u" W7 R2 e+ F
  185.     }
    4 U6 m* O- c5 _
  186.   }
    & O8 I+ z# g  d; h& k1 {
  187. 9 e0 N. w  L& g7 F& M$ \, Z
  188.   private String convertToJson(boolean doHidePrivateData)
    9 f, V- O& w( h1 z# s
  189.   {
    ) E$ T  A' J  s' S
  190.     JSONObject smsJson = new JSONObject();- p# @: w& ?* P. o
  191.     SmsMessageFromTil msgSeg = null;1 q& J6 B7 U( m+ a
  192.     try
    ( x, Z& x! Q- P$ p9 C3 S
  193.     {$ H# z. e, K) O0 M" V+ G
  194.       msgSeg = (SmsMessageFromTil)this.segments.findFirst();8 a4 m, s5 d( l6 T" x
  195.       if (msgSeg != null)
    * z: f7 F  O& r3 Z
  196.       {
    , Z$ F$ c' o  D; C- ]) \
  197.         if (doHidePrivateData)0 E; }5 L3 Q; P2 p
  198.         {% c" d! `' y7 z5 ]6 M, p8 p; P
  199.           smsJson.put("body", "This has been hidden for logging");, G" W1 V; E5 _- ?
  200.           smsJson.put("address", "555-333-4444");
    5 o+ I$ w! h) c2 g0 V
  201.           smsJson.put("callbackNumber", "555-333-4444");
    + `- `. N" C) Z$ Z9 B" G% W
  202.         }& }/ k& M6 O- z/ ]) Q( q* P' C
  203.         else {
    $ y  T+ }2 K: f; c; H; ?
  204.           smsJson.put("body", getCompletedBody());
    + R& \: ]8 r! h1 X
  205.           smsJson.put("address", msgSeg.getWhoIsItFrom());
    1 S5 h9 R+ w6 ^+ G6 Z7 o, `
  206.           smsJson.put("callbackNumber", msgSeg.getCallbackNumber());+ ^" j' I) S& g7 a: w- {
  207.         }" u9 d6 L2 C, e9 h% q/ ?# F
  208.         smsJson.put("networkMsgId", msgSeg.getMessageId());! P" y( M& K  H; d: v
  209.         smsJson.put("deliveryReportOptions", msgSeg.getDeliveryReportOptions());$ ^0 t' a4 T4 p, m  i
  210.         smsJson.put("timeStamp", msgSeg.getTimeStamp());. f5 O* W; U1 J7 ?; t' u% B
  211.         if (msgSeg.isThisMessageFromAGsmNetwork())
    0 C- k, J/ ~7 |2 M% t5 t' H9 r0 w. l
  212.         {
    ' }% K# f. B: u" B  }) ]
  213.           smsJson.put("priority", msgSeg.getSmsClassInfo());1 B# t6 R7 X; q% i. L
  214.           if (msgSeg.isFromSim())3 G9 @1 M$ q3 {: z8 q
  215.             smsJson.put("isFromSim", true);8 v- [9 B) s# m
  216.         }
    9 f" r. F9 }  L2 V
  217.         else {& r0 ^" Q9 e; o% P* `: }
  218.           smsJson.put("priority", msgSeg.getPriority());, V; Q9 B0 o( J0 O) N; T- W
  219.         }9 {% J! u& [& j2 A7 `; }: F
  220.         smsJson.put("displayMode", msgSeg.getDisplayMode());
    - U2 {3 J9 m, k" V! S
  221.         smsJson.put("privacyMode", msgSeg.getPrivacyMode()); break label257:, U* B8 q& n" ?6 N# D; E3 D3 K1 j
  222.       }
    - u+ O1 w6 L7 k6 K4 i
  223.   L' G" r" a/ T' h! E2 y
  224.       logger.severe("Did not find Message Segment to generate JSON string");
    , ?9 W  u7 `6 ~5 {3 V# K- t
  225.     }* _4 H( ]* k* I9 p6 D5 v7 i! _
  226.     catch (ActiveRecordException e)/ z) u3 [2 r) N) R
  227.     {5 t- r7 u9 z. P; s( o+ O- V
  228.       logger.severe("Caught Exception", e);8 \* f3 m6 g% A# S
  229.     }
    : r: |9 E  m2 m3 G( j5 i7 A
  230.     catch (JSONException e)
    ; `, d- C0 r+ J
  231.     {
    0 G  v" X) @$ o! }7 z4 U
  232.       logger.severe("Caught Exception", e);1 w/ u& j) P5 ]% H. O, P
  233.     }
    2 P. E7 ^9 X' ?/ ^8 ]0 M' J3 g
  234.     label257: String jsonString = smsJson.toString();' L: M# b9 d) @& e1 ^7 z) k
  235.     logger.finer("toJSONString SMS Message: " + jsonString);) G" o. P: r/ l! h  Q% A' E
  236.     return jsonString;
    4 x0 X: i4 U3 W
  237.   }
    9 T! c' c4 _2 t- A9 L

  238. . ^5 F/ U8 j, R7 @3 Q6 n
  239.   public String toJSONString()
    7 ^  e* o! l2 J( p
  240.   {
    5 u0 w; Q; n( ~- }- }! J5 L6 g/ F
  241.     return convertToJson(false);! h+ ~# q* T7 b+ i  ?/ _7 E
  242.   }
    9 \. ]3 u7 b% a, ]1 J

  243. ' v2 y0 k6 P& v  J% u; l# j
  244.   public String toDebugJSONString()
    1 j( [# Z7 F) K1 U5 W
  245.   {/ B; C) [' t% P6 Q% O) b" m
  246.     return convertToJson(true);
    + ?% [" T7 W& r; w/ p
  247.   }  a. ~. Y/ @2 @. X
  248. }
复制代码
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:23 | 显示全部楼层

回复 楼主1# mfly 的帖子

我把palm的Jar也都加入Library了啊,咋回事呢?报了好多错哎
回复 支持 反对

使用道具 举报

发表于 2009-7-26 22:50 | 显示全部楼层

回复 楼主1# mfly 的帖子

是不是因为我加入的是1.1ROM里的jar的关系呢?跟1.0.4的参数对不上了
回复 支持 反对

使用道具 举报

发表于 2009-7-27 00:28 | 显示全部楼层

回复 楼主1# mfly 的帖子

我试了下,编译你的那个文件就ok,我编译的是SmsMessageSegmentContainer,不灵,估计是SmsMessageSegmentContainer里面的一些函数在library里找不到吧,如何才能编译这个文件成功呢?请指点一下,谢谢
回复 支持 反对

使用道具 举报

发表于 2009-7-27 21:24 | 显示全部楼层
eclipse啊~像我们这种穷人,只能用Emacs....
回复 支持 反对

使用道具 举报

发表于 2009-8-18 22:01 | 显示全部楼层
其它的代码有吗?我用jd-gui 0.2.7反编译出来好像有点问题啊。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 加入我们

本版积分规则

QQ|Archiver|手机版|小黑屋|吹友吧 ( 京ICP备05078561号 )

GMT+8, 2024-11-14 15:00 , Processed in 0.340686 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表