• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala URLDecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中java.net.URLDecoder的典型用法代码示例。如果您正苦于以下问题:Scala URLDecoder类的具体用法?Scala URLDecoder怎么用?Scala URLDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了URLDecoder类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: Main

//设置package包名称以及导入依赖的类
package hu.blackbelt.cd.bintray.deploy

import java.net.URLDecoder

import com.amazonaws.services.lambda.runtime.Context
import com.amazonaws.services.lambda.runtime.events.S3Event
import com.typesafe.scalalogging.LazyLogging

import scala.collection.JavaConverters._

class Main(context: Context) extends LazyLogging {
  private def decodeS3Key(key: String): String = URLDecoder.decode(key.replace("+", " "), "utf-8")

  def deploy(event: S3Event) = {


    event.getRecords.asScala.foreach(
      s3EventRecord => {
        val bucket = s3EventRecord.getS3.getBucket.getName
        val key = decodeS3Key(s3EventRecord.getS3.getObject.getKey)
        val loc = StorageLocation(bucket, key)

        logger.info(s"received event for $loc")

        val parts = key.split('/')
        require(parts.size > 1, s"cannot extract project name and version from $key")
        val project = parts(0)

        val version = parts(1)
        val deployer = new Deploy(Project(loc, project, version))
        logger.info(s"fetching $loc")
        val archive = deployer.fetch {
          is => {
            logger.info("fetched")
            logger.info("starting deployment to bintray")
            deployer.upload(is).failed.toOption.foreach(throw _)
            logger.info("deployment success")
          }
        }

      }
    )

  }
} 
开发者ID:tsechov,项目名称:s3-bintray-deploy,代码行数:46,代码来源:Main.scala


示例2: disableUi

//设置package包名称以及导入依赖的类
package net.ruippeixotog.scalafbp.http

import java.net.URLDecoder

import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.model.Uri
import akka.http.scaladsl.model.Uri.Query
import akka.http.scaladsl.server.Directives._
import spray.json.DefaultJsonProtocol._
import spray.json._

trait UiHttpService {

  def disableUi: Boolean

  private[this] val dummyUser = "user"
  private[this] val dummyUserName = "ScalaFBP Development Environment"
  private[this] val dummyToken = "oauthToken"

  // format: OFF
  lazy val uiRoutes =
    if(disableUi) reject
    else {
      pathPrefix("oauth") {
        path("login" / "oauth" / "authorize") {
          parameter("redirect_uri") { encodedUri =>
            val uri = Uri(URLDecoder.decode(encodedUri, "UTF-8"))
            redirect(uri.withQuery(Query("code" -> dummyUser)), Found)
          }
        } ~
        path("authenticate" / dummyUser) {
          complete(Map("token" -> dummyToken))
        } ~
        path("user") {
          complete(JsObject(
            "name" -> JsString(dummyUserName),
            "github" -> JsObject.empty))
        }
      } ~
      pathEndOrSingleSlash { getFromResource("ui/index.html") } ~
      getFromResourceDirectory("ui")
    }
  // format: ON
} 
开发者ID:ruippeixotog,项目名称:scalafbp,代码行数:46,代码来源:UiHttpService.scala


示例3: DoobieHelpers

//设置package包名称以及导入依赖的类
package com.imageintelligence.pix.repository

import java.net.{URL, URLDecoder}
import java.time.Instant

import doobie.imports._

object DoobieHelpers {
  implicit val URLMeta: Meta[URL] =
    Meta[String].nxmap(
      i => new URL(i),
      i => URLDecoder.decode(i.toString, "UTF-8")
    )

  implicit val InstantMeta: Meta[Instant] =
    Meta[java.sql.Timestamp].nxmap(
      i => i.toInstant,
      i => new java.sql.Timestamp(i.toEpochMilli)
    )
} 
开发者ID:ImageIntelligence,项目名称:pix-api,代码行数:21,代码来源:DoobieHelpers.scala


