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

Scala IllegalArgumentException类代码示例

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

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



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

示例1: Barcodes

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

import play.api.mvc.{Action, Controller}

class Barcodes extends Controller {
  val ImageResolution = 144

  // png? ???? Action
  def barcode(ean: Long) = Action {
      import java.lang.IllegalArgumentException

      val MimeType = "image/png"
      try {
        val imageData = ean13BarCode(ean, MimeType)
        Ok(imageData).as(MimeType)
      }
      catch {
        case e: IllegalArgumentException =>
          BadRequest("Couldn't generate bar code. Error: " + e.getMessage)
      }
  }

  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean

    val output: ByteArrayOutputStream = new ByteArrayOutputStream
    val canvas: BitmapCanvasProvider = new BitmapCanvasProvider(
      output, mimeType, ImageResolution, BufferedImage.TYPE_BYTE_BINARY, false, 0)

    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish

    output.toByteArray
  }
} 
开发者ID:makeajourney,项目名称:play-products-example,代码行数:40,代码来源:Barcodes.scala


示例2: Converter

//设置package包名称以及导入依赖的类
package com.dataoptimo.imgprocessing.convert
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.io.Text
import org.apache.hadoop.io.BytesWritable
import org.apache.hadoop.fs.{Path, FileSystem}
import org.apache.hadoop.io.IOUtils
import org.apache.hadoop.io.SequenceFile
import java.io.IOException
import java.lang.IllegalArgumentException

class Converter(conf: Configuration) {
  
  def imageToSequence(srcPath: String, dstPath: String){
    try {
    val fs = FileSystem.get(conf);
    val inPath = new Path(srcPath);
    val outPath = new Path(dstPath);
    val key = new Text();
    val value = new BytesWritable();
    val in = fs.open(inPath);
    val buffer = new Array[Byte](in.available())
    in.read(buffer);
    var writer = SequenceFile.createWriter(fs, conf, outPath, key.getClass(),value.getClass());
    writer.append(new Text(inPath.getName()), new BytesWritable(buffer));
    IOUtils.closeStream(writer);
    }
    catch {
      case io: IOException => println(io.getMessage)
      case illegalArgument: IllegalArgumentException => println(illegalArgument.getMessage)
    }
    
    
    
  }
} 
开发者ID:mfawadalam,项目名称:imgprocessing,代码行数:36,代码来源:Converters.scala


示例3: Barcodes

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

import play.api.mvc.{Action, Controller}

class Barcodes extends Controller{
	val ImageResolution = 144

	def barcode(ean: Long) = Action{
		import java.lang.IllegalArgumentException

		val MimeType = "image/png"
		try{
			val imageData = ean13BarCode(ean, MimeType)
			Ok(imageData).as(MimeType)
		}catch{
			case e:IllegalArgumentException =>
			BadRequest("Couldn't generate bar code. Error: " + e.getMessage)
		}
	}

	def ean13BarCode(ean:Long, mimeType: String) : Array[Byte] = {
		import java.io.ByteArrayOutputStream
		import java.awt.image.BufferedImage
		import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
		import org.krysalis.barcode4j.impl.upcean.EAN13Bean

		val output: ByteArrayOutputStream = new ByteArrayOutputStream
		val canvas: BitmapCanvasProvider = 
			new BitmapCanvasProvider(output, mimeType, ImageResolution,
				BufferedImage.TYPE_BYTE_BINARY, false, 0)

		val barcode = new EAN13Bean()
		barcode.generateBarcode(canvas, String valueOf ean)
		canvas.finish

		output.toByteArray
	}
} 
开发者ID:WackStr,项目名称:PlayProducts,代码行数:39,代码来源:Barcodes.scala


示例4: Barcodes

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

import play.api.mvc.{Action, Controller}

