本文整理汇总了Python中java.lang.Integer类的典型用法代码示例。如果您正苦于以下问题:Python Integer类的具体用法?Python Integer怎么用?Python Integer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Integer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_zones
def load_zones(app):
"""Read favourite zones
"""
app.zones = []
favZonesDir = File(File.separator.join([app.SCRIPTDIR,
"configuration",
"favourite_zones"]))
for zoneFile in sorted(favZonesDir.listFiles()):
name = zoneFile.getName()[:-4]
fileName = zoneFile.getPath()
zoneFile = open(fileName)
fileContent = zoneFile.read()
if len(fileContent.split("|")) == 2:
geomString, country = fileContent.split("|")
country = country.upper()
else:
geomString = fileContent
country = ""
zoneFile.close()
zType = "rectangle"
try:
Integer.parseInt(geomString[0])
except NumberFormatException:
zType = "polygon"
zone = Zone(app, name, zType, geomString, country)
app.zones.append(zone)
if name == app.favZoneName:
app.favZone = zone
#Fav zone is active but its data is missing
if app.favouriteZoneStatus and app.favZone is None:
app.favouriteZoneStatus = False
示例2: retrieve_an_archive
def retrieve_an_archive(cust_id, archive_name, user_id, chunk_hint, file_name, output_ids):
print "\nretrieve_a_chunk routine:: output file_name is :", file_name
try:
outfile_stream = FileOutputStream(file_name)
except:
print "retrieve_a_chunk routine:: Failed to open output stream on file : ", file_name, "..returning"
return None
# retrieve data
mc = ManagementContainer.getInstance()
rm = mc.getRecoveryManager()
l_cust_id = Integer.parseInt(cust_id);
l_user_id = Integer.parseInt(user_id);
sosw = IRecoveryManager.SimpleOutputStreamWrapper(outfile_stream)
try:
rm.createPerUserActiveRecoveryArchiveFile(l_cust_id, archive_name, l_user_id, sosw, chunk_hint)
except:
print "retrieve_a_chunk routine:: `Exception while creating active recovery archive..returning"
sys.exc_info()[1].printStackTrace()
print("*** print_exc:")
traceback.print_exc(file=sys.stdout)
outfile_stream.close()
raise
outfile_stream.close()
return get_chunk_hint(file_name, output_ids)
示例3: test_byte_value
def test_byte_value(self):
from java.lang import Integer
try:
# call instance from class, should throw but not crash
Integer.byteValue()
except:
pass
示例4: test_number_format
def test_number_format(self):
try:
Integer.parseInt('asdf')
except Exception as ex:
if jep.USE_MAPPED_EXCEPTIONS:
self.assertTrue(isinstance(ex, jep.NumberFormatException))
else:
self.assertEquals(ex.java_name, 'java.lang.NumberFormatException')
示例5: get_values
def get_values(self):
i = Integer(-5)
pi = i.intValue()
j = Long(5001)
pj = j.longValue()
d = Double(10.001)
pd = d.doubleValue()
return i, pi, j, pj, d, pd
示例6: warn
def warn(self, e):
errorNumber = self.textfield.getText()
if errorNumber == "":
self.textfield.setBorder(self.defaultborder)
return
try:
Integer.parseInt(errorNumber)
except NumberFormatException:
self.textfield.setBorder(BorderFactory.createLineBorder(Color.RED, 1))
return
self.textfield.setBorder(BorderFactory.createLineBorder(Color.GREEN, 1))
示例7: test_bigtest05
def test_bigtest05(self):
'''Get recids_hm_intint'''
message = self.bridge.createMessage('bigtest') \
.setParam('action', 'recids_hm_intint') \
.setParam('size', self.size)
self.bridge.sendMessage(message)
res = HashMap.cast_(message.getResults())
assert res.size() == self.size
assert Integer.cast_(res.get(0)).equals(0)
assert Integer.cast_(res.get(5)).equals(5)
示例8: test_pow
def test_pow(self):
i, pi, j, pj, d, pd = self.get_values()
self.assertEqual(pow(i, i), pow(pi, pi))
self.assertEqual(pow(i, 3), pow(pi, 3))
self.assertEqual(pow(j, j), pow(pj, pj))
self.assertEqual(pow(j, 301), pow(pj, 301))
self.assertEqual(pow(d, d), pow(pd, pd))
self.assertEqual(pow(d, 4.53), pow(pd, 4.53))
k = Integer(2)
pk = k.intValue()
self.assertEqual(pow(i, 3, k), pow(pi, 3, pk))
self.assertEqual(pow(j, 301, k), pow(pj, 301, pk))
示例9: initializeServices
def initializeServices(self):
self.updateUtilizationInfo = 1
self.discoverDependLinks = Boolean.parseBoolean(self.getParameterValue('discoverDependLinks'))
self.onlyHostDependLinks = 0
self.ignoreUnackedTcpConn = 0
self.shouldCountClients = 1
self.discoverIP = self.Framework.getDestinationAttribute('ip_address')
self.hostId = self.Framework.getDestinationAttribute('hostId')
self.minimalClients = Integer.parseInt(self.Framework.getParameter('minClients'))
self.minimalOctets = Integer.parseInt(self.Framework.getParameter('minOctets'))
self.minimalPackets = Integer.parseInt(self.Framework.getParameter('minPackets'))
self.protocols = self.Framework.getParameter('protocols')
self.disregardListenPorts = Boolean.parseBoolean(self.getParameterValue('disregardListenPorts'))
示例10: get_recids_changes
def get_recids_changes(message):
"""Retrieves the recids of the last changed documents"""
last_recid = None
table = 'bibrec'
if message.getParam("table"):
table = str(message.getParam("table"))
if message.getParam("last_recid"):
#last_recid = int(Integer.cast_(message.getParam("last_recid")).intValue())
last_recid = int(str(message.getParam("last_recid")))
mod_date = None
if message.getParam("mod_date"):
mod_date = str(message.getParam("mod_date"))
max_records = 10000
if message.getParam('max_records'):
max_records = int(Integer.cast_(message.getParam("max_records")).intValue())
if last_recid and last_recid == -1:
mod_date = None
(wid, results) = api_calls.dispatch("get_recids_changes", last_recid, max_recs=max_records,
mod_date=mod_date, table=table)
if results:
data, last_recid, mod_date = results
out = HashMap() #.of_(String, JArray_int)
for k,v in data.items():
out.put(k, JArray_int(v))
message.setResults(out)
message.setParam('mod_date', mod_date)
message.setParam('last_recid', last_recid)
示例11: servicesPorts
def servicesPorts(self, onlyKnownPorts = 1):
services = self.Framework.getParameter('services')
if logger.isDebugEnabled():
logger.debug('Requested services:', services)
if (services == None) or (len(services) == 0) or (services == '*'):
if onlyKnownPorts:
portsInfo = self.knownPortsConfigFile.getTcpPorts()
services = ''
delimiter = ''
for info in portsInfo:
services = services + delimiter + str(info.getPortNumber())
delimiter = ','
if len(services) == 0:
return services
else:
return ''
names = services.split(',')
ports = ''
delimiter = ''
for name in names:
portNums = self.knownPortsConfigFile.getPortByName(name)
if (portNums == None) or (len(portNums) == 0):
try:
portNums = [Integer.parseInt(name)]
except:
logger.debug('Failed to resolve service port number:', name)
continue
for portNum in portNums:
ports = ports + delimiter + str(portNum)
delimiter = ','
if logger.isDebugEnabled():
logger.debug('Requested services ports:', ports)
return ports
示例12: equals
def equals(self, other):
try:
selfIntValue = self.getIntValue()
otherIntValue = other.getIntValue()
return _Integer.equals(selfIntValue, otherIntValue)
#
except:
return False
示例13: diagnostic_test
def diagnostic_test(message):
out = []
message.setParam("query", "boson")
perform_request_search_ints(message)
res = JArray_int.cast_(message.getResults())
out.append('Search for "boson" retrieved: %s hits' % len(res) )
out.append('Total hits: %s' % Integer.cast_(message.getParam("total")))
message.setResults('\n'.join(out))
示例14: buildBarChart
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()
示例15: pyValToJavaObj
def pyValToJavaObj(val):
retObj = val
valtype = type(val)
if valtype is int:
retObj = Integer(val)
elif valtype is float:
retObj = Float(val)
elif valtype is long:
retObj = Long(val)
elif valtype is bool:
retObj = Boolean(val)
elif valtype is list:
retObj = ArrayList()
for i in val:
retObj.add(pyValToJavaObj(i))
elif valtype is tuple:
tempList = ArrayList()
for i in val:
tempList.add(pyValToJavaObj(i))
retObj = Collections.unmodifiableList(tempList)
elif issubclass(valtype, dict):
retObj = pyDictToJavaMap(val)
elif issubclass(valtype, JavaWrapperClass):
retObj = val.toJavaObj()
return retObj