本文整理汇总了Scala中java.util.List类的典型用法代码示例。如果您正苦于以下问题:Scala List类的具体用法?Scala List怎么用?Scala List使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了List类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: PreferenceGroupAdapter
//设置package包名称以及导入依赖的类
package be.mygod.preference
import java.lang.reflect.Field
import java.util.List
import android.os.Build
import android.support.v4.content.ContextCompat
import android.support.v4.view.ViewCompat
import android.support.v7.preference.{PreferenceGroup, PreferenceViewHolder, PreferenceGroupAdapter => Old}
import android.view.{LayoutInflater, View, ViewGroup}
import com.github.shadowsocks.R
object PreferenceGroupAdapter {
private var preferenceLayoutsField: Field = _
private var fieldResId: Field = _
private var fieldWidgetResId: Field = _
private val preferenceViewHolderConstructor = classOf[PreferenceViewHolder].getDeclaredConstructor(classOf[View])
{
val oldClass = classOf[Old]
preferenceLayoutsField = oldClass.getDeclaredField("mPreferenceLayouts")
preferenceLayoutsField.setAccessible(true)
val c = oldClass.getDeclaredClasses.filter(c => c.getSimpleName == "PreferenceLayout").head
fieldResId = c.getDeclaredField("resId")
fieldResId.setAccessible(true)
fieldWidgetResId = c.getDeclaredField("widgetResId")
fieldWidgetResId.setAccessible(true)
preferenceViewHolderConstructor.setAccessible(true)
}
}
class PreferenceGroupAdapter(group: PreferenceGroup) extends Old(group) {
import PreferenceGroupAdapter._
protected lazy val preferenceLayouts = preferenceLayoutsField.get(this).asInstanceOf[List[AnyRef]]
override def onCreateViewHolder(parent: ViewGroup, viewType: Int) = if (Build.VERSION.SDK_INT < 21) {
val context = parent.getContext
val inflater = LayoutInflater.from(context)
val pl = preferenceLayouts.get(viewType)
val view = inflater.inflate(fieldResId.get(pl).asInstanceOf[Int], parent, false)
if (view.getBackground == null) {
val array = context.obtainStyledAttributes(null, R.styleable.BackgroundStyle)
var background = array.getDrawable(R.styleable.BackgroundStyle_android_selectableItemBackground)
if (background == null)
background = ContextCompat.getDrawable(context, android.R.drawable.list_selector_background)
array.recycle
val (s, t, e, b) = (ViewCompat.getPaddingStart(view), view.getPaddingTop,
ViewCompat.getPaddingEnd(view), view.getPaddingBottom)
view.setBackground(background)
ViewCompat.setPaddingRelative(view, s, t, e, b)
}
val widgetFrame = view.findViewById(android.R.id.widget_frame).asInstanceOf[ViewGroup]
if (widgetFrame != null) {
val widgetResId = fieldWidgetResId.get(pl).asInstanceOf[Int]
if (widgetResId != 0) inflater.inflate(widgetResId, widgetFrame) else widgetFrame.setVisibility(View.GONE)
}
preferenceViewHolderConstructor.newInstance(view)
} else super.onCreateViewHolder(parent, viewType)
}
示例2: ImageWriter
//设置package包名称以及导入依赖的类
package script
import java.awt._
import java.io.{File, FileInputStream}
import java.util.List
import model.MA
import com.kennycason.kumo.bg.PixelBoundryBackground
import com.kennycason.kumo.font.scale.LinearFontScalar
import com.kennycason.kumo.font.{FontWeight, KumoFont}
import com.kennycason.kumo.nlp.FrequencyAnalyzer
import com.kennycason.kumo.palette.ColorPalette
import com.kennycason.kumo.{CollisionMode, WordCloud, WordFrequency}
import com.typesafe.scalalogging.LazyLogging
object ImageWriter
extends LazyLogging
with App
{
val ma = new MA("neko.txt")
ma.doAnalysis()
val frequencyAnalyzer = new FrequencyAnalyzer()
frequencyAnalyzer.setWordFrequenciesToReturn(300)
frequencyAnalyzer.setMinWordLength(2)
val wordFrequencies: List[WordFrequency] = frequencyAnalyzer.load(new File("output/neko.txt"))
val dimension = new Dimension(660, 740)
val wordCloud = new WordCloud(dimension, CollisionMode.PIXEL_PERFECT)
wordCloud.setBackgroundColor(new Color(0x000000FF, true))
wordCloud.setPadding(2)
wordCloud.setBackground(new PixelBoundryBackground(new FileInputStream("background/techchan1.png")))
wordCloud.setColorPalette(new ColorPalette(new Color(0x4055F1), new Color(0x408DF1), new Color(0x40AAF1), new Color(0x40C5F1), new Color(0x40D3F1), new Color(0x99FFFF)))
wordCloud.setFontScalar(new LinearFontScalar(2, 10))
wordCloud.setKumoFont(new KumoFont("Comic Sans MS", FontWeight.BOLD))
wordCloud.setBackgroundColor(Color.WHITE)
wordCloud.build(wordFrequencies)
wordCloud.writeToFile("imageout/neko.png")
}
示例3: Dynomite
//设置package包名称以及导入依赖的类
package com.advancedspark.serving.spark
import com.netflix.dyno.jedis._
import com.netflix.dyno.connectionpool.Host
import com.netflix.dyno.connectionpool.HostSupplier
import com.netflix.dyno.connectionpool.TokenMapSupplier
import com.netflix.dyno.connectionpool.impl.lb.HostToken
import com.netflix.dyno.connectionpool.exception.DynoException
import com.netflix.dyno.connectionpool.impl.ConnectionPoolConfigurationImpl
import com.netflix.dyno.connectionpool.impl.ConnectionContextImpl
import com.netflix.dyno.connectionpool.impl.OperationResultImpl
import com.netflix.dyno.connectionpool.impl.utils.ZipUtils
import scala.collection.JavaConversions._
import java.util.Collections
import java.util.Collection
import java.util.Set
import java.util.List
object Dynomite {
val localhostHost = new Host("127.0.0.1", Host.Status.Up)
val localhostToken = new HostToken(100000L, localhostHost)
val localhostHostSupplier = new HostSupplier() {
@Override
def getHosts(): Collection[Host] = {
Collections.singletonList(localhostHost)
}
}
val localhostTokenMapSupplier = new TokenMapSupplier() {
@Override
def getTokens(activeHosts: Set[Host]): List[HostToken] = {
Collections.singletonList(localhostToken)
}
@Override
def getTokenForHost(host: Host, activeHosts: Set[Host]): HostToken = {
return localhostToken
}
}
val redisPort = 6379
val client = new DynoJedisClient.Builder()
.withApplicationName("pipeline")
.withDynomiteClusterName("pipeline-dynomite")
.withHostSupplier(localhostHostSupplier)
.withCPConfig(new ConnectionPoolConfigurationImpl("localhostTokenMapSupplier")
.withTokenSupplier(localhostTokenMapSupplier))
.withPort(redisPort)
.build()
}
示例4: TweetUtil
//设置package包名称以及导入依赖的类
package textmining
import java.util.List
import twitter4j.Status
import twitter4j.Twitter
import twitter4j.TwitterException
import twitter4j.TwitterFactory
import twitter4j.User
import twitter4j._
import twitter4j.api._
import twitter4j.auth._
import secret.Data
import scala.collection.mutable.ArrayBuffer
import collection.JavaConversions._
class TweetUtil(_userName: String){
private [this] val userName:String = _userName
private [this] val tweet_num:Int = 600
def getTweet():Array[String] = {
//??????????????????
val twitter:Twitter = new TwitterFactory().getInstance
twitter.setOAuthConsumer(Data.ck, Data.cs);
twitter.setOAuthAccessToken(new AccessToken(Data.at, Data.as));
val tweetArray:ArrayBuffer[String] = ArrayBuffer.empty[String]
try{
//??????
val user:User = twitter.showUser("@"+this.userName)
//id???
val id:Long = user.getId
//???????
var nowpage:Int = 1
while(tweetArray.size <= this.tweet_num){
val tweetList = twitter.getUserTimeline(id,new Paging(nowpage,600))
for(status <- tweetList){
val tweet:Status = status.asInstanceOf[Status]
tweetArray += tweet.getText
}
nowpage += 1
}
}catch{
case e:TwitterException => e.printStackTrace()
}
tweetArray.take(this.tweet_num).foreach(println _)
tweetArray.take(this.tweet_num).toArray
}
}
示例5: SendTwilio
//设置package包名称以及导入依赖的类
package com.trn.sms
import com.twilio.sdk.TwilioRestClient
import com.twilio.sdk.TwilioRestException
import com.twilio.sdk.resource.factory.MessageFactory
import com.twilio.sdk.resource.instance.Message
import org.apache.http.NameValuePair
import org.apache.http.message.BasicNameValuePair
import java.util.ArrayList
import java.util.List
object SendTwilio extends App {
val ACCOUNT_SID = "AC270965dc1d10bbe8aa812f944c351e2c"
val AUTH_TOKEN = "57a39ded3bd4b43913fb47703ad5cd65"
val client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN)
// Build a filter for the MessageList
val params = new ArrayList[NameValuePair]()
params.add(new BasicNameValuePair("Body", "Test Twilio messagessssss"))
params.add(new BasicNameValuePair("To", "+447441907695"))
params.add(new BasicNameValuePair("From", "+441618504732"))
val messageFactory = client.getAccount().getMessageFactory()
val message = messageFactory.create(params)
println(message.getSid())
}
示例6: ScakkaZooCacheJavaImpl
//设置package包名称以及导入依赖的类
package com.github.astonbitecode.zoocache.impl.java
import com.github.astonbitecode.zoocache.api.java.JScakkaZooCache
import com.github.astonbitecode.zoocache.api.ScakkaException.NotCachedException
import scala.concurrent.{ Future, Await }
import scala.concurrent.duration._
import com.github.astonbitecode.zoocache.api.scala.ScakkaZooCache
import scala.collection.JavaConversions._
import java.lang.String
import java.util.List
import com.github.astonbitecode.zoocache.api.dtos.{ JCacheResult, CacheResult }
import com.github.astonbitecode.zoocache.api.dtos.JCacheResult
import com.github.astonbitecode.zoocache.api.dtos.JCacheResult
import com.github.astonbitecode.zoocache.api.dtos.JCacheResult
import com.github.astonbitecode.zoocache.api.dtos.JCacheResult
class ScakkaZooCacheJavaImpl(scakkaCache: ScakkaZooCache) extends JScakkaZooCache {
@throws(classOf[NotCachedException])
def getChildren(path: String): List[String] = scakkaCache.getChildren(path)
@throws(classOf[NotCachedException])
def getData(path: String): Array[Byte] = scakkaCache.getData(path)
def find(regex: String): List[JCacheResult] = scakkaCache.find(regex)
def addPathToCache(path: String): java.util.concurrent.Future[Unit] = scakkaCache.addPathToCache(path)
def removePathFromCache(path: String): java.util.concurrent.Future[Unit] = scakkaCache.removePathFromCache(path)
def stop(): java.util.concurrent.Future[Unit] = scakkaCache.stop
private implicit def scalaFuture2JavaFuture[T](x: Future[T]): java.util.concurrent.Future[T] = {
new java.util.concurrent.Future[T] {
override def isCancelled: Boolean = throw new UnsupportedOperationException
override def get(): T = Await.result(x, 30.minutes)
override def get(timeout: Long, unit: TimeUnit): T = Await.result(x, Duration.create(timeout, unit))
override def cancel(mayInterruptIfRunning: Boolean): Boolean = throw new UnsupportedOperationException
override def isDone: Boolean = x.isCompleted
}
}
implicit private def scalaCacheResultListToJavaCacheResultList(scalaRes: scala.collection.immutable.List[CacheResult]): List[JCacheResult] = {
scalaRes.map { s =>
{
new JCacheResult(s.path, s.data, s.children)
}
}
}
}
示例7: Public
//设置package包名称以及导入依赖的类
package de.dangoe.freda.jooq.generated.public
import de.dangoe.freda.jooq.generated.DefaultCatalog
import de.dangoe.freda.jooq.generated.public.tables.Accounts
import de.dangoe.freda.jooq.generated.public.tables.Users
import java.util.ArrayList
import java.util.Arrays
import java.util.List
import javax.annotation.Generated
import org.jooq.Catalog
import org.jooq.Table
import org.jooq.impl.SchemaImpl
import scala.Array
object Public {
@Generated(
value = Array(
"http://www.jooq.org",
"jOOQ version:3.9.4"
),
comments = "This class is generated by jOOQ"
)
class Public extends SchemaImpl("PUBLIC", DefaultCatalog.DEFAULT_CATALOG) {
override def getCatalog : Catalog = DefaultCatalog.DEFAULT_CATALOG
override def getTables : List[Table[_]] = {
val result = new ArrayList[Table[_]]
result.addAll(getTables0)
result
}
private def getTables0(): List[Table[_]] = {
return Arrays.asList[Table[_]](
Accounts.ACCOUNTS,
Users.USERS)
}
}
示例8: OpenTsdbSinkConnector
//设置package包名称以及导入依赖的类
package com.svds.kafka.connect.opentsdb
import java.util.{List, Map}
import com.typesafe.scalalogging.LazyLogging
import org.apache.kafka.common.config.ConfigDef
import org.apache.kafka.connect.errors.ConnectException
import org.apache.kafka.connect.sink.SinkConnector
import scala.collection.JavaConversions._
import scala.collection.mutable
class OpenTsdbSinkConnector extends SinkConnector with LazyLogging {
private val configProps: Map[String, String] = mutable.Map[String, String]()
override def config: ConfigDef = {
logger.debug("config")
OpenTsdbConnectorConfig.config
}
@throws(classOf[ConnectException])
override def start(props: Map[String, String]) = {
logger.debug(s"start(props: ${props})")
this.configProps.putAll(props)
}
override def taskClass: Class[OpenTsdbSinkTask] = {
classOf[OpenTsdbSinkTask]
}
def taskConfigs(maxTasks: Int): List[Map[String, String]] = {
logger.debug(s"taskConfigs(), this.configProps: ${this.configProps}")
val range = (1 to maxTasks).toBuffer
val configs = range map { _ : Int =>
this.configProps
}
logger.debug(s"taskConfigs(), configs: ${configs}")
configs
}
override def stop = {}
override def version = "0.0.1"
}