class Barcodes extends Controller {
  val ImageResolution = 144

  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException
    val MimeType = "image/png"
    try {
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    }
    catch {
      case e: IllegalArgumentException =>
        BadRequest("Couldn’t generate bar code. Error: " + e.getMessage)
    }
  }

  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean
    val output: ByteArrayOutputStream = new ByteArrayOutputStream
    val canvas: BitmapCanvasProvider =
      new BitmapCanvasProvider(output, mimeType, ImageResolution,
        BufferedImage.TYPE_BYTE_BINARY, false, 0)
    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish
    output.toByteArray
  }
} 
开发者ID:augfool,项目名称:scala_play2_web,代码行数:36,代码来源:Barcodes.scala


示例5: Barcodes

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

import play.api.mvc.{Action, Controller}


class Barcodes extends Controller {
  val ImageResolution = 144

  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException

    val MimeType = "image/png"
    try {
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    }
    catch {
      case e: IllegalArgumentException =>
      BadRequest("Couldn’t generate bar code. Error: " + e.getMessage)
    }
  }


  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean

    val output: ByteArrayOutputStream = new ByteArrayOutputStream
    val canvas: BitmapCanvasProvider =
      new BitmapCanvasProvider(output, mimeType, ImageResolution,
      BufferedImage.TYPE_BYTE_BINARY, false, 0)

    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish

    output.toByteArray
  }

} 
开发者ID:ema00,项目名称:Play-Framework-CRUD,代码行数:43,代码来源:Barcodes.scala


示例6: MinHashDocument

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

import java.nio.charset.StandardCharsets
import java.lang.IllegalArgumentException
import com.google.common.hash._

class MinHashDocument(text: String, signatureLength: Int = 100, shingleLength: Int = 5, seed: Int = 5) {
  def generateShingles(): Iterator[String] = {
    text.split("\\s+").sliding(shingleLength).map(gram => gram.mkString(" "))
  }

  def generateMinHashSignature(): Array[Int] = {
    (seed to (seed + signatureLength - 1)).map { randomSeed => 
      val hashFunction: HashFunction = Hashing.murmur3_32(randomSeed)
      generateShingles().map(shingle => hashFunction.hashString(shingle, StandardCharsets.UTF_8).asInt).min
    }.toArray
  }
}

object MinHashDocument {
  def jaccardSimilarity[A](item1: Iterable[A], item2: Iterable[A]): Double = {
    val set1: Set[A] = item1.toSet
    val set2: Set[A] = item2.toSet
    set1.intersect(set2).size.toDouble / set1.union(set2).size.toDouble
  }

  def minhashSimilarity[A](item1: Array[A], item2: Array[A]): Double = {
    if (item1.length != item2.length) {
      throw new IllegalArgumentException("MinHashes must be equal length")
    }
   
    val agreeingRows = item1.zip(item2).map { case(val1, val2) =>
      if (val1 == val2) {
        1
      } else {
        0
      }
    }.sum

    agreeingRows.toDouble / item1.length.toDouble
  }
} 
开发者ID:steven-s,项目名称:minhash-document-clusters,代码行数:43,代码来源:MinHashDocument.scala


示例7: BarcodesController

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

import javax.inject._

import play.api._
import play.api.mvc._


class BarcodesController @Inject() extends Controller {
  val ImageResolution = 144

  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean

    val output: ByteArrayOutputStream = new ByteArrayOutputStream
    val canvas: BitmapCanvasProvider = new BitmapCanvasProvider(output, mimeType, ImageResolution, BufferedImage.TYPE_BYTE_BINARY, false, 0)
    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish
    output.toByteArray
  }

  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException

    val MimeType = "image/png"

    try {
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    } catch {
      case e: IllegalArgumentException =>
        BadRequest("Couldn’t generate bar code. Error: " + e.getMessage)
    }
  }
} 
开发者ID:yomajkel,项目名称:scala_play_book,代码行数:40,代码来源:BarcodesController.scala


示例8: BarcodesController

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



import javax.inject.{Inject, Singleton}
import play.api.mvc.{Action, Controller}


@Singleton
class BarcodesController @Inject() extends Controller {
  val ImageResolution = 144

  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException

    val MimeType = "image/png"
    try{
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    }catch {
      case e: IllegalArgumentException =>
        BadRequest("Couldn't generate bar code. Error: " + e.getMessage)
    }

  }

  def ean13BarCode(ean: Long, mimeType: String) : Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean
    var output: ByteArrayOutputStream = new ByteArrayOutputStream
    var canvas: BitmapCanvasProvider =
      new BitmapCanvasProvider(output, mimeType, ImageResolution,
        BufferedImage.TYPE_BYTE_BINARY, false, 0)

    val barCode = new EAN13Bean()
    barCode.generateBarcode(canvas, String valueOf ean)
    canvas.finish
    output.toByteArray
  }
} 
开发者ID:lanheixingkong,项目名称:product-list,代码行数:43,代码来源:BarcodesController.scala


示例9: BarcodesController

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

import java.awt.image.BufferedImage
import javax.inject.{Inject, Singleton}

import play.api.Configuration
import play.api.mvc.{Action, Controller}

@Singleton
class BarcodesController @Inject() (val configuration: Configuration) extends Controller  {
  val ImageResolution = 144

  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException

    val MimeType = "image/png"
    try {
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    } catch {
      case e: IllegalArgumentException =>
        BadRequest("Couldn't generate bar code. Error: " + e.getMessage)
    }
  }

  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {

    import java.io.ByteArrayOutputStream
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean

    val output: ByteArrayOutputStream = new ByteArrayOutputStream()
    val canvas: BitmapCanvasProvider = new BitmapCanvasProvider(output, mimeType, ImageResolution,
      BufferedImage.TYPE_BYTE_BINARY, false, 0)

    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish()

    output.toByteArray
  }
} 
开发者ID:jacksonja,项目名称:product,代码行数:43,代码来源:BarcodesController.scala


示例10: Main

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

import java.lang.IllegalArgumentException

import com.typesafe.config.{Config, ConfigFactory}
import numb.translate.NumberTranslationService
import scaldi.{Injectable, Injector, TypesafeConfigInjector}


object Main extends App with Injectable {
  // Declare injector bindings where properties are added after module bindings
  implicit val injector : Injector = TypesafeConfigInjector(ConfigFactory.load()) :: new NumbModule
  val translator: NumberTranslationService = inject[NumberTranslationService]
  if (args.length == 1) {
    try {
      println(translator.translate(args(0)))
    } catch {
      case e:IllegalArgumentException => println("Please enter a number only containing digits between 0 and 1000001")
    }
  } else {
    println("Please pass exactly one argument only containing digits.")
  }
} 
开发者ID:whfern,项目名称:numb,代码行数:24,代码来源:Main.scala


示例11: BarcodesController

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

import play.api.mvc.Controller
import javax.inject.Inject
import javax.inject.Singleton
import play.api.mvc.Action

@Singleton
class BarcodesController @Inject() extends Controller {
  
  val ImageResolution = 144
  
  def barcode(ean: Long) = Action {
    import java.lang.IllegalArgumentException
    val MimeType = "image/png"
    try {
      val imageData = ean13BarCode(ean, MimeType)
      Ok(imageData).as(MimeType)
    } catch {
      case e: IllegalArgumentException =>
        BadRequest("Couldn’t generate bar code. Error: " + e.getMessage)
    }
  }
  
  def ean13BarCode(ean: Long, mimeType: String): Array[Byte] = {
    import java.io.ByteArrayOutputStream
    import java.awt.image.BufferedImage
    import org.krysalis.barcode4j.output.bitmap.BitmapCanvasProvider
    import org.krysalis.barcode4j.impl.upcean.EAN13Bean
    val output: ByteArrayOutputStream = new ByteArrayOutputStream
    val canvas: BitmapCanvasProvider =
      new BitmapCanvasProvider(output, mimeType, ImageResolution,
        BufferedImage.TYPE_BYTE_BINARY, false, 0)
    val barcode = new EAN13Bean()
    barcode.generateBarcode(canvas, String valueOf ean)
    canvas.finish
    output.toByteArray
  }
} 
开发者ID:Dread1982,项目名称:play_products,代码行数:40,代码来源:BarCodesController.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala SpringApplication类代码示例发布时间:2022-05-23
下一篇:
Scala HttpClientBuilder类代码示例发布时间: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