Is there a way for the data I read from a NFC tag to then be able to translate that data into a choice of my own? For example, I scan a tag with direction data on it. How can I choose which language I wish to read that data in?
NFC tags don't have much memory. And the ones that do have more memory are much more expensive.
And so sometimes data is represented with a short hexadecimal number. In the case of transit data for instance, in San Francisco this application called Farebot will be able to tell you which Bart Station you got in and which Bart Station you exited (BART stands for Bay Area Rapid Transit, it's a type of medium-range subway train that connects multiple cities within the Bay Area).
But instead of storing "16th Street Mission" inside the transit card, it might only store a shorter hexadecimal number like B2
And inside the Farebot application, there would already be an internal table that knows that B2 is equivalent to "16th Street Mission" for instance, but depending on the language setting of your app, there is no reason that you couldn't have a French table that tells you that B2 corresponds to "16eme Rue Mission" also.
Does my explanation make sense? Unfortunately, with the limited memory of NFC tags, you can't store too much data within the tag/card itself, and so storing multiple translations inside the tag itself wouldn't make a lot of sense.
It's the case that NFC tags can only hold limited amounts of data (think very small chunks of data) exactly as Stephan above said. To see you an example of another app made using NFC tags, kindly go to this repo and see the MainActivity, more precisely what's inside the if-statement starting from line 114 (I would've pasted the code, but it's not formatted properly). What it does is it gets the data from the tag and esentially translates it into a string that, if I remember well, was only something like (LR1, LR2, LR3...) and so on. How you "interpret" this tiny bit of information should be entirely on your app's backend code (e.g. we knew that LR1 was lecture room 1 so we had an idea of what to do).
What I'm trying to say is that you can encode hexadecimal strings of limited length on the NFC and then convert it back to whatever data structure you want to use, but the logic and interpretation take place on your app's side. The repo above shows an example on how to do this in java.
If I understand your question fine.
** NFC tags have very little memory, so you might have to build a dictionary in your application
For ex:
A1 is mapped to Right
B1 is mapped to Left. etc
Then you store A1 or B1 for example on your tags.
Then what you need to do is, when you resolve the A1 to Right after that you need to call a Translate API like
Google translate
Bing FREE
Related
I have a bit of a rookie question regarding storage of map data i a java game. I'm making a 2d tile-based game, where each tile has an id (1, 2, 3, 4 and so on...). I currently store the game data in a .txt file, where each number is seperated by a tab. Therefrom i read it via scanners .nextInt.
This method works fine, but it seems to give me a problem:
Since the level file is just a normal .txt file it is easily edited by anyone. This means that the user could just change a few numbers in the file with any kind of text editor and thereby easily cheat.
How would this be avoided? Should i store the map data differently or should i use some form of encryption?
One solution to this would be to store the data in a database, such as derby. Once the game has been exported as a jar file the casual player will never even see the file, and if they do get their hands on it, probably wouldn't know what to do with it.
Here is a nice tutorial on how to set up and connect to a simple derby database.
http://www.vogella.com/tutorials/ApacheDerby/article.html
good luck.
Java has a Serializable interface that can be used to save java objects.
API docs can be found here: http://docs.oracle.com/javase/7/docs/api/java/io/Serializable.html
This doesn't make it impossible for people to cheat and change the maps just more difficult.
If you're really worried about it you could use some form of encryption or add a checksum to further prevent tampering.
I have two api for getting a description of apps and one common UI. I need to check whether the description come with CDATA tag or not in Java.
For example, one app has the following description :
"<![CDATA[<p>What is Skype?<br />Skype is software that enables the world's
conversations. Millions of individuals and businesses use Skype to make free video and voice
calls, send instant messages and share files with other Skype users. Everyday, people also
use Skype to make low-cost calls to landlines and mobiles.</p>]]>"
And another app has the following description
Run with your fingers as fast as you can to try and get to the top of the leader board. This
game gets even better with friends, Once people see you playing they will want to have a go
and try to beat your fastest time. Tip: Take long strides on the screen to get maximum
distance per step,
<a href=https://abc.defgh.ij.kl/apps/wap/shopping/shopping/freshima-supermarket/freshima-supermarket/web/>WAP URL</a>
How can I differentiate there two description? Is there a way to detect whether the description comes with CDATA or not in Java?
How are you parsing your XML?
If you are using StAX, you can get the current event that you encounter in your stream, which might be XMLStreamConstants.CHARACTERS or XMLStreamConstants.CDATA.
If you are getting a Node Object (like for instance via XPathAPI), the Object will offer you a getNodeType() Method. Also Node has Constants for Node.TEXT_NODE and
Node.CDATA_SECTION_NODE.
More Information would be helpful answering your question.
Regards,
Max
You should not be treating the following two examples differently, because as far as XML is concerned, they are just different ways of escaping the same content:
<a><![CDATA[<xyz/>]]></a>
<a><xyz/></a>
So perhaps your test is simply "does the text content contain a < character?".
I am working on a project here that ingests internal resumes from people at my company, strips out the skills and relevant content from them and stores it in a database. This was all done using docx4j and Grails. This required the resumes to first be submitted via a template that formatted everything just right so that the ingest tool knew what to look for to strip the data.
The 2nd portion of this, is what if we want to get out a "reduced" resume from the database. In other words, I want to search the uploaded content I now have, and only print out new resumes for people who have Java programming experience lets say. So I can go into my database, find the people who originally had java as a skill, and output a new set of resumes that are also still in a nice templated format, and only have the relevant info in them, instead of ALL the content.
I have been writing some software to do this in Java that will basically use a docx template, overwriting the items in customXML which are bound to the content controls in the doc, so the new data shows up and can eb saved as a new docx with that custom data.
This seems really cumbersome to me, and has some limitations. For one, lets say my template has a place for 3 Skills, and the particular person has 8 skills. There seems to be no good way to add those 5 additional skills to the docx other than painstakingly inserting the data with all of the formatting XML tags and such. This is a real pain, because if the template changes, I dont want to have to go back into my software and edit source code to change that additional data input XML tag to bold instead of italic.
I was doing some reading up on using Infopath to create a form that I could use to get the input, connecting to some sharepoint data source or something to store the stripped out data. However, I can't seem to find out if it is possible using sharepoint to get the data back out, in a nice formatted way. What would the general steps for this be? It seems like I couldnt find very much about this topic with any quick googling.
Thanks
You could set up the skills:
<skills>
<skill>..</skill>
<skill>..</skill>
and use a "repeat" content control pointing to the container. This would handle any number of <skill> entries.
I'm making a game in Java, and I need a good file format to store the player's saved data.
Any suggestions?
Feel free to give examples in code if you want.
EDIT: This is a server-client game, so the saved data will be on the server's machine. Also, I don't want to use Serialization.
XML
let's you save any data structure you may have in a standard format and you won't need to write your own parser/writer for it
if you need the files to be "secured" from gamers changing their scores/progress/... (not sure where the files are stored? or whether this matters?) you could pass the XML through an encryption algorithm or encrypt the data elements before putting them into the XML
All of the answers so far seem to be about XML, which isn't a bad format, but there are other options you might find useful, which should make your startup times faster:
Json: Common and has been around longer than my next two suggestions.
Thrift: What Facebook uses. Should be faster than Json, supported by less languages.
Protocol Buffers: Used by Google. Probably the fastest, and also easy to extend.
Or just make your classes support Serializable.
If as you say, the information will be saved on the server it should definitely be in a database. The typical game protocol is store the user information in a database - pull it into memory when they login, with lazy updates to the db for changes to the object in memory (keeps game performance high) as they play the game and update their "in memory" user game state object.
Don't limit the scalability of your game by starting with file based storage just because it might be slightly easier.
Since its your game, you could define a file format yourself. For saving game's state directly serializing and storing will do. As for the players saved data (which could be his level progress, game score etc) you could use XML.
<?xml version="1.0"?>
<Game>
<player id="01d">
<name>
John
</name>
<skill>
Rookie
</skill>
<score>
122
</score>
</player>
</Game>
Ofcourse you could encrypt it to make it hack-proof
What's the best way to do spreadsheet-like calculations in a programming language? Example: A multi-user application needs to be available over the web that crunches columns and cells of numbers like a spread-sheet based on user submission. What are the best data structures/ database models/patterns to handle this type of work so that handling the different columns are done efficiently and easily in php, java, or even .Net. Is it better to use data structures within the language, or is it better to use a database? If using a database is the way, how does one go about doing this?
To do the actual calculation, look at graph theory. Basically you want to represent each cell as a node in a graph and each dependency as a directed edge. Next, do a topological sort to calculate the value of each cell in the right order.
Aspose.Cells (formerly Aspose.Excel.Web) is a good way to get the functionality you are looking for.
Unless you are asking more for a "How is it done?" than "I need to do it." Then I would look at the other answers given.
Along the lines of "I need to do it"
Microsoft has Excel Services which does just what you want.
Spreadsheet operations on the server. It is available via a web services interface, so you can connect and drive calculations from Java, PHP, .NET, whatever.
Excel Services is part of Sharepoint 2007.
Resolver One is a Spreadsheet app made in IronPython.
There is an explanation of the overall mechanic for the calculation [pythonology.org] it uses for user generated ecuations.
The relevant image showing Resolver One's overall algorithm.
Should note that users can write python code to be interpreted both on the cells and a special 'outside of sheet' place.
Look at another question here in SO, from where I reused my answer.
I can't tell you how to do it. But I would recommend you to look at the code of PHPExcel. PHPExcel is a library that allows you to create Excel files within PHP.
The workflow of PHPExcel is simplified like this:
Create an empty Excel file object
Add cells (with either data or formulas) to the "Excel file"
Call the create function which is generating the file itself
In your case you would have to replace 3. with something like "Create web interface".
Therefore I would recommend you to look at the code of this open source project and look how the general structure is. This should help you solving your problem.
I once used a binary tree to store the output of parsing a string using BODMAS. Each node was an operation between two other nodes, which could be a number, a variable or another operation.
So y = x * x + 2
became:
+
* 2
x x
Sadly this was at school in Pascal and is stored on a 5 1/4" disk, so you don't want it :)
SpreadsheetGear for .NET will let you load Excel workbooks, plug in values, calculate and then get the results.
You can see a few simple ASP.NET calculation samples here, other ASP.NET samples here and download a free trial here.
Disclaimer: I own SpreadsheetGear LLC
I must point out that google spreadsheets already does this kind of stuff.