示例4: getImageType

//设置package包名称以及导入依赖的类
package org.aj.awslambda

import java.awt.image.BufferedImage
import java.io.IOException
import java.net.URLDecoder

import com.amazonaws.services.lambda.runtime.events.S3Event
import java.util.regex.Pattern

import scala.concurrent.{Await, Future}
import scala.concurrent.ExecutionContext.Implicits.global


  private def getImageType(srcKey: String): Option[String] = {
    val matcher = Pattern.compile(".*\\.([^\\.]*)").matcher(srcKey)
    matcher.matches() match {
      case true => {
        //get source image type and validate
        val imageType = matcher.group(1)
        imageTypes.get(imageType) match {
          case Some(_) => Some(imageType)
          case _ => None
        }
      }
      case _ => None
    }
  }

  private def decodeS3Key(key: String): String = URLDecoder.decode(key.replace("+", " "), "utf-8")

  private def process(srcBucket: String, srcKey: String, imageType: String, dstBucket: String): Future[List[Url]] = {

    //get source image with it's sizes
    val sourceImage: (BufferedImage, Url) = getImage(srcBucket, srcKey)
    //re-size
    val original: Future[Url] = process(sourceImage._1, sourceImage._2, imageType, dstBucket, srcKey)
    val resized: List[Option[Future[Url]]] = sizes.map { size =>
      if (sourceImage._2.width != size) Some(process(sourceImage._1, size, imageType, dstBucket, srcKey))
      else None
    }
    //return
    Future.sequence(original :: resized.flatten)

  }

} 
开发者ID:ajmnsk,项目名称:awslambda-resize,代码行数:47,代码来源:ImageHandler.scala


示例5: createTempDir

//设置package包名称以及导入依赖的类
package eu.shiftforward.apso

import java.net.URLDecoder
import java.io.{ File, InputStream }

trait TestHelper {

  def createTempDir(prefix: String = "logs", suffix: String = ""): File = {
    val temp = File.createTempFile(prefix, suffix)
    temp.delete()
    temp.mkdir()
    temp.deleteOnExit()
    temp
  }

  @deprecated("Use `eu.shiftforward.apso.io.ResourceUtil.getResourceURL` instead where the " +
    "`resource` argument is already prefixed with a '/'", "2016/05/24")
  def getResourceURL(resource: String): String =
    URLDecoder.decode(getClass.getResource(resource).getFile, "UTF-8")

  @deprecated("Use `eu.shiftforward.apso.io.ResourceUtil.getResourceStream` instead where the " +
    "`resource` argument is already prefixed with a '/'", "2016/05/24")
  def getResourceStream(resource: String): InputStream =
    getClass.getResourceAsStream(resource)
} 
开发者ID:ShiftForward,项目名称:apso,代码行数:26,代码来源:TestHelper.scala


示例6: HardCodedGroundTruthImportTest

//设置package包名称以及导入依赖的类
package org.opencompare.io.wikipedia

import java.net.URLDecoder
import java.nio.charset.StandardCharsets

import org.opencompare.api.java.impl.PCMFactoryImpl
import org.opencompare.io.wikipedia.io.{WikiTextTemplateProcessor, WikiTextLoader, MediaWikiAPI}
import org.scalatest.{Matchers, FlatSpec}


class HardCodedGroundTruthImportTest extends FlatSpec with Matchers {

  val pcmFactory = new PCMFactoryImpl
  val url = "wikipedia.org"
  val mediaWikiAPI = new MediaWikiAPI(url)
  val miner = new WikiTextLoader(new WikiTextTemplateProcessor(mediaWikiAPI))

