user590849
user590849

Reputation: 11765

what does this code snippet mean

code snippet:

  for( String token : tokens ) 
        {
            try
            {
                Url url = as("mycompany", "someapikey").call(shorten(token));
             }
         } 

what do the 'as' and the 'call' mean. Are they keywords in java?

i was browsing and i found this code and i would like to understand what it means.

thank you in advance.

Upvotes: 0

Views: 755

Answers (4)

Ishtar
Ishtar

Reputation: 11662

Maybe a static import?

For example, if class Foo has a static method as(), you can use

import static Foo.as;

{
  //now can do this:
  as();  //equal to Foo.as();
}

Upvotes: 0

Curd
Curd

Reputation: 12417

as and call are not keywords in Java.

It seems that as(String s1, String s2) is a method that returns an object that has a method call(..).

That method call(..) is invoked on the return value of as(..).

Upvotes: 0

james
james

Reputation: 26271

Looks like it's using the bit.ly library to shorten URLs. the for loop is iterating through strings in a collection, tokens. it then creates a shortened URL via the bit.ly library. These aren't keywords in Java, they are just method names.

android bit.ly library: http://code.google.com/p/bitlyj/

Upvotes: 2

unwind
unwind

Reputation: 399703

No, they are regular methods. The as() method should be in the class this is from (or a superclass), while the call() method is defined for the type returned by as().

It would be helpful to have a link back to the original source where you found this, as more context is often useful.

Upvotes: 0

Related Questions