From the below official website, iPhone 7 Plus Model A1661 works for ChinaMobile 4G while A1784 does not.
https://support.apple.com/en-ca/HT201296
https://support.apple.com/en-us/HT202909
Saturday, November 5, 2016
Thursday, November 3, 2016
Live and learn
Mahatma Gandhi: “Live as if you were to die tomorrow. Learn as if you were to live forever.”
Wednesday, November 2, 2016
Programming in Scala 11/12/13/14/15
1.
Any is a superclass of every other class, Nothing is a subclass of every other class.
== and !=, are declared final in class Any, so they cannot be overridden in subclasses.
2.
Any is a superclass of every other class, Nothing is a subclass of every other class.
== and !=, are declared final in class Any, so they cannot be overridden in subclasses.
2.
Class Null is the type of the null reference; it is a subclass of every reference class (i.e., every class that
itself inherits from AnyRef). Null is not compatible with value types. You cannot, for example, assign
a null value to an integer variable.
Type Nothing is at the very bottom of Scala's class hierarchy; it is a subtype of every other type.
you can
do anything in a trait definition that you can do in a class definition, and the syntax looks exactly the
same, with only two exceptions.
First, a trait cannot have any "class" parameters.
The other difference between classes and traits is that whereas in classes, super calls are statically
bound, in traits, they are dynamically bound. If you write "super.toString" in a class, you know exactly
which method implementation will be invoked. When you write the same thing in a trait, however, the
method implementation to invoke for the super call is undefined when you define the trait.
3.
Using the modifier case makes the
Scala compiler add some syntactic conveniences to your class.
First, it adds a factory method with the name of the class.
The second syntactic convenience is that all arguments in the parameter list of a case class implicitly
get a val prefix, so they are maintained as fields.
Finally, the compiler adds a copy method to your class for making modified copies.
However, the biggest advantage
of case classes is that they support pattern matching.
4.
Constant patterns:
def describe(x: Any) = x match {
case 5 => "five"
case true => "truth"
case "hello" => "hi!"
case Nil => "the empty list"
case _ => "something else"
}
Scala uses a simple lexical rule for disambiguation: a simple
name starting with a lowercase letter is taken to be a pattern variable; all other references are taken to
be constants.
If that
does not work (because pi is a local variable, say), you can alternatively enclose the variable name in
back ticks. For instance, `pi` would again be interpreted as a constant, not as a variable
3.
Using the modifier case makes the
Scala compiler add some syntactic conveniences to your class.
First, it adds a factory method with the name of the class.
The second syntactic convenience is that all arguments in the parameter list of a case class implicitly
get a val prefix, so they are maintained as fields.
Finally, the compiler adds a copy method to your class for making modified copies.
However, the biggest advantage
of case classes is that they support pattern matching.
4.
Constant patterns:
def describe(x: Any) = x match {
case 5 => "five"
case true => "truth"
case "hello" => "hi!"
case Nil => "the empty list"
case _ => "something else"
}
Scala uses a simple lexical rule for disambiguation: a simple
name starting with a lowercase letter is taken to be a pattern variable; all other references are taken to
be constants.
If that
does not work (because pi is a local variable, say), you can alternatively enclose the variable name in
back ticks. For instance, `pi` would again be interpreted as a constant, not as a variable
Saturday, October 29, 2016
Programming in Scala 7/8/9/10
1.
scala> val someNumbers = List(-11,2,-12,8,9)
scala> someNumbers.filter( x=>x<8 )
scala> someNumbers.filter(_>0)
scala> val f= (_: Int)+(_: Int)
scala> someNumbers.foreach(println _)
equals
someNumbers.foreach(x => println(x))
2. closure
2. closure
def makeIncreaser(more: Int) = (x: Int) => x + more
3.
scala> def twice(op: Double => Double, x: Double) = op(op(x))
scala> twice(_ + 1, 5)
4.
In Scala it is forbidden to define a field and method with the same name in the same class, whereas this is
allowed in Java.
Generally, Scala has just two namespaces for definitions in place of Java's four. Java's four namespaces
are fields, methods, types, and packages. By contrast, Scala's two namespaces are:
• values (fields, methods, packages, and singleton objects)
• types (class and trait names)
Tuesday, October 25, 2016
Programming in Scala Note 4/5/6
1.
The way you make members public in Scala is by not explicitly specifying any access modifier.
Public is Scala's default access level.
2.
one way in which Scala is more object-oriented than Java is that classes in
Scala cannot have static members. Instead, Scala has singleton objects. A singleton object definition
looks like a class definition, except instead of the keyword class you use the keyword object.
A singleton object is more than a holder of static methods, however. It is a first-class object.
One difference between classes and singleton objects is that singleton objects cannot take parameters,
whereas classes can. Because you can't instantiate a singleton object with the newkeyword, you have
no way to pass parameters to it.
3.
in Scala, you
can name .scala files anything you want, no matter what Scala classes or code you put in them.
4. ==First check the left side for null. If it is not null,
4. ==First check the left side for null. If it is not null,
call the equals method.
scala> 1==1.0
res8: Boolean = true
5.
In Java, classes have
constructors, which can take parameters; whereas in Scala, classes can take parameters directly. The
Scala notation is more concise—class parameters can be used directly in the body of the class
6.
class Rational(n: Int, d: Int) {
require(d != 0)
override def toString = n + "/" + d
}
7.
In Scala, every auxiliary constructor must invoke another constructor of the same class as its first
action. In a Scala class, only the primary
constructor can invoke a superclass constructor.
8.
scala> implicit def intToRational(x: Int) = new Rational(x)
Programming in Scala Note Chapter 1/2/3
Chapter 1/2/3
1.
1.
def factorial(x: BigInt): BigInt =
if (x == 0) 1 else x * factorial(x - 1)
2.
A val is similar to a final variable in Java. Once
initialized, a val can never be reassigned. A var, by contrast, is similar to a non-final variable in Java.
3.
Sometimes the Scala compiler will require you to specify the result type of a function. If the functionis recursive,[7] for example, you must explicitly specify the function's result type.
If a function consists of just one statement, you can optionally leave off the curly braces.
scala> def max(x: Int, y: Int) = if (x > y) x else y
4.
A result type of Unit indicates the function returns no interesting value.scala> def greet() = println("Hello, world!")
greet: ()Unit
5.
Note that Java's + +i and i++ don't work in Scala. To increment in Scala, you need to say either i = i + 1 or i += 1.
6.
args.foreach(arg => println(arg))
or
args.foreach((arg: String) => println(arg))
orargs.foreach(println)
or
for(arg <- args) println(arg)
7.If the method name ends in a colon, the method is invoked on the right operand.8.The time it takes to append to a list grows linearly with the size of the list, whereas prepending with :: takes constant time. If you want to build a list efficiently by appending elements, you can prepend them and when you're done call reverse. Or you can use a ListBuffer, a mutable list that does offer an append operation, and when you're done call toList.9.
Once you have a tuple instantiated, you can access its elements individually with a dot, underscore, and the one-based index of the element.
val pair = (99, "Luftballons") println(pair._1)
10.
This -> method, which you can invoke on any object in a Scala program, returns a two-element tuple containing the key and value.
import scala.collection.mutable val treasureMap = mutable.Map[Int, String]() treasureMap += (1 -> "Go to island.")
11.
if code contains any vars, it is probably in an imperative style. If the code contains no vars at all—i.e., it contains only vals—it is probably in a functional style.
Friday, September 30, 2016
My SOAP based web service client development and test note
My SOAP based web service client development and test note:
1. If wsdl is available, SOAP UI is a good tool for the test. If there's error, then use local wsdl file and it could be fixed
2. If SOAP request file is available (you can get it from the server side or SOAP UI), then Apache Common http client is good to post the SOAP request
to the end point directly:
String strURL = "https://...";
String strSoapAction = "retrieve";
File input = new File(strXMLFilename);
PostMethod post = new PostMethod(strURL);
RequestEntity entity = new FileRequestEntity(input,
"text/xml; charset=UTF-8");
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", strSoapAction);
HttpClient httpclient = new HttpClient();
int result = httpclient.executeMethod(post);
...
Still, the response could be parsed by JAXB like (Use the regular expression "<soapenv:Body>(.*?)</soapenv:Body>" to get the body part retrieveResponseStr):
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(retrieveResponseStr);
RetrieveResponse retrieveResponse = ((JAXBElement<RetrieveResponse>) unmarshaller
.unmarshal(reader)).getValue();
3. Or SAAJ could be used to construct the SOAP message as this link shows
http://stackoverflow.com/questions/15940234/how-to-do-a-soap-web-service-call-from-java-class
4. The most common way is to generate the client by invoking "wsimport -keep ...", and then
If need customize SOAP header, then implement javax.xml.ws.handler.soap.SOAPHandler, call service's method setHandlerResolver before getPort
Be careful not to introduce WAS_V7JAXWS_WEBSERVICES_THINCLIENT if you use IBM RAD. Or you may get error "WSWS7130E: No Secure Sockets Layer (SSL) configuration is available"
or "IOException: Connection close: Read failed. Possible end of stream encountered".
TCP/IP monitor in Eclipse cannot support https monitor
I cannot enable Fiddler to monitor Java web service client for https
1. If wsdl is available, SOAP UI is a good tool for the test. If there's error, then use local wsdl file and it could be fixed
2. If SOAP request file is available (you can get it from the server side or SOAP UI), then Apache Common http client is good to post the SOAP request
to the end point directly:
String strURL = "https://...";
String strSoapAction = "retrieve";
File input = new File(strXMLFilename);
PostMethod post = new PostMethod(strURL);
RequestEntity entity = new FileRequestEntity(input,
"text/xml; charset=UTF-8");
post.setRequestEntity(entity);
post.setRequestHeader("SOAPAction", strSoapAction);
HttpClient httpclient = new HttpClient();
int result = httpclient.executeMethod(post);
...
Still, the response could be parsed by JAXB like (Use the regular expression "<soapenv:Body>(.*?)</soapenv:Body>" to get the body part retrieveResponseStr):
JAXBContext jaxbContext = JAXBContext.newInstance(ObjectFactory.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader reader = new StringReader(retrieveResponseStr);
RetrieveResponse retrieveResponse = ((JAXBElement<RetrieveResponse>) unmarshaller
.unmarshal(reader)).getValue();
3. Or SAAJ could be used to construct the SOAP message as this link shows
http://stackoverflow.com/questions/15940234/how-to-do-a-soap-web-service-call-from-java-class
4. The most common way is to generate the client by invoking "wsimport -keep ...", and then
If need customize SOAP header, then implement javax.xml.ws.handler.soap.SOAPHandler, call service's method setHandlerResolver before getPort
Be careful not to introduce WAS_V7JAXWS_WEBSERVICES_THINCLIENT if you use IBM RAD. Or you may get error "WSWS7130E: No Secure Sockets Layer (SSL) configuration is available"
or "IOException: Connection close: Read failed. Possible end of stream encountered".
TCP/IP monitor in Eclipse cannot support https monitor
I cannot enable Fiddler to monitor Java web service client for https
Subscribe to:
Posts (Atom)