本文整理汇总了Python中java.lang.Integer.valueOf方法的典型用法代码示例。如果您正苦于以下问题:Python Integer.valueOf方法的具体用法?Python Integer.valueOf怎么用?Python Integer.valueOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.lang.Integer
的用法示例。
在下文中一共展示了Integer.valueOf方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: buildBarChart
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import valueOf [as 别名]
def buildBarChart(self, context):
barChartData = None
self.systemConfig = context["systemConfig"]
self.imgW = 550
self.imgH = 400
if (self.request.getParameter("w") is not None):
self.imgW = Integer.valueOf(self.request.getParameter("w"))
if (self.request.getParameter("h") is not None):
self.imgH = Integer.valueOf(self.request.getParameter("h"))
self.fromDtTxt = self.request.getParameter("from")
self.toDtTxt = self.request.getParameter("to")
if (self.fromDtTxt is None or self.toDtTxt is None):
self.errorMsg = "Invalid date range."
return
self.fromDt = self.dateFormatter.parse(self.fromDtTxt)
self.toDt = self.dateFormatter.parse(self.toDtTxt)
if (self.fromDt.after(self.toDt)):
self.errorMsg = "Invalid date range."
return
self.out = self.response.getOutputStream("image/png")
chartHandlerConfig =self.systemConfig.getObject("charts").get(self.chartName)
className = chartHandlerConfig.get("className")
chartHandlerClass = Class.forName(className)
chartHandlerObject = chartHandlerClass.newInstance()
setSystemConfigMethod = chartHandlerClass.getMethod("setSystemConfig", self.get_class("com.googlecode.fascinator.common.JsonSimple"))
setSystemConfigMethod.invoke(chartHandlerObject, self.systemConfig)
setScriptingServiceMethod = chartHandlerClass.getMethod("setScriptingServices", self.get_class("com.googlecode.fascinator.portal.services.ScriptingServices"))
setScriptingServiceMethod.invoke(chartHandlerObject, context['Services'])
setFromDateMethod = chartHandlerClass.getMethod("setFromDate", self.get_class("java.util.Date"))
setFromDateMethod.invoke(chartHandlerObject, self.fromDt)
setFromDateMethod = chartHandlerClass.getMethod("setToDate", self.get_class("java.util.Date"))
setFromDateMethod.invoke(chartHandlerObject, self.toDt)
renderChartMethod = chartHandlerClass.getMethod("renderChart",
self.get_class("java.io.OutputStream"))
renderChartMethod.invoke(chartHandlerObject, self.out);
self.out.close()
示例2: abs
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import valueOf [as 别名]
print 'type conversions'
print 'numbers'
from java.lang.Math import abs
assert abs(-2.) == 2., 'Python float to Java double'
assert abs(-2) == 2l, 'Python int to Java long'
assert abs(-2l) == 2l, 'Python long to Java long'
try: abs(-123456789123456789123l)
except TypeError: pass
print 'strings'
from java.lang import Integer, String
assert Integer.valueOf('42') == 42, 'Python string to Java string'
print 'arrays'
chars = ['a', 'b', 'c']
assert String.valueOf(chars) == 'abc', 'char array'
print 'Enumerations'
from java.util import Vector
vec = Vector()
items = range(10)
for i in items:
vec.addElement(i)
expected = 0
for i in vec:
示例3: test_strings
# 需要导入模块: from java.lang import Integer [as 别名]
# 或者: from java.lang.Integer import valueOf [as 别名]
def test_strings(self):
self.assertEqual(Integer.valueOf('42'), 42,
'Python string to Java string')