  it should "import a PCM with special characters or nested tables (don't remember what the test is supposed to do)" in  {
    val language = "ja"
    val title = "%E6%A0%83%E6%9C%A8%E7%9C%8C"
    val decodedTitle = URLDecoder.decode(title, StandardCharsets.UTF_8.name)
    val wikitext = mediaWikiAPI.getWikitextFromTitle(language, decodedTitle)
    val pcms = miner.mine(language, wikitext, title)

    pcms.size() shouldNot be (0)
  }

} 
开发者ID:Bastcloa,项目名称:testJenkins,代码行数:29,代码来源:HardCodedGroundTruthImportTest.scala


示例7: NowPlaying

//设置package包名称以及导入依赖的类
import java.io.File
import java.net.URLDecoder
import scala.sys.process.{ Process, ProcessIO }
import scala.io.Source

object NowPlaying {
	def main(args: Array[String]): Unit = {
	  val processBuilder = Process("qdbus-qt5 org.mpris.MediaPlayer2.audacious /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Metadata")
	  val processIo = new ProcessIO(
	  	_ => (),
	  	stdout => {
	  		val wantedLines = Source.fromInputStream(stdout).getLines().map { line =>
	  			val values = line.split(": ")

	  			if(values.length > 0) {
	  				(values(0), values.drop(1).foldLeft("")((x, y) => x + y))
	  			} else {
	  				("", "")
	  			}
	  		}.toMap.filter(x => x._1 == "xesam:title" || x._1 == "xesam:artist" || x._1 == "xesam:url")

	  		val nowPlayingResult = NowPlayingResult(wantedLines.get("xesam:title"), wantedLines.get("xesam:artist"), wantedLines.get("xesam:url"))

	  		nowPlayingResult match {
	  			case NowPlayingResult(None, None, url) => {
	  				val filename = new File(url.get).getName

	  				val decodedFilename = URLDecoder.decode(filename, "UTF-8")

	  				println(s"/me is playing $decodedFilename")
	  			}
	  			case NowPlayingResult(title, artist, _) => println(s"/me is playing ${artist.get} - ${title.get}")
	  			case _ => println("/me is playing I have no idea")
	  		}
	  	},
	  	_ => ()
	 	)

	 	processBuilder.run(processIo)
	}
}

case class NowPlayingResult(title: Option[String], artist: Option[String], absolutePath: Option[String]) 
开发者ID:nadams,项目名称:now-playing,代码行数:44,代码来源:NowPlaying.scala


示例8: DoobieHelpers

//设置package包名称以及导入依赖的类
package me.davidvuong.http_api.helpers

import java.net.{URL, URLDecoder}
import java.time.Instant

import doobie.imports._
import me.davidvuong.http_api.domain.MessageStatus

object DoobieHelpers {
  implicit val URLMeta: Meta[URL] =
    Meta[String].nxmap(
      i => new URL(i),
      i => URLDecoder.decode(i.toString, "UTF-8")
    )

  implicit val InstantMeta: Meta[Instant] =
    Meta[java.sql.Timestamp].nxmap(
      i => i.toInstant,
      i => new java.sql.Timestamp(i.toEpochMilli)
    )

  implicit val MessageStatusMeta2: Meta[MessageStatus] =
    Meta[String].nxmap(
      i => MessageStatus.fromString(i).fold(sys.error, identity),
      i => MessageStatus.toString(i)
    )
} 
开发者ID:davidvuong,项目名称:docker-compose-bp,代码行数:28,代码来源:DoobieHelpers.scala


示例9: ELBSSLCertificateLambdaConfig

//设置package包名称以及导入依赖的类
package com.ocelotconsulting

import java.net.URLDecoder

import com.amazonaws.services.s3.event.S3EventNotification.S3Entity
import com.typesafe.config.{Config, ConfigFactory}

import scala.collection.JavaConverters._
import scala.language.postfixOps


package object ssl {
  object ELBSSLCertificateLambdaConfig {
    val config = ConfigFactory.load()
    val certInfo: Iterable[Config] = config.getConfigList("cert-path-to-arn") asScala
    private def forS3Event(s3Path: String): Config = certInfo.filter { _.getString("s3") == s3Path} head
    def arn(s3Path: String) =  forS3Event(s3Path).getString("arn")
    def elb(s3Path: String) = forS3Event(s3Path).getString("elb")
  }

  def toSSLCertName(entity: S3Entity): String =
    ELBSSLCertificateLambdaConfig.arn(s"${decodeS3Key(entity.getBucket.getName)}/${decodeS3Key(entity.getObject.getKey)}")

  def toELBName(entity: S3Entity): String =
    ELBSSLCertificateLambdaConfig.elb(s"${decodeS3Key(entity.getBucket.getName)}/${decodeS3Key(entity.getObject.getKey)}")

  def decodeS3Key(key: String): String = URLDecoder.decode(key.replace("+", " "), "utf-8")
} 
开发者ID:ocelotconsulting,项目名称:elb-ssl-cert-lambda,代码行数:29,代码来源:package.scala


示例10: PlainQueryConverter

//设置package包名称以及导入依赖的类
package com.hypertino.hyperbus.model.hrl

import java.net.{URLDecoder, URLEncoder}

import com.hypertino.binders.value.{Null, Obj, Text, Value}

object PlainQueryConverter extends QueryConverter {
  final val encoding = "UTF-8"

  override def parseQueryString(queryString: String): Value = {
    if (queryString == null || queryString.isEmpty) {
      Null
    } else {

      Obj(queryString.split('&').map { s ?
        val i = s.indexOf('=')
        if (i>0) {
          val left = s.substring(0, i)
          val right = Text(URLDecoder.decode(s.substring(i+1), encoding))
          left ? right
        }
        else {
          s ? Null
        }
      }.toMap)
    }
  }

  override def toQueryString(value: Value): String = {
    value match {
      case Null ? ""
      case Text(s) ? s
      case Obj(elements) ? elements.map { case (k, v) ?
        if (v.isNull) {
          k
        }
        else {
          k + "=" + URLEncoder.encode(v.toString, encoding)
        }
      } mkString "&"
      case other ? throw new IllegalArgumentException(s"$other is not an Obj or Text")
    }
  }
} 
开发者ID:hypertino,项目名称:hyperbus,代码行数:45,代码来源:PlainQueryConverter.scala


示例11: Main

//设置package包名称以及导入依赖的类
package net.nocono

import java.io.{ InputStream, OutputStream }
import java.net.URLDecoder

import com.fasterxml.jackson.databind.{ DeserializationFeature, ObjectMapper }
import com.fasterxml.jackson.module.scala.DefaultScalaModule

class Main {
  val scalaMapper = new ObjectMapper().registerModule(new DefaultScalaModule).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

  def handler(input: InputStream, output: OutputStream): Unit = {
    val params = scalaMapper.readValue(input, classOf[SlackOutgoingData])
    println(params)
    val result = params.decodedText match {
      case "?????" => Some(s"?????, ${params.user_name}")
      case "Scala"      => Some("?????")
      case _            => None
    }

    result.foreach { r =>
      output.write( s"""{ "text": "$r" }""".getBytes("UTF-8"))
    }
  }
}

case class SlackOutgoingData(
  token: String,
  team_id: String,
  team_domain: String,
  service_id: String,
  channel_id: String,
  channel_name: String,
  timestamp: String,
  user_id: String,
  user_name: String,
  text: String,
  trigger_word: String) {

  val decodedText = URLDecoder.decode(text, "UTF-8")

} 
开发者ID:SAMMY7th,项目名称:aws-lambda-scala,代码行数:43,代码来源:Main.scala


示例12: Binders

//设置package包名称以及导入依赖的类
package support

import events._
import eventstore.{ StoreRevision, StreamRevision }
import java.net.URLDecoder
import java.util.UUID

object Binders {
  implicit def IdentifierPathBindable[A <: Identifier](implicit companion: IdentifierCompanion[A]) = new play.api.mvc.PathBindable[A] {
    override def bind(key: String, value: String) = try {
      Right(companion.apply(UUID.fromString(URLDecoder.decode(value, "utf-8"))))
    } catch {
      case _: RuntimeException => Left(s"Cannot parse parameter $key as ${companion.prefix}: ${URLDecoder.decode(value, "utf-8")}")
    }
    override def unbind(key: String, value: A) = value.uuid.toString
  }

  implicit object CommentIdBindable extends play.api.mvc.PathBindable[CommentId] {
    override def bind(key: String, value: String) = try {
      Right(CommentId(URLDecoder.decode(value, "utf-8").toInt))
    } catch {
      case _: RuntimeException => Left(s"Cannot parse parameter $key as CommentId: ${URLDecoder.decode(value, "utf-8")}")
    }
    override def unbind(key: String, value: CommentId) = value.value.toString
  }

  implicit object queryStringBindableStoreRevision extends play.api.mvc.QueryStringBindable[StoreRevision] {
    override def bind(key: String, params: Map[String, Seq[String]]) = params.get(key).flatMap(_.headOption).map { value =>
      try {
        Right(StoreRevision(value.toLong))
      } catch {
        case _: RuntimeException => Left(s"Cannot parse parameter $key as StoreRevision: $value")
      }
    }
    override def unbind(key: String, value: StoreRevision) = s"$key=${value.value}"
  }

  implicit object queryStringBindableStreamRevision extends play.api.mvc.QueryStringBindable[StreamRevision] {
    override def bind(key: String, params: Map[String, Seq[String]]) = params.get(key).flatMap(_.headOption).map { value =>
      try {
        Right(StreamRevision(value.toLong))
      } catch {
        case _: RuntimeException => Left(s"Cannot parse parameter $key as StreamRevision: $value")
      }
    }
    override def unbind(key: String, value: StreamRevision) = s"$key=${value.value}"
  }
} 
开发者ID:cubean,项目名称:play-blog-example,代码行数:49,代码来源:Binders.scala


示例13: Paths

//设置package包名称以及导入依赖的类
package myscala.util

import java.io.File
import java.net.{URL, URLDecoder}

import myscala._
import myscala.io.Resource

object Paths {

    def urlAsFile(url: URL): File = {
        if (url == null) return null
        new File(urlAsPath(url))
    }

    def urlAsPath(url: URL): String = {
        if (url == null) {
            return null
        }
        val protocol = url.getProtocol
        var file = url.getPath

        file = URLDecoder.decode(file, "UTF8")

        if (Resource.URL_PROTOCOL_FILE == protocol) {
            return file
        }
        else if (Resource.URL_PROTOCOL_JAR == protocol || Resource.URL_PROTOCOL_ZIP == protocol) {
            val ipos = file.indexOf(Resource.URL_SEPARATOR_JAR)
            if (ipos > 0) file = file.substring(0, ipos)
            if (file.startsWith(Resource.URL_PREFIX_FILE)) file = file.substring(Resource.URL_PREFIX_FILE.length)
            return file
        }
        else if (Resource.URL_PROTOCOL_VFS == protocol) {
            val ipos = file.indexOf(Resource.URL_SEPARATOR_JAR)
            if (ipos > 0) file = file.substring(0, ipos)
            else if (file.endsWith("/")) file = file.substring(0, file.length - 1)
            return file
        }
        file
    }

    def removeStart(path: String, remove: String): String = path.stripStart(remove)

    def removeEnd(path: String, remove: String): String = path.stripEnd(remove)

} 
开发者ID:yingzhuo,项目名称:myscala,代码行数:48,代码来源:Paths.scala


示例14: Main

//设置package包名称以及导入依赖的类
package com.iheart.lambda

import java.net.URLDecoder
import com.iheart.lambda.Utils._
import play.api.libs.ws.WSResponse
import play.api.libs.ws.ning.NingWSClient
import scala.collection.JavaConverters._
import com.amazonaws.services.lambda.runtime.events.S3Event
import com.amazonaws.services.lambda.runtime.Context
import scala.concurrent.{Future, Await}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global


class Main {

  val wsClient = NingWSClient()

  
  def handleEvent(event: S3Event, context: Context) = {
    event.getRecords.asScala.foreach { record =>
       val bucket = record.getS3.getBucket.getName
       val key = URLDecoder.decode(record.getS3.getObject.getKey,"UTF-8")
       println("Received key " + key)
       sendToNewRelic(parseLogFile(bucket,key))
    } 
  } 
} 
开发者ID:denen99,项目名称:fastly-lambda,代码行数:29,代码来源:Main.scala


示例15: lurlDecode

//设置package包名称以及导入依赖的类
package com.levent.hive.udfs

import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF
import java.net.URLDecoder

@Description(
        name = "lurlDecode",
        value = "_FUNC_(string) URLDecode - decodes application/x-www-form-urlencoded type into string (UTF-8)",
        extended = "SELECT lurlDecode(string) FROM test LIMIT 1;")
class lurlDecode extends UDF {
  def evaluate(url: String ): String= {
	if (url == null )
	   return null
	val decodedURL= java.net.URLDecoder.decode(url, "UTF-8");
	return (decodedURL)
	
  }

} 
开发者ID:lserinol,项目名称:Hive-udfs,代码行数:21,代码来源:lurldecode.scala


示例16: NameInfo

//设置package包名称以及导入依赖的类
package com.peopledesigned

import scala.collection.JavaConverters._
import java.net.URLDecoder
import java.io.{InputStream, OutputStream, PrintStream}
import com.amazonaws.services.lambda.runtime.events.S3Event

case class NameInfo(firstName: String, lastName: String)

case class MyLambdaApp() {
  def decodeS3Key(key: String): String = URLDecoder.decode(key.replace("+", " "), "utf-8")

  @LambdaFunction(path="/getsource", inputModel="I", outputModel="O")
  def getSourceBuckets(event: S3Event): java.util.List[String] = {
    val result = event.getRecords.asScala.map(record => decodeS3Key(record.getS3.getObject.getKey)).asJava
    println(result)
    return result
  }

  val scalaMapper = {
    import com.fasterxml.jackson.databind.ObjectMapper
    import com.fasterxml.jackson.module.scala.DefaultScalaModule
    new ObjectMapper().registerModule(new DefaultScalaModule)
  }

  @LambdaFunction(path="/greeting", inputModel="I", outputModel="O")
  def greeting(input: InputStream, output: OutputStream): Unit = {
    val name = scalaMapper.readValue(input, classOf[NameInfo])
    val result = s"Greetings ${name.firstName} ${name.lastName}." 
    output.write(result.getBytes("UTF-8"))
  }
} 
开发者ID:Java1Guy,项目名称:sbt-scalamkins,代码行数:33,代码来源:MyLambdaApp.scala


示例17: JsonHttpClient

//设置package包名称以及导入依赖的类
package client

import java.net.URLDecoder
import javax.inject.Inject

import com.google.inject.Singleton
import org.slf4j.LoggerFactory
import play.api.libs.concurrent.Execution.Implicits._
import play.api.libs.json.JsValue
import play.api.libs.json.Json.parse
import play.api.libs.ws.WSClient

import scala.concurrent.Future

@Singleton
class JsonHttpClient @Inject()(wsClient: WSClient) {
  private val logger = LoggerFactory.getLogger(getClass)

  def get(url: String): Future[JsValue] = {
    wsClient.url(url).get().map(resp => {
      resp.status match {
        case 200 => parse(resp.body.trim)
        case _ => {
          val response = parse(resp.body)
          val errorResponse = (response \ "errorResponse").get
          val statusCode = (errorResponse \ "statusCode").get
          val errorStatus: String = (errorResponse \ "status").get.as[String]
          val searchQuery: String = (errorResponse \ "searchQuery").get.as[String]
          val decodedUrl = URLDecoder.decode(searchQuery, "UTF-8")

          logger.error(s"Api throws error with statusCode = ${statusCode}," +
            s" message = ${errorStatus}, query = ${searchQuery}")

          throw new Exception(s"statusCode: $statusCode, errorStatus: $errorStatus for searchQuery: $decodedUrl")
        }
      }
    }
    )
  }
} 
开发者ID:kunalherkal,项目名称:comparator,代码行数:41,代码来源:JsonHttpClient.scala


示例18: Application

//设置package包名称以及导入依赖的类
package controllers

import javax.inject.Inject
import java.net.URLDecoder

import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api._
import play.api.libs.json.Json
import play.api.mvc._


class Application @Inject() (configuration: Configuration) extends Controller {

  val decoder = new URLDecoder()

  val ime = (new models.IME(configuration)).ime


  def index = Action {
    Ok("hello")
  }

  def lookup(query: String, usePOJ: Boolean=false) = Action.async {
      scala.concurrent.Future {
        val candidates =
          ime.computeCandidateList(query, "", true, usePOJ)
            .filter(_.consumedLength == query.length)
            .map(_.label)
            .mkString("|")
        Ok(candidates)
      }
  }

  def ime(query:String, context: String, usePOJ: Boolean=false): Action[AnyContent] = Action.async {
    val decodedContext = URLDecoder.decode(context,"UTF8")
    scala.concurrent.Future {
      val strippedContext = decodedContext.substring(math.max(0,decodedContext.length - 9), decodedContext.length)
      val strippedQuery = query.substring(0, math.min(100,query.length))
      val normalized = ime.normalizeRomanization(strippedQuery, usePOJ, usePOJ)
      Logger.info(s"$normalized : P($strippedQuery|$strippedContext)")
      Ok(s"${normalized.getOrElse("???")}\n${ime.computeCandidateList(strippedQuery, strippedContext, true, usePOJ).map(_.label).mkString("\n").toString}")
    }
  }

} 
开发者ID:a-tsioh,项目名称:TaigIME2-webAPI-scala,代码行数:46,代码来源:Application.scala


示例19: explodeClasspath

//设置package包名称以及导入依赖的类
package com.hindog.grid

import java.io.{File, FileFilter}
import java.net.{JarURLConnection, URL, URLDecoder}

import scala.collection.JavaConverters._
import scala.collection._


  def explodeClasspath(classpath: String = System.getProperty("java.class.path")): Array[URL] = {
    classpath.split(File.pathSeparator).flatMap(file => {
      if (file.endsWith(".jar")) {
        try {
          val url = new URL("jar:file:" + file + "!/META-INF/MANIFEST.MF")
          val jarConnection = url.openConnection().asInstanceOf[JarURLConnection]
          val manifest = new java.util.jar.Manifest(jarConnection.getInputStream)
          manifest.getMainAttributes.getValue("Class-Path").split("\\s+").map(f => URLDecoder.decode(f, "UTF-8")).toSeq
        } catch {
          case ex: Exception => Seq(file)
        }
      } else if (file.endsWith("*")) {
        new File(file.stripSuffix("*")).listFiles(new FileFilter {
          override def accept(pathname: File): Boolean = pathname.getName.endsWith(".jar") || pathname.getName.endsWith(".xml") || pathname.getName.endsWith(".properties") || pathname.getName.endsWith(".class")
        }).map(_.toString).toSeq
      } else {
        Seq(file)
      }
    }).map(s => new File(s).toURI.toURL)
  }
} 
开发者ID:hindog,项目名称:grid-executor,代码行数:31,代码来源:ClasspathUtils.scala



注:本文中的java.net.URLDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala DateTimeFormat类代码示例发布时间:2022-05-23
下一篇:
Scala FileReader